/**
 * Copyright 2008-2009 DRIVER PROJECT (ICM UW)
 * Original author: Marek Horst
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package eu.dnetlib.data.ismock;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

import javax.xml.ws.wsaddressing.W3CEndpointReference;

import eu.dnetlib.data.index.utils.QueryProvider;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;

/**
 * Very simple mock IS-LU class, for performing junit index tests.
 * @author mhorst
 *
 */
public class MockISLookUp implements ISLookUpService {

	MockDataContainer dataContainer;

	public List<String> describeMethods() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> describeVerbs() {
		// TODO Auto-generated method stub
		return null;
	}

	public Boolean flushCachedResultSets() {
		// TODO Auto-generated method stub
		return false;
	}

	public String getResourceProfile(String profId) {
		return dataContainer.getResourceProfile(profId);
	}

	public String getResourceProfileByQuery(String XQuery) {
//	support for DMF mdformat
		if (XQuery!=null) {
			if (QueryProvider.findMDFormatResource("DMF").equals(XQuery)) {
				String file = "/eu/dnetlib/data/ismock/mdformat-dmf.xml";
				try {
					InputStream is = MockISLookUp.class.getResourceAsStream(file);
					BufferedInputStream bis = new BufferedInputStream(is);
					InputStreamReader isr = new InputStreamReader(bis);
					BufferedReader reader = new BufferedReader(isr);
					StringBuffer strBuff = new StringBuffer();
					String line = null;
					while ((line = reader.readLine())!=null) {
						strBuff.append(line);
					}
					System.out.println("MDFormat content: "+strBuff.toString());
					return strBuff.toString();
				} catch (IOException e) {
					throw new RuntimeException("couldn't load reasource: " + file, e);
				}
			} else {
				return null;
			}
		} else {
			return null;
		}
	}

	public String getResourceQoSParams(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	public String getResourceTypeSchema(String resourceType) {
		// TODO Auto-generated method stub
		return null;
	}

	public String identify() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean isAnOpenDLib2Service() {
		// TODO Auto-generated method stub
		return false;
	}


	public W3CEndpointReference listCommunities() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> listDHNIDs() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> listResourceTypes() {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> listServiceIDs(String serviceType) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<String> listServiceTypes() {
		// TODO Auto-generated method stub
		return null;
	}

	public void notify(String subscrId, String topic, String isId,
			String message) {
		// TODO Auto-generated method stub
	}

	public boolean postConfig(int delay) {
		// TODO Auto-generated method stub
		return false;
	}

	public List<String> quickSearchProfile(String XQuery) {
		// TODO Auto-generated method stub
		return null;
	}

	public W3CEndpointReference searchProfile(String XQuery) {
		// TODO Auto-generated method stub
		return null;
	}

	public MockDataContainer getDataContainer() {
		return dataContainer;
	}

	public void setDataContainer(MockDataContainer dataContainer) {
		this.dataContainer = dataContainer;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService#getCollection(java.lang.String, java.lang.String)
	 */
//	@Override
	public String getCollection(String profId, String format)
			throws ISLookUpException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService#listCollections(java.lang.String, java.lang.String, java.lang.String)
	 */
//	@Override
	public W3CEndpointReference listCollections(String format, String idfather,
			String owner) throws ISLookUpException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService#listMDStores(java.lang.String)
	 */
//	@Override
	public W3CEndpointReference listMDStores(String metadataformat)
			throws ISLookUpException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService#listResourceProfiles(java.lang.String, java.lang.String, java.lang.String)
	 */
//	@Override
	public W3CEndpointReference listResourceProfiles(String resourceKind,
			String format, String resourceType) throws ISLookUpException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.common.rmi.BaseService#start()
	 */
//	@Override
	public void start() {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService#retrieveCollection(java.lang.String)
	 */
	@Override
	public String retrieveCollection(String profId) throws ISLookUpException {
		// TODO Auto-generated method stub
		return null;
	}

}
