package org.biomoby.registry.sync.handler;

import org.biomoby.shared.MobyException;
import org.biomoby.shared.MobyNamespace;

/**
 * Class to synchronize the namespaces in the biomoby centrals.
 * 
 * @author groscurt
 */
public class NamespaceHandler extends AbstractMobyHandler< MobyNamespace > {
	public NamespaceHandler(String authority) throws MobyException {
		super(authority);
	}

	public boolean register( MobyNamespace namespace ) {
		try {
			// try to register the namespace at the local central
			localCentral.registerNamespace( namespace );
		}
		catch ( Exception e ) {
			logger.warning( "The namespace " + namespace.getName() + " could not be added !\n" + e.getLocalizedMessage() );
			return false;
		}
		return true;
	}

	public boolean unregister( MobyNamespace namespace ) {
		try {
			// try to unregister the namespace
			localCentral.unregisterNamespace( namespace );
		}
		catch ( Exception e ) {
			logger.warning( "The namespace " + namespace.getName() + " could not be unregistered !\n"
					+ e.getLocalizedMessage() );
			return false;
		}
		return true;
	}
}
