/**
 * Copyright 2008-2009 DRIVER PROJECT (Bielefeld University)
 * Original author: Marek Imialek <marek.imialek at uni-bielefeld.de>
 *
 * 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.contract.mocks;

import java.util.List;

import eu.dnetlib.enabling.is.registry.ISRegistryDocumentNotFoundException;
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;

/**
 * @author <a href="mailto:marek.imialek at uni-bielefeld.de">Marek Imialek</a>
 *
 */
public class mockISRegistryService implements ISRegistryService {

	public mockISStorage isStorage;
	
	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#addBlackBoardMessage(java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public void addBlackBoardMessage(String profId, String messageId,
			String message) throws ISRegistryException {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#addOrUpdateResourceType(java.lang.String, java.lang.String)
	 */
	@Override
	public boolean addOrUpdateResourceType(String resourceType,
			String resourceSchema) throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#addProfileNode(java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public boolean addProfileNode(String profId, String xpath, String node)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#addResourceType(java.lang.String, java.lang.String)
	 */
	@Override
	public boolean addResourceType(String resourceType, String resourceSchema)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#deleteBlackBoardMessage(java.lang.String, java.lang.String)
	 */
	@Override
	public void deleteBlackBoardMessage(String profId, String messageId)
			throws ISRegistryException {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#deleteProfile(java.lang.String)
	 */
	@Override
	public boolean deleteProfile(String profId) throws ISRegistryException,
			ISRegistryDocumentNotFoundException {
		
		if (this.isStorage.get(profId) == null)
			throw new ISRegistryDocumentNotFoundException(
						"Resource not found in the storage");

		String resp = this.isStorage.remove(profId);
		if (resp != null)
			return true;
		else	
			return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#deleteProfiles(java.util.List)
	 */
	@Override
	public boolean deleteProfiles(List<String> arrayprofId)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#deleteResourceType(java.lang.String, java.lang.Boolean)
	 */
	@Override
	public boolean deleteResourceType(String resourceType, Boolean hierarchical)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#executeXUpdate(java.lang.String)
	 */
	@Override
	public boolean executeXUpdate(String XQuery) throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#insertProfileForValidation(java.lang.String, java.lang.String)
	 */
	@Override
	public String insertProfileForValidation(String resourceType,
			String resourceProfile) throws ISRegistryException {
		// TODO Auto-generated method stub
		return null;
	}

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

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#refreshProfile(java.lang.String, java.lang.String)
	 */
	@Override
	public boolean refreshProfile(String profId, String resourceType)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#registerProfile(java.lang.String)
	 */
	@Override
	public String registerProfile(String resourceProfile)
			throws ISRegistryException {
		
		int numberOfStoredProfiles = isStorage.getSize();	
		String profileId = "sts-identifier-"+ numberOfStoredProfiles;
		isStorage.store(profileId, resourceProfile);
		
		return profileId;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#registerSecureProfile(java.lang.String, java.lang.String)
	 */
	@Override
	public String registerSecureProfile(String resourceProfId,
			String secureProfId) throws ISRegistryException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#removeProfileNode(java.lang.String, java.lang.String)
	 */
	@Override
	public boolean removeProfileNode(String profId, String nodeId)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#replyBlackBoardMessage(java.lang.String, java.lang.String)
	 */
	@Override
	public void replyBlackBoardMessage(String profId, String message)
			throws ISRegistryException {
		// TODO Auto-generated method stub

	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#updateProfile(java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public boolean updateProfile(String profId, String resourceProfile,
			String resourceType) throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#updateProfileDHN(java.lang.String)
	 */
	@Override
	public String updateProfileDHN(String resourceProfile)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#updateProfileNode(java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public boolean updateProfileNode(String profId, String xpath, String node)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#updateRegionDescription(java.lang.String, java.lang.String)
	 */
	@Override
	public boolean updateRegionDescription(String profId, String resourceProfile)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return false;
	}

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

	/* (non-Javadoc)
	 * @see eu.dnetlib.enabling.is.registry.rmi.ISRegistryService#validateProfiles(java.util.List)
	 */
	@Override
	public List<String> validateProfiles(List<String> profIds)
			throws ISRegistryException {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.common.rmi.BaseService#identify()
	 */
	@Override
	public String identify() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see eu.dnetlib.common.rmi.BaseService#notify(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
	 */
	@Override
	public void notify(String subscriptionId, String topic, String isId,
			String message) {
		// TODO Auto-generated method stub

	}

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

	}

	/**
	 * @param mockISStorage the mockISStorage to set
	 */
	public void setIsStorage(mockISStorage isStorage) {
		this.isStorage = isStorage;
	}

	/**
	 * @return the mockISStorage
	 */
	public mockISStorage getIsStorage() {
		return isStorage;
	}

}
