package eu.dnetlib.functionality.index;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import eu.dnetlib.enabling.tools.UniqueIdentifierGenerator;
import eu.dnetlib.enabling.tools.UniqueIdentifierGeneratorImpl;
import eu.dnetlib.enabling.tools.blackboard.AbstractBlackboardNotificationHandler;
import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;

/**
 * Accepts index creation and feed but mocks those operations.
 *
 * @author marko
 *
 */
public class IndexMockNotificationHandler extends AbstractBlackboardNotificationHandler<BlackboardServerHandler> {

	/**
	 * logger.
	 */
	private static final Log log = LogFactory.getLog(IndexMockNotificationHandler.class); // NOPMD by marko on 11/24/08 5:02 PM

	/**
	 * generate mock index profile identifiers.
	 */
	private UniqueIdentifierGenerator uuidGenerator = new UniqueIdentifierGeneratorImpl();

	@Override
	protected void processJob(BlackboardJob job) {
		log.info("processing mock index job: " + job.getAction());

		if(job.getAction().equals("CREATE"))
			job.getParameters().put("id", uuidGenerator.generateIdentifier());

		getBlackboardHandler().done(job);
	}

}
