Index: modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/trunk/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>6.0.1-SNAPSHOT</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,123 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import java.util.List;
+import java.util.Map;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+
+    public List<String> getMDStoreRecords(final String mdId, final int pageSize, final int offset, final Map<String, String> queryParam) throws MDStoreServiceException {
+
+        return retriever.getMDStoreRecords(mdId, pageSize, offset, queryParam);
+
+    }
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import java.util.List;
+import java.util.Map;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+    public List<String> getMDStoreRecords(final String mdId, int pageSize, final int offset, final Map<String, String> queryParam) throws MDStoreServiceException {
+        MDStore mdStore = dao.getMDStore(mdId);
+        return mdStore.deliver(mdId, pageSize, offset, queryParam);
+    }
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,8 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
+services.mdstore.readlock.expire.days=3
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/trunk/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/trunk/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import java.util.List;
+import java.util.Map;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+    public List<String> getMDStoreRecords(final String mdId, int pageSize, final int offset, final Map<String, String> queryParam) throws MDStoreServiceException {
+        MDStore mdStore = dao.getMDStore(mdId);
+        return mdStore.deliver(mdId, pageSize, offset, queryParam);
+    }
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+	@Override
+	public String toString() {
+		return "MDStoreDBStatus{" +
+				"handledDatastructures=" + handledDatastructures +
+				", usedDiskSpace=" + usedDiskSpace +
+				", date='" + date + '\'' +
+				'}';
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(revision 45150)
@@ -0,0 +1,42 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>6.0.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,154 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.collect.Maps;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.action.DoneCallback;
+import eu.dnetlib.data.mdstore.modular.action.FailedCallback;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import java.util.List;
+import java.util.Map;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+                     final String rsEpr,
+                     final String storingType,
+                     final boolean sync,
+                     final List<MDFormatDescription> mdformats,
+                     final DoneCallback doneCallback,
+                     final FailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId);
+		log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+            int writeOps;
+
+            if (mdformats == null) {
+                writeOps = mdstore.feed(records, refresh);
+            } else {
+                writeOps = mdstore.feed(records, refresh, mdformats);
+            }
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(buildParams(size, writeOps));
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	private Map<String, String> buildParams(final int size, final int storeCount) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("mdstoreSize", String.valueOf(size));
+		params.put("writeOps", String.valueOf(storeCount));
+		return params;
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,154 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.collect.Maps;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.action.DoneCallback;
+import eu.dnetlib.data.mdstore.modular.action.FailedCallback;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import java.util.List;
+import java.util.Map;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+                     final String rsEpr,
+                     final String storingType,
+                     final boolean sync,
+                     final List<MDFormatDescription> mdformats,
+                     final DoneCallback doneCallback,
+                     final FailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId);
+		log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+            int writeOps;
+
+            if (mdformats == null) {
+                writeOps = mdstore.feed(records, refresh);
+            } else {
+                writeOps = mdstore.feed(records, refresh, mdformats);
+            }
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(buildParams(size, writeOps));
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	private Map<String, String> buildParams(final int size, final int storeCount) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("mdstoreSize", String.valueOf(size));
+		params.put("writeOps", String.valueOf(storeCount));
+		return params;
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(revision 45150)
@@ -0,0 +1,79 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
+import eu.dnetlib.data.mdstore.modular.MDStoreFeeder;
+import eu.dnetlib.data.mdstore.modular.MDStoreUtils;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import java.util.List;
+import java.util.Map;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+    private static final String layoutIndex = "store";
+
+	private MDStoreFeeder feeder;
+
+    @Autowired
+    private MDStoreUtils mdstoreUtils;
+
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+        String format = feeder.getDao().getMDStore(mdId).getFormat();
+        List<MDFormatDescription> mdformats = mdstoreUtils.getField(format, layoutIndex);
+
+        if (mdformats != null) {
+            for (MDFormatDescription desc : mdformats) {
+                log.info("name: " + desc.getName());
+                log.info("xpath: " + desc.getXpath());
+            }
+        }
+
+
+        feeder.feed(mdId, epr, storingType, true, mdformats, new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().put("mdstoreSize", "" + params.get("mdstoreSize"));
+				job.getParameters().put("writeOps", "" + params.get("writeOps"));
+				completeWithSuccess(handler, job);
+			}
+		}, new FailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+import java.util.List;
+import java.util.Map;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+    int feed(Iterable<String> records, boolean incremental, List<MDFormatDescription> mdformats);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+    List<String> deliver(String mdId, int pageSize, int offset, Map<String, String> queryParam);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+	@Override
+	public String toString() {
+		return "MDStoreDBStatus{" +
+				"handledDatastructures=" + handledDatastructures +
+				", usedDiskSpace=" + usedDiskSpace +
+				", date='" + date + '\'' +
+				'}';
+	}
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(revision 45150)
@@ -0,0 +1,8 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+public interface DoneCallback {
+
+	void call(Map<String, String> params);
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class PluginAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(PluginAction.class);
+
+	@Autowired
+	private MDStorePluginEnumerator pluginEnumerator;
+
+	@Override
+	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String name = job.getParameters().get("plugin.name");
+
+		final Map<String, MDStorePlugin> plugins = pluginEnumerator.getAll();
+
+		if ((plugins == null) || plugins.isEmpty() || !plugins.containsKey(name)) throw new MDStoreServiceException("Unable to find plugin: " + name);
+
+		log.info("running MDStore plugin: " + name);
+
+		plugins.get(name).run(getDao(), job.getParameters(), new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().putAll(params);
+				handler.done(job);
+			}
+		});
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(revision 45150)
@@ -0,0 +1,36 @@
+package eu.dnetlib.data.mdstore.modular;
+
+/**
+ * Created by sandro on 11/29/16.
+ */
+public class MDFormatDescription {
+
+    private String name;
+
+    private String xpath;
+
+    public MDFormatDescription() {
+
+    }
+
+    public MDFormatDescription(String name, String xpath) {
+        this.name = name;
+        this.xpath = xpath;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getXpath() {
+        return xpath;
+    }
+
+    public void setXpath(String xpath) {
+        this.xpath = xpath;
+    }
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(revision 45150)
@@ -0,0 +1,79 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
+import eu.dnetlib.data.mdstore.modular.MDStoreFeeder;
+import eu.dnetlib.data.mdstore.modular.MDStoreUtils;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import java.util.List;
+import java.util.Map;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+    private static final String layoutIndex = "store";
+
+	private MDStoreFeeder feeder;
+
+    @Autowired
+    private MDStoreUtils mdstoreUtils;
+
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+        String format = feeder.getDao().getMDStore(mdId).getFormat();
+        List<MDFormatDescription> mdformats = mdstoreUtils.getField(format, layoutIndex);
+
+        if (mdformats != null) {
+            for (MDFormatDescription desc : mdformats) {
+                log.info("name: " + desc.getName());
+                log.info("xpath: " + desc.getXpath());
+            }
+        }
+
+
+        feeder.feed(mdId, epr, storingType, true, mdformats, new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().put("mdstoreSize", "" + params.get("mdstoreSize"));
+				job.getParameters().put("writeOps", "" + params.get("writeOps"));
+				completeWithSuccess(handler, job);
+			}
+		}, new FailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(revision 45150)
@@ -0,0 +1,23 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public class DummyPlugin implements MDStorePlugin {
+
+	private static final Log log = LogFactory.getLog(DummyPlugin.class);
+
+	@Override
+	public void run(final MDStoreDao dao, final Map<String, String> params, final DoneCallback done) {
+		log.info("Nothing to do, I'm a dummy plugin. Bye.");
+		HashMap<String, String> res = new HashMap<String, String>();
+		res.put("ret", "cheers!");
+		done.call(res);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xmlns:t="http://dnetlib.eu/springbeans/t"
+       xmlns:template="http://dnetlib.eu/springbeans/template" xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+
+
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+				<entry key="RUN_PLUGIN">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>				
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+ 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
+	
+	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />
+
+
+    <bean id="mdstoreUtils" class="eu.dnetlib.data.mdstore.modular.MDStoreUtils"/>
+	
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+<!-- 	<bean id="mdstoreRecordParser"  -->
+<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package eu.dnetlib.data.mdstore.modular.action;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED,
+	RUN_PLUGIN
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(revision 45150)
@@ -0,0 +1,81 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.collect.Lists;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+public class MDStoreUtils {
+
+    /**
+     * service locator.
+     */
+    @Autowired
+    private UniqueServiceLocator serviceLocator;
+
+    public List<MDFormatDescription> getField(final String format, final String layout) throws MDStoreServiceException {
+
+        String xquery = "for $x in collection('/db/DRIVER/MDFormatDSResources/MDFormatDSResourceType')/RESOURCE_PROFILE/BODY[CONFIGURATION/NAME='" + format + "'] return $x/STATUS/LAYOUTS/LAYOUT[@name='" + layout
+                + "']/FIELDS";
+
+        try {
+            String result = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+            final List<MDFormatDescription> mdformat = Lists.newArrayList();
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder;
+            builder = factory.newDocumentBuilder();
+            Document doc = builder.parse(new ByteArrayInputStream(result.getBytes()));
+            XPathFactory xPathFactory = XPathFactory.newInstance();
+            XPath myXpath = xPathFactory.newXPath();
+            XPathExpression expression = myXpath.compile("//FIELD");
+            Object values = expression.evaluate(doc, XPathConstants.NODESET);
+            NodeList v = (NodeList) values;
+            for (int i = 0; i < v.getLength(); i++) {
+                Node currentItem = v.item(i);
+                NamedNodeMap attributes = currentItem.getAttributes();
+                String name = null;
+                String xpath = null;
+                if (attributes.getNamedItem("name") != null) {
+                    name = attributes.getNamedItem("name").getNodeValue();
+                }
+                if (attributes.getNamedItem("xpath") != null) {
+                    xpath = attributes.getNamedItem("xpath").getNodeValue();
+                }
+                if (attributes.getNamedItem("value") != null) {
+                    xpath = attributes.getNamedItem("value").getNodeValue();
+                }
+
+                MDFormatDescription currentMdFormat = new MDFormatDescription();
+                currentMdFormat.setName(name);
+                currentMdFormat.setXpath(xpath);
+                mdformat.add(currentMdFormat);
+            }
+            return mdformat;
+
+        } catch (ISLookUpDocumentNotFoundException e1) {
+            return null;
+        } catch (ISLookUpException e1) {
+            return null;
+        } catch (Exception e) {
+            throw new MDStoreServiceException("Error on retrieving field from mdformat", e);
+        }
+
+    }
+}
+
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+			getDao().deleteMDStore(currentId);
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,8 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
+services.mdstore.readlock.expire.days=3
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,147 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.action.DoneCallback;
+import eu.dnetlib.data.mdstore.modular.action.FailedCallback;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final DoneCallback doneCallback,
+			final FailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId);
+		log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			int writeOps = mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(buildParams(size, writeOps));
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	private Map<String, String> buildParams(final int size, final int storeCount) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("mdstoreSize", String.valueOf(size));
+		params.put("writeOps", String.valueOf(storeCount));
+		return params;
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(revision 45150)
@@ -0,0 +1,42 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(revision 45150)
@@ -0,0 +1,60 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreFeeder;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().put("mdstoreSize", "" + params.get("mdstoreSize"));
+				job.getParameters().put("writeOps", "" + params.get("writeOps"));
+				completeWithSuccess(handler, job);
+			}
+		}, new FailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(revision 45150)
@@ -0,0 +1,42 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(revision 45150)
@@ -0,0 +1,8 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+public interface DoneCallback {
+
+	void call(Map<String, String> params);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class PluginAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(PluginAction.class);
+
+	@Autowired
+	private MDStorePluginEnumerator pluginEnumerator;
+
+	@Override
+	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String name = job.getParameters().get("plugin.name");
+
+		final Map<String, MDStorePlugin> plugins = pluginEnumerator.getAll();
+
+		if ((plugins == null) || plugins.isEmpty() || !plugins.containsKey(name)) throw new MDStoreServiceException("Unable to find plugin: " + name);
+
+		log.info("running MDStore plugin: " + name);
+
+		plugins.get(name).run(getDao(), job.getParameters(), new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().putAll(params);
+				handler.done(job);
+			}
+		});
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+public interface FailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(revision 45150)
@@ -0,0 +1,8 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+public interface DoneCallback {
+
+	void call(Map<String, String> params);
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(revision 45150)
@@ -0,0 +1,23 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public class DummyPlugin implements MDStorePlugin {
+
+	private static final Log log = LogFactory.getLog(DummyPlugin.class);
+
+	@Override
+	public void run(final MDStoreDao dao, final Map<String, String> params, final DoneCallback done) {
+		log.info("Nothing to do, I'm a dummy plugin. Bye.");
+		HashMap<String, String> res = new HashMap<String, String>();
+		res.put("ret", "cheers!");
+		done.call(res);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(revision 45150)
@@ -0,0 +1,23 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public class DummyPlugin implements MDStorePlugin {
+
+	private static final Log log = LogFactory.getLog(DummyPlugin.class);
+
+	@Override
+	public void run(final MDStoreDao dao, final Map<String, String> params, final DoneCallback done) {
+		log.info("Nothing to do, I'm a dummy plugin. Bye.");
+		HashMap<String, String> res = new HashMap<String, String>();
+		res.put("ret", "cheers!");
+		done.call(res);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public interface MDStorePlugin {
+
+	public void run(MDStoreDao dao, Map<String, String> params, DoneCallback doneCallback) throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class PluginAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(PluginAction.class);
+
+	@Autowired
+	private MDStorePluginEnumerator pluginEnumerator;
+
+	@Override
+	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String name = job.getParameters().get("plugin.name");
+
+		final Map<String, MDStorePlugin> plugins = pluginEnumerator.getAll();
+
+		if ((plugins == null) || plugins.isEmpty() || !plugins.containsKey(name)) throw new MDStoreServiceException("Unable to find plugin: " + name);
+
+		log.info("running MDStore plugin: " + name);
+
+		plugins.get(name).run(getDao(), job.getParameters(), new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().putAll(params);
+				handler.done(job);
+			}
+		});
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package eu.dnetlib.data.mdstore.modular.action;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED,
+	RUN_PLUGIN
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package eu.dnetlib.data.mdstore.modular.action;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED,
+	RUN_PLUGIN
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+public class MDStorePluginEnumerator implements BeanFactoryAware {
+
+	// private static final Log log = LogFactory.getLog(MDStorePluginEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * bean factory.
+	 */
+	private ListableBeanFactory beanFactory;
+
+	@Override
+	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+		this.beanFactory = (ListableBeanFactory) beanFactory;
+	}
+
+	/**
+	 * Get all beans implementing the MDStorePlugin interface.
+	 *
+	 * @return
+	 */
+	public Map<String, MDStorePlugin> getAll() {
+		return beanFactory.getBeansOfType(MDStorePlugin.class);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(revision 45150)
@@ -0,0 +1,36 @@
+package eu.dnetlib.data.mdstore.modular;
+
+/**
+ * Created by sandro on 11/29/16.
+ */
+public class MDFormatDescription {
+
+    private String name;
+
+    private String xpath;
+
+    public MDFormatDescription() {
+
+    }
+
+    public MDFormatDescription(String name, String xpath) {
+        this.name = name;
+        this.xpath = xpath;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getXpath() {
+        return xpath;
+    }
+
+    public void setXpath(String xpath) {
+        this.xpath = xpath;
+    }
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(revision 45150)
@@ -0,0 +1,81 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.collect.Lists;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+public class MDStoreUtils {
+
+    /**
+     * service locator.
+     */
+    @Autowired
+    private UniqueServiceLocator serviceLocator;
+
+    public List<MDFormatDescription> getField(final String format, final String layout) throws MDStoreServiceException {
+
+        String xquery = "for $x in collection('/db/DRIVER/MDFormatDSResources/MDFormatDSResourceType')/RESOURCE_PROFILE/BODY[CONFIGURATION/NAME='" + format + "'] return $x/STATUS/LAYOUTS/LAYOUT[@name='" + layout
+                + "']/FIELDS";
+
+        try {
+            String result = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+            final List<MDFormatDescription> mdformat = Lists.newArrayList();
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder;
+            builder = factory.newDocumentBuilder();
+            Document doc = builder.parse(new ByteArrayInputStream(result.getBytes()));
+            XPathFactory xPathFactory = XPathFactory.newInstance();
+            XPath myXpath = xPathFactory.newXPath();
+            XPathExpression expression = myXpath.compile("//FIELD");
+            Object values = expression.evaluate(doc, XPathConstants.NODESET);
+            NodeList v = (NodeList) values;
+            for (int i = 0; i < v.getLength(); i++) {
+                Node currentItem = v.item(i);
+                NamedNodeMap attributes = currentItem.getAttributes();
+                String name = null;
+                String xpath = null;
+                if (attributes.getNamedItem("name") != null) {
+                    name = attributes.getNamedItem("name").getNodeValue();
+                }
+                if (attributes.getNamedItem("xpath") != null) {
+                    xpath = attributes.getNamedItem("xpath").getNodeValue();
+                }
+                if (attributes.getNamedItem("value") != null) {
+                    xpath = attributes.getNamedItem("value").getNodeValue();
+                }
+
+                MDFormatDescription currentMdFormat = new MDFormatDescription();
+                currentMdFormat.setName(name);
+                currentMdFormat.setXpath(xpath);
+                mdformat.add(currentMdFormat);
+            }
+            return mdformat;
+
+        } catch (ISLookUpDocumentNotFoundException e1) {
+            return null;
+        } catch (ISLookUpException e1) {
+            return null;
+        } catch (Exception e) {
+            throw new MDStoreServiceException("Error on retrieving field from mdformat", e);
+        }
+
+    }
+}
+
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:p="http://www.springframework.org/schema/p"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xmlns:t="http://dnetlib.eu/springbeans/t"
+       xmlns:template="http://dnetlib.eu/springbeans/template" xmlns="http://www.springframework.org/schema/beans"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+
+
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+				<entry key="RUN_PLUGIN">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>				
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+ 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
+	
+	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />
+
+
+    <bean id="mdstoreUtils" class="eu.dnetlib.data.mdstore.modular.MDStoreUtils"/>
+	
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+<!-- 	<bean id="mdstoreRecordParser"  -->
+<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,8 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
+services.mdstore.readlock.expire.days=3
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/trunk
===================================================================
--- modules/cnr-modular-mdstore-service/trunk	(nonexistent)
+++ modules/cnr-modular-mdstore-service/trunk	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/trunk
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,123 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import java.util.List;
+import java.util.Map;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+
+    public List<String> getMDStoreRecords(final String mdId, final int pageSize, final int offset, final Map<String, String> queryParam) throws MDStoreServiceException {
+
+        return retriever.getMDStoreRecords(mdId, pageSize, offset, queryParam);
+
+    }
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+import java.util.List;
+import java.util.Map;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+    int feed(Iterable<String> records, boolean incremental, List<MDFormatDescription> mdformats);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+    List<String> deliver(String mdId, int pageSize, int offset, Map<String, String> queryParam);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>5.0.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+			getDao().deleteMDStore(currentId);
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+public interface FailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public interface MDStorePlugin {
+
+	public void run(MDStoreDao dao, Map<String, String> params, DoneCallback doneCallback) throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(revision 45150)
@@ -0,0 +1,60 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreFeeder;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().put("total", "" + params.get("size"));
+				job.getParameters().put("stored", "" + params.get("stored"));
+				completeWithSuccess(handler, job);
+			}
+		}, new FailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+public class MDStorePluginEnumerator implements BeanFactoryAware {
+
+	// private static final Log log = LogFactory.getLog(MDStorePluginEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * bean factory.
+	 */
+	private ListableBeanFactory beanFactory;
+
+	@Override
+	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+		this.beanFactory = (ListableBeanFactory) beanFactory;
+	}
+
+	/**
+	 * Get all beans implementing the MDStorePlugin interface.
+	 *
+	 * @return
+	 */
+	public Map<String, MDStorePlugin> getAll() {
+		return beanFactory.getBeansOfType(MDStorePlugin.class);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+public interface FailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class PluginAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(PluginAction.class);
+
+	@Autowired
+	private MDStorePluginEnumerator pluginEnumerator;
+
+	@Override
+	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String name = job.getParameters().get("plugin.name");
+
+		final Map<String, MDStorePlugin> plugins = pluginEnumerator.getAll();
+
+		if ((plugins == null) || plugins.isEmpty() || !plugins.containsKey(name)) throw new MDStoreServiceException("Unable to find plugin: " + name);
+
+		log.info("running MDStore plugin: " + name);
+
+		plugins.get(name).run(getDao(), job.getParameters(), new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().putAll(params);
+				handler.done(job);
+			}
+		});
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-6.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>5.0.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+			getDao().deleteMDStore(currentId);
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+public interface FailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(revision 45150)
@@ -0,0 +1,42 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public interface MDStorePlugin {
+
+	public void run(MDStoreDao dao, Map<String, String> params, DoneCallback doneCallback) throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,8 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
+services.mdstore.readlock.expire.days=3
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(revision 45150)
@@ -0,0 +1,23 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public class DummyPlugin implements MDStorePlugin {
+
+	private static final Log log = LogFactory.getLog(DummyPlugin.class);
+
+	@Override
+	public void run(final MDStoreDao dao, final Map<String, String> params, final DoneCallback done) {
+		log.info("Nothing to do, I'm a dummy plugin. Bye.");
+		HashMap<String, String> res = new HashMap<String, String>();
+		res.put("ret", "cheers!");
+		done.call(res);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+public class MDStorePluginEnumerator implements BeanFactoryAware {
+
+	// private static final Log log = LogFactory.getLog(MDStorePluginEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * bean factory.
+	 */
+	private ListableBeanFactory beanFactory;
+
+	@Override
+	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+		this.beanFactory = (ListableBeanFactory) beanFactory;
+	}
+
+	/**
+	 * Get all beans implementing the MDStorePlugin interface.
+	 *
+	 * @return
+	 */
+	public Map<String, MDStorePlugin> getAll() {
+		return beanFactory.getBeansOfType(MDStorePlugin.class);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>5.0.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+	@Override
+	public String toString() {
+		return "MDStoreDBStatus{" +
+				"handledDatastructures=" + handledDatastructures +
+				", usedDiskSpace=" + usedDiskSpace +
+				", date='" + date + '\'' +
+				'}';
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+public class MDStorePluginEnumerator implements BeanFactoryAware {
+
+	// private static final Log log = LogFactory.getLog(MDStorePluginEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * bean factory.
+	 */
+	private ListableBeanFactory beanFactory;
+
+	@Override
+	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+		this.beanFactory = (ListableBeanFactory) beanFactory;
+	}
+
+	/**
+	 * Get all beans implementing the MDStorePlugin interface.
+	 *
+	 * @return
+	 */
+	public Map<String, MDStorePlugin> getAll() {
+		return beanFactory.getBeansOfType(MDStorePlugin.class);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,148 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.collect.Maps;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.action.DoneCallback;
+import eu.dnetlib.data.mdstore.modular.action.FailedCallback;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final DoneCallback doneCallback,
+			final FailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId);
+		log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(buildParams(size));
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	private Map<String, String> buildParams(final int size) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("size", String.valueOf(size));
+		return params;
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+public interface FailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public interface MDStorePlugin {
+
+	public void run(MDStoreDao dao, Map<String, String> params, DoneCallback doneCallback) throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+	@Override
+	public String toString() {
+		return "MDStoreDBStatus{" +
+				"handledDatastructures=" + handledDatastructures +
+				", usedDiskSpace=" + usedDiskSpace +
+				", date='" + date + '\'' +
+				'}';
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+				<entry key="RUN_PLUGIN">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>				
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+ 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
+	
+	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />
+	
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+<!-- 	<bean id="mdstoreRecordParser"  -->
+<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+import org.springframework.beans.factory.annotation.Required;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+			getDao().deleteMDStore(currentId);
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(revision 45150)
@@ -0,0 +1,8 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+public interface DoneCallback {
+
+	void call(Map<String, String> params);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DoneCallback.java	(revision 45150)
@@ -0,0 +1,8 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+public interface DoneCallback {
+
+	void call(Map<String, String> params);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package eu.dnetlib.data.mdstore.modular.action;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED,
+	RUN_PLUGIN
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+				<entry key="RUN_PLUGIN">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>				
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+ 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
+	
+	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />
+	
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+<!-- 	<bean id="mdstoreRecordParser"  -->
+<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/FeedAction.java	(revision 45150)
@@ -0,0 +1,60 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreFeeder;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().put("total", "" + params.get("size"));
+				completeWithSuccess(handler, job);
+			}
+		}, new FailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,147 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+import com.google.common.collect.Maps;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.action.DoneCallback;
+import eu.dnetlib.data.mdstore.modular.action.FailedCallback;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final DoneCallback doneCallback,
+			final FailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId);
+		log.debug("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			int stored = mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(buildParams(size, stored));
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	private Map<String, String> buildParams(final int size, final int storeCount) {
+		Map<String, String> params = Maps.newHashMap();
+		params.put("size", String.valueOf(size));
+		params.put("stored", String.valueOf(storeCount));
+		return params;
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/PluginAction.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class PluginAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(PluginAction.class);
+
+	@Autowired
+	private MDStorePluginEnumerator pluginEnumerator;
+
+	@Override
+	protected void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String name = job.getParameters().get("plugin.name");
+
+		final Map<String, MDStorePlugin> plugins = pluginEnumerator.getAll();
+
+		if ((plugins == null) || plugins.isEmpty() || !plugins.containsKey(name)) throw new MDStoreServiceException("Unable to find plugin: " + name);
+
+		log.info("running MDStore plugin: " + name);
+
+		plugins.get(name).run(getDao(), job.getParameters(), new DoneCallback() {
+
+			@Override
+			public void call(final Map<String, String> params) {
+				job.getParameters().putAll(params);
+				handler.done(job);
+			}
+		});
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,11 @@
+/**
+ *
+ */
+package eu.dnetlib.data.mdstore.modular.action;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED,
+	RUN_PLUGIN
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.action.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+				<entry key="RUN_PLUGIN">
+					<bean class="eu.dnetlib.data.mdstore.modular.action.PluginAction"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>				
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+ 	<bean id="dummyMDstorePlugin" class="eu.dnetlib.data.mdstore.modular.action.DummyPlugin" />
+	
+	<bean id="mdStorePluginEnumerator" class="eu.dnetlib.data.mdstore.modular.action.MDStorePluginEnumerator" />
+	
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+<!-- 	<bean id="mdstoreRecordParser"  -->
+<!-- 		factory-bean="recordParserFactory" factory-method="newInstance"/> -->
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePlugin.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public interface MDStorePlugin {
+
+	public void run(MDStoreDao dao, Map<String, String> params, DoneCallback doneCallback) throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.1.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.1.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.4.1,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,135 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.action.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/CreateAction.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/DummyPlugin.java	(revision 45150)
@@ -0,0 +1,23 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public class DummyPlugin implements MDStorePlugin {
+
+	private static final Log log = LogFactory.getLog(DummyPlugin.class);
+
+	@Override
+	public void run(final MDStoreDao dao, final Map<String, String> params, final DoneCallback done) {
+		log.info("Nothing to do, I'm a dummy plugin. Bye.");
+		HashMap<String, String> res = new HashMap<String, String>();
+		res.put("ret", "cheers!");
+		done.call(res);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/action/MDStorePluginEnumerator.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.action;
+
+import java.util.Map;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.ListableBeanFactory;
+
+public class MDStorePluginEnumerator implements BeanFactoryAware {
+
+	// private static final Log log = LogFactory.getLog(MDStorePluginEnumerator.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/**
+	 * bean factory.
+	 */
+	private ListableBeanFactory beanFactory;
+
+	@Override
+	public void setBeanFactory(final BeanFactory beanFactory) throws BeansException {
+		this.beanFactory = (ListableBeanFactory) beanFactory;
+	}
+
+	/**
+	 * Get all beans implementing the MDStorePlugin interface.
+	 *
+	 * @return
+	 */
+	public Map<String, MDStorePlugin> getAll() {
+		return beanFactory.getBeansOfType(MDStorePlugin.class);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(final String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(final String mdId, final boolean refresh) throws MDStoreServiceException;
+
+	void commit(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(final String mdId, final String format, final String interpretation, final String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(final String id) throws MDStoreServiceException;
+
+	int getCachedSize(final String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(final String id) throws MDStoreServiceException;
+
+	int getSumOfSizes(final String format, final String layout, final String interpretation) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,135 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,135 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	@Override
+	public int size(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getSumOfSizes(format, layout, interpretation);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-5.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(MDStoreRetriever.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+		final MDStore mdStore = dao.readMDStore(mdId);
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		try {
+			return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+				@Override
+				public Iterable<String> apply(final String mdId) {
+					log.debug("bulk deliver of mdId: " + mdId);
+					try {
+						return dao.readMDStore(mdId).iterate();
+					} catch (MDStoreServiceException e) {
+						throw new RuntimeException(e);
+					}
+				}
+			}));
+		} catch (RuntimeException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.1.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.4</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,113 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+
+			@Override
+			public String apply(final MDStoreDescription input) {
+				return input.getId();
+			}
+		}));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	@Override
+	public int size(final String mdId) throws MDStoreServiceException {
+		return this.getRetriever().getDao().getCachedSize(mdId);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	void invalidTransaction(final String transactionId, final String mdId) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,135 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String transactionId = null;
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+			transactionId = mdstore.getId();
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Throwable e) {
+			if (transactionId != null) {
+				dao.invalidTransaction(transactionId, mdId);
+			}
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.1.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.3</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+	
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.4
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,31 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+	
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.3
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,33 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+	
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.getMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.getMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.getMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.getMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+	
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.5</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,29 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,29 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,29 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.4</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.3</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-4.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.getMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.getMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			registryLocator.getService().deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,131 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, refresh);
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+		try {
+			final MDStore mdStore = dao.getMDStore(mdId);
+			return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+		} catch (MDStoreServiceException e) {
+			throw new RuntimeException(e);
+		}
+
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				try {
+					return dao.getMDStore(mdId).iterate();
+				} catch (MDStoreServiceException e) {
+					throw new RuntimeException(e);
+				}
+
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		try {
+			return dao.getMDStore(mdId).getRecord(recordId);
+		} catch (MDStoreServiceException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.5
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,64 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.getMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.getMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			registryLocator.getService().deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.4
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,118 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction
+	 *
+	 *
+	 * @param transactionId
+	 * @param mdId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract boolean commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,29 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,152 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private MDStoreTransactionManager transactionManager;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String temporaryID = "";
+		try {
+			final boolean incremental = !"REFRESH".equals(storingType);
+
+			temporaryID = transactionManager.startTransaction(mdId, !incremental);
+
+			final MDStore mdstore = dao.getMDStore(temporaryID);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (!incremental) {
+				mdstore.truncate();
+			}
+
+			mdstore.feed(records, incremental);
+
+			transactionManager.commit(temporaryID, mdId);
+
+			int size = dao.getMDStore(mdId).getSize();
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId + ", temporary id: " + temporaryID);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+					+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	/**
+	 * @return the transactionManager
+	 */
+	public MDStoreTransactionManager getTransactionManager() {
+		return transactionManager;
+	}
+
+	/**
+	 * @param transactionManager
+	 *            the transactionManager to set
+	 */
+	@Required
+	public void setTransactionManager(final MDStoreTransactionManager transactionManager) {
+		this.transactionManager = transactionManager;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,108 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+
+
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			handler.done(job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			registryLocator.getService().deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,73 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+		try {
+			final MDStore mdStore = dao.getMDStore(mdId);
+			return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+		} catch (MDStoreServiceException e) {
+			throw new RuntimeException(e);
+		}
+
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				try {
+					return dao.getMDStore(mdId).iterate();
+				} catch (MDStoreServiceException e) {
+					throw new RuntimeException(e);
+				}
+
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		try {
+			return dao.getMDStore(mdId).getRecord(recordId);
+		} catch (MDStoreServiceException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,84 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+
+		String currentId;
+		try {
+			currentId = transactionManager.readMdStore(mdId);
+			final MDStore mdStore = dao.getMDStore(currentId);
+			return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+		} catch (MDStoreServiceException e) {
+
+			return null;
+		}
+
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				try {
+					String currentId = transactionManager.readMdStore(mdId);
+					return dao.getMDStore(currentId).iterate();
+				} catch (MDStoreServiceException e) {
+					return null;
+				}
+
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		try {
+			String currentId = transactionManager.readMdStore(mdId);
+			return dao.getMDStore(currentId).getRecord(recordId);
+		} catch (MDStoreServiceException e) {
+			return null;
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.ISRegistryDocumentNotFoundException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryDocumentNotFoundException, ISRegistryException {
+		registryLocator.getService().deleteProfile(job.getParameters().get("id"));
+		String currentId = job.getParameters().get("id");
+		try {
+			transactionManager.dropMDStore(currentId);
+		} catch (MDStoreServiceException e) {
+			throw new ISRegistryException("Error deleting mdstore with id " + currentId, e);
+		}
+		getDao().deleteMDStore(currentId);
+
+		handler.done(job);
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId);
+
+	List<String> listMDStores();
+
+	List<String> listMDStores(String format, String layout, String interpretation);
+
+	void createMDStore(String mdId, String format, String interpretation, String layout);
+
+	void deleteMDStore(String id);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,110 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Creates the md store.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 * 
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction
+	 * 
+	 * 
+	 * @param transactionId
+	 * @param mdId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract boolean commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 * 
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 * 
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 * 
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 * 
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 * 
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			registryLocator.getService().deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,99 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return retriever.getDao().listMDStores();
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public abstract class AbstractMDStoreAction {
+	private MDStoreDao dao;
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	public void setDao(MDStoreDao dao) {
+		this.dao = dao;
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.3
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,77 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/**
+	 * Execute async.
+	 *
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	/**
+	 * Gets the dao.
+	 *
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 *
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,88 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+
+		String currentId;
+		try {
+			currentId = transactionManager.readMdStore(mdId);
+			final MDStore mdStore = dao.getMDStore(currentId);
+			return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+		} catch (MDStoreServiceException e) {
+
+			return null;
+		}
+
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				try {
+					String currentId = transactionManager.readMdStore(mdId);
+					return dao.getMDStore(currentId).iterate();
+				} catch (MDStoreServiceException e) {
+					return null;
+				}
+
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		try {
+			String currentId = transactionManager.readMdStore(mdId);
+			return dao.getMDStore(currentId).getRecord(recordId);
+		} catch (MDStoreServiceException e) {
+			return null;
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+	public void verifyConsistency() throws MDStoreServiceException {
+		transactionManager.verifyConsistency();
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" 
+		p:transactionManager-ref="${services.mdstore.transaction}"
+		/>
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" 
+		p:transactionManager-ref="${services.mdstore.transaction}"
+		/>
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<String> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,99 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return retriever.getDao().listMDStores();
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,57 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				handler.done(job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				handler.failed(job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+bin
+.settings
+.project
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,18 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	List<String> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FieldsExtractor.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FieldsExtractor.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FieldsExtractor.java	(revision 45150)
@@ -0,0 +1,67 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+public class FieldsExtractor {
+
+	private final DocumentBuilderFactory factory;
+	private DocumentBuilder builder;
+	private XPath xpath;
+
+	public FieldsExtractor() throws ParserConfigurationException {
+		factory = DocumentBuilderFactory.newInstance();
+		this.builder = factory.newDocumentBuilder();
+		XPathFactory xPathFactory = XPathFactory.newInstance();
+		this.xpath = xPathFactory.newXPath();
+	}
+
+	public Map<String, List<String>> getData(final String xml, final List<MDFormatDescription> mdref) {
+
+		try {
+			Document doc = builder.parse(new ByteArrayInputStream(xml.getBytes()));
+
+			Map<String, List<String>> result = Maps.newHashMap();
+			for (MDFormatDescription info : mdref) {
+				XPathExpression expression = xpath.compile(info.getXpath());
+				NodeList values = (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
+				for (int i = 0; i < values.getLength(); i++) {
+					Node currentItem = values.item(i);
+					NodeList fields = currentItem.getChildNodes();
+					if (fields != null) {
+						List<String> currentValues = Lists.newArrayList();
+						for (int k = 0; k < fields.getLength(); k++) {
+							Node field = fields.item(k);
+							while (field.hasChildNodes()) {
+								field = field.getFirstChild();
+							}
+							currentValues.add(field.getNodeValue());
+
+						}
+						result.put(info.getName(), currentValues);
+					}
+				}
+			}
+			return result;
+		} catch (Exception e) {
+			return Maps.newHashMap();
+		}
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,75 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the header.
+ *
+ * @author marko
+ *
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(final String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+							// log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+						// log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " +
+						// grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId")) { return res; }
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(final Stack<String> elementStack) {
+		if (elementStack.size() <= 3) { return ""; }
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDBStatus.java	(revision 45150)
@@ -0,0 +1,41 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreDBStatus {
+
+	private int handledDatastructures;
+	private int usedDiskSpace;
+	private String date;
+
+	public MDStoreDBStatus() {}
+
+	public MDStoreDBStatus(final int handledDatastructures, final int usedDiskSpace, final String date) {
+		this.handledDatastructures = handledDatastructures;
+		this.usedDiskSpace = usedDiskSpace;
+		this.date = date;
+	}
+
+	public int getHandledDatastructures() {
+		return handledDatastructures;
+	}
+
+	public void setHandledDatastructures(final int handledDatastructures) {
+		this.handledDatastructures = handledDatastructures;
+	}
+
+	public int getUsedDiskSpace() {
+		return usedDiskSpace;
+	}
+
+	public void setUsedDiskSpace(final int usedDiskSpace) {
+		this.usedDiskSpace = usedDiskSpace;
+	}
+
+	public String getDate() {
+		return date;
+	}
+
+	public void setDate(final String date) {
+		this.date = date;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,122 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Verify consistency.
+	 *
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void verifyConsistency() throws MDStoreServiceException;
+
+	/**
+	 * Creates the md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 *
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 *
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction.
+	 *
+	 * @param transactionId
+	 *            the transaction id
+	 * @param mdstoreId
+	 *            the mdstore id
+	 * @param currentMDStore
+	 *            the current md store
+	 * @return true, if successful
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract boolean commit(String transactionId, String mdstoreId, MDStore currentMDStore) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 *
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 *
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 *
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreUtils.java	(revision 45150)
@@ -0,0 +1,83 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException;
+import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+
+public class MDStoreUtils {
+
+	/**
+	 * service locator.
+	 */
+	@Autowired
+	private UniqueServiceLocator serviceLocator;
+
+	public List<MDFormatDescription> getField(final String format, final String layout) throws MDStoreServiceException {
+
+		String xquery = "for $x in collection('')/RESOURCE_PROFILE/BODY[CONFIGURATION/NAME='" + format + "'] return $x/STATUS/LAYOUTS/LAYOUT[@name='" + layout
+				+ "']/FIELDS";
+
+		try {
+			String result = serviceLocator.getService(ISLookUpService.class).getResourceProfileByQuery(xquery);
+			final List<MDFormatDescription> mdformat = Lists.newArrayList();
+			DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+			DocumentBuilder builder;
+			builder = factory.newDocumentBuilder();
+			Document doc = builder.parse(new ByteArrayInputStream(result.getBytes()));
+			XPathFactory xPathFactory = XPathFactory.newInstance();
+			XPath myXpath = xPathFactory.newXPath();
+			XPathExpression expression = myXpath.compile("//FIELD");
+			Object values = expression.evaluate(doc, XPathConstants.NODESET);
+			NodeList v = (NodeList) values;
+			for (int i = 0; i < v.getLength(); i++) {
+				Node currentItem = v.item(i);
+				NamedNodeMap attributes = currentItem.getAttributes();
+				String name = null;
+				String xpath = null;
+				if (attributes.getNamedItem("name") != null) {
+					name = attributes.getNamedItem("name").getNodeValue();
+				}
+				if (attributes.getNamedItem("xpath") != null) {
+					xpath = attributes.getNamedItem("xpath").getNodeValue();
+				}
+				if (attributes.getNamedItem("value") != null) {
+					xpath = attributes.getNamedItem("value").getNodeValue();
+				}
+
+				MDFormatDescription currentMdFormat = new MDFormatDescription();
+				currentMdFormat.setName(name);
+				currentMdFormat.setXpath(xpath);
+				mdformat.add(currentMdFormat);
+			}
+			return mdformat;
+
+		} catch (ISLookUpDocumentNotFoundException e1) {
+			return null;
+		} catch (ISLookUpException e1) {
+			return null;
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error on retrieving field from mdformat", e);
+		}
+
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,65 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class MDStoreRetriever {
+
+    private MDStoreDao dao;
+
+    private ResultSetFactory resultSetFactory;
+
+    public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) throws MDStoreServiceException {
+        final MDStore mdStore = dao.readMDStore(mdId);
+        return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+    }
+
+    public Iterable<String> deliver(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+        try {
+            return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+                @Override
+                public Iterable<String> apply(final String mdId) {
+                    try {
+                        return dao.readMDStore(mdId).iterate();
+                    } catch (MDStoreServiceException e) {
+                        throw new RuntimeException(e);
+                    }
+                }
+            }));
+        } catch (RuntimeException e) {
+            throw new MDStoreServiceException(e);
+        }
+    }
+
+    public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+        return dao.getMDStore(mdId).getRecord(recordId);
+    }
+
+    public MDStoreDao getDao() {
+        return dao;
+    }
+
+    @Required
+    public void setDao(final MDStoreDao dao) {
+        this.dao = dao;
+    }
+
+    @Required
+    public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+        this.resultSetFactory = resultSetFactory;
+    }
+
+    public ResultSetFactory getResultSetFactory() {
+        return resultSetFactory;
+    }
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		try {
+			String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+			transactionManager.createMDStore(mdId);
+
+			getDao().createMDStore(mdId, format, interpretation, layout);
+
+			job.getParameters().put("id", mdId);
+
+			completeWithSuccess(handler, job);
+		} catch (ISRegistryException e) {
+			throw new MDStoreServiceException(e);
+		}
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * service locator.
+	 */
+	private UniqueServiceLocator serviceLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return serviceLocator.getService(ISRegistryService.class).registerProfile(template.toString());
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedFailedCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedFailedCallback {
+
+	void call(Throwable e);
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedDoneCallback.java	(revision 45150)
@@ -0,0 +1,6 @@
+package eu.dnetlib.data.mdstore.modular;
+
+public interface FeedDoneCallback {
+
+	void call(int size);
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+		
+	<bean id="mdStoreUtils" class="eu.dnetlib.data.mdstore.modular.MDStoreUtils"/>
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:serviceLocator-ref="uniqueServiceLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:serviceLocator-ref="uniqueServiceLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:serviceLocator-ref="uniqueServiceLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+		
+	<bean id="fieldExtractor" class="eu.dnetlib.data.mdstore.modular.FieldsExtractor"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st	(revision 45150)
@@ -0,0 +1,5 @@
+<STATUS>
+	<HANDLED_DATASTRUCTURE>$status.handledDatastructures$</HANDLED_DATASTRUCTURE>
+	<USED_DISKSPACE>$status.usedDiskSpace$</USED_DISKSPACE>
+	<LAST_UPDATE value="$status.date$"/>
+</STATUS>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			registryLocator.getService().deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			handler.done(job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/pom.xml	(revision 45150)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+		<relativePath></relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>3.0.0-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0-SNAPSHOT,1.1.0-SNAPSHOT)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0-SNAPSHOT,1.1.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0-SNAPSHOT,1.1.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0-SNAPSHOT,1.1.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0-SNAPSHOT,1.1.0-SNAPSHOT)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,110 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public void start() {
+		try {
+			retriever.getDao().listMDStores();
+			retriever.verifyConsistency();
+		} catch (MDStoreServiceException e) {
+
+		}
+		super.start();
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return retriever.getDao().listMDStores();
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.modular.MDFormatDescription;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	void feed(Iterable<String> records, boolean incremental);
+
+	void feed(Iterable<String> records, boolean incremental, List<MDFormatDescription> mdformats);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,84 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+
+		String currentId;
+		try {
+			currentId = transactionManager.readMdStore(mdId);
+			final MDStore mdStore = dao.getMDStore(currentId);
+			return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+		} catch (MDStoreServiceException e) {
+
+			return null;
+		}
+
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				try {
+					String currentId = transactionManager.readMdStore(mdId);
+					return dao.getMDStore(currentId).iterate();
+				} catch (MDStoreServiceException e) {
+					return null;
+				}
+
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		try {
+			String currentId = transactionManager.readMdStore(mdId);
+			return dao.getMDStore(currentId).getRecord(recordId);
+		} catch (MDStoreServiceException e) {
+			return null;
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionInfo.java	(revision 45150)
@@ -0,0 +1,72 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreTransactionInfo {
+
+	private String id;
+	private Boolean refresh;
+	private Date date;
+	private long size;
+
+	/**
+	 * @return the date
+	 */
+	public Date getDate() {
+		return date;
+	}
+
+	/**
+	 * @param date
+	 *            the date to set
+	 */
+	public void setDate(final Date date) {
+		this.date = date;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the refresh
+	 */
+	public Boolean getRefresh() {
+		return refresh;
+	}
+
+	/**
+	 * @param refresh
+	 *            the refresh to set
+	 */
+	public void setRefresh(final Boolean refresh) {
+		this.refresh = refresh;
+	}
+
+	/**
+	 * @return the size
+	 */
+	public long getSize() {
+		return size;
+	}
+
+	/**
+	 * @param size
+	 *            the size to set
+	 */
+	public void setSize(final long size) {
+		this.size = size;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Callable;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private MDStoreFeeder feeder;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
+
+		final String mdId = job.getParameters().get("mdId");
+		if ((mdId == null) || mdId.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		final String epr = job.getParameters().get("epr");
+		if ((epr == null) || epr.isEmpty()) throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+
+		String storingType = job.getParameters().get("storingType");
+		if ((storingType == null) || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		feeder.feed(mdId, epr, storingType, true, new Callable<Object>() {
+
+			@Override
+			public Object call() {
+				job.getParameters().put("total", "" + getDao().getMDStore(mdId).getSize());
+				handler.done(job);
+				return null;
+			}
+		}, new Callable<Object>() {
+
+			@Override
+			public Object call() {
+				handler.failed(job, new Exception("Error during feeding of " + mdId));
+				return null;
+			}
+		});
+
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDFormatDescription.java	(revision 45150)
@@ -0,0 +1,53 @@
+package eu.dnetlib.data.mdstore.modular;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class MDFormatDescription.
+ */
+public class MDFormatDescription {
+
+	/** The name. */
+	private String name;
+
+	/** The xpath. */
+	private String xpath;
+
+	/**
+	 * Gets the name.
+	 *
+	 * @return the name
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Sets the name.
+	 *
+	 * @param name
+	 *            the name to set
+	 */
+	public void setName(final String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Gets the xpath.
+	 *
+	 * @return the xpath
+	 */
+	public String getXpath() {
+		return xpath;
+	}
+
+	/**
+	 * Sets the xpath.
+	 *
+	 * @param xpath
+	 *            the xpath to set
+	 */
+	public void setXpath(final String xpath) {
+		this.xpath = xpath;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,125 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+import javax.annotation.Resource;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.core.io.ClassPathResource;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+/**
+ * The Class AbstractMDStoreAction.
+ */
+public abstract class AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Resource
+	private UniqueServiceLocator serviceLocator;
+
+	/** The dao. */
+	private MDStoreDao dao;
+
+	/** The executor. */
+	private final Executor executor = Executors.newCachedThreadPool();
+
+	/** Logger */
+	private static final Log log = LogFactory.getLog(AbstractMDStoreAction.class);
+
+	private static final ClassPathResource mdstoreServiceStatusTemplate = new ClassPathResource(
+			"/eu/dnetlib/data/mdstore/modular/mdstoreServiceStatusTemplate.xml.st");
+
+	/**
+	 * Execute async.
+	 * 
+	 * @param handler
+	 *            the handler
+	 * @param job
+	 *            the job
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	protected abstract void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction#execute(eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler,
+	 * eu.dnetlib.enabling.tools.blackboard.BlackboardJob)
+	 */
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) {
+		executor.execute(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					handler.ongoing(job);
+					executeAsync(handler, job);
+				} catch (MDStoreServiceException e) {
+					handler.failed(job, e);
+				}
+			}
+		});
+	}
+
+	protected void completeWithSuccess(final BlackboardServerHandler handler, final BlackboardJob job) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.done(job);
+		}
+	}
+
+	protected void completeWithFail(final BlackboardServerHandler handler, final BlackboardJob job, final Throwable e) {
+		// Don't change this synchronization rule
+		synchronized (this) {
+			updateMDStoreServiceProfile(job);
+			handler.failed(job, e);
+		}
+	}
+
+	private void updateMDStoreServiceProfile(final BlackboardJob job) {
+		final String id = job.getServiceId();
+
+		log.info("Updating mdstore service profile status, id: " + id);
+		try {
+			final StringTemplate st = new StringTemplate(IOUtils.toString(mdstoreServiceStatusTemplate.getInputStream()));
+			st.setAttribute("status", dao.getDBStatus());
+			serviceLocator.getService(ISRegistryService.class).updateProfileNode(id, "//STATUS", st.toString());
+		} catch (Exception e) {
+			log.error("Error upadating profile " + id, e);
+		}
+	}
+
+	/**
+	 * Gets the dao.
+	 * 
+	 * @return the dao
+	 */
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	/**
+	 * Sets the dao.
+	 * 
+	 * @param dao
+	 *            the new dao
+	 */
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,106 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws MDStoreServiceException, DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() throws MDStoreServiceException {
+		return (Lists.transform(retriever.getDao().listMDStores(), new Function<MDStoreDescription, String>() {
+            @Override
+            public String apply(MDStoreDescription input) {
+                return input.getId();
+            }
+        }));
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) throws MDStoreServiceException {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsId, final String storingType) throws MDStoreServiceException {
+		throw new MDStoreServiceException("not implemented, use the Blackboard asynchronous equivalent");
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" 
+		p:transactionManager-ref="${services.mdstore.transaction}"
+		/>
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStore.java	(revision 45150)
@@ -0,0 +1,32 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+public interface MDStore {
+
+	String getId();
+
+	String getFormat();
+
+	String getInterpretation();
+
+	String getLayout();
+
+	void truncate();
+
+	int feed(Iterable<String> records, boolean incremental);
+
+	ResultSetListener deliver(String from, String until, String recordFilter);
+
+	ResultSetListener deliverIds(String from, String until, String recordFilter);
+
+	Iterable<String> iterate();
+
+	int getSize();
+
+	void deleteRecord(String recordId);
+
+	String getRecord(String recordId) throws DocumentNotFoundException;
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,180 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Callable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private MDStoreTransactionManager transactionManager;
+
+	private boolean syncFeed = true;
+
+	static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	public void feed(final String mdId, final String rsEpr, final String storingType) {
+		feed(mdId, rsEpr, storingType, syncFeed, null, null);
+	}
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final Callable<?> callback,
+			final Callable<?> failCallback) {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		final Thread feederThread = new Thread(new Runnable() {
+
+			@Override
+			public void run() {
+				try {
+					final boolean incremental = !"REFRESH".equals(storingType);
+
+					String temporaryID = transactionManager.startTransaction(mdId, !incremental);
+
+					final MDStore mdstore = dao.getMDStore(temporaryID);
+
+					final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+					if (!incremental) {
+						mdstore.truncate();
+					}
+
+					final int size = mdstore.feed(records, incremental);
+
+					transactionManager.commit(temporaryID, mdId);
+
+					touch(mdId, size);
+
+					log.info("Stop feeding mdstore " + mdId + " - new size: " + size);
+
+					if (callback != null) {
+						try {
+							callback.call();
+						} catch (Exception e) {
+							log.error("Error executing callback", e);
+						}
+					}
+				} catch (Throwable e) {
+					log.error("Error in feeding thread", e);
+					if (failCallback != null) {
+						try {
+							failCallback.call();
+						} catch (Exception e1) {
+							log.error("Error executing failCallback", e);
+						}
+					}
+				}
+			}
+		});
+
+		feederThread.start();
+
+		if (sync) {
+			try {
+				feederThread.join();
+			} catch (InterruptedException e) {
+				throw new IllegalStateException(e);
+			}
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 * 
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	/**
+	 * @return the transactionManager
+	 */
+	public MDStoreTransactionManager getTransactionManager() {
+		return transactionManager;
+	}
+
+	/**
+	 * @param transactionManager
+	 *            the transactionManager to set
+	 */
+	@Required
+	public void setTransactionManager(final MDStoreTransactionManager transactionManager) {
+		this.transactionManager = transactionManager;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.ISRegistryDocumentNotFoundException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryDocumentNotFoundException, ISRegistryException {
+		registryLocator.getService().deleteProfile(job.getParameters().get("id"));
+
+		getDao().deleteMDStore(job.getParameters().get("id"));
+
+		handler.done(job);
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreExpiredInfo.java	(revision 45150)
@@ -0,0 +1,39 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.Date;
+
+public class MDStoreExpiredInfo {
+
+	private String id;
+	private Date lastRead;
+
+	/**
+	 * @return the lastRead
+	 */
+	public Date getLastRead() {
+		return lastRead;
+	}
+
+	/**
+	 * @param lastRead
+	 *            the lastRead to set
+	 */
+	public void setLastRead(final Date lastRead) {
+		this.lastRead = lastRead;
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id
+	 *            the id to set
+	 */
+	public void setId(final String id) {
+		this.id = id;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,46 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.ISRegistryDocumentNotFoundException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryDocumentNotFoundException, ISRegistryException {
+		registryLocator.getService().deleteProfile(job.getParameters().get("id"));
+		String currentId = job.getParameters().get("id");
+		try {
+			transactionManager.dropMDStore(currentId);
+		} catch (MDStoreServiceException e) {
+			throw new ISRegistryException("Error deleting mdstore with id " + currentId, e);
+		}
+		getDao().deleteMDStore(currentId);
+
+		handler.done(job);
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/SimpleRecordParser.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+/**
+ * Terrible implementation of a record parser.
+ * 
+ * @author marko
+ *
+ */
+public class SimpleRecordParser implements RecordParser {
+	static final Log log = LogFactory.getLog(SimpleRecordParser.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+		Map<String, String> props = new HashMap<String, String>();
+
+		try {
+//			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			XPath xpath = XPathFactory.newInstance().newXPath();
+
+//			Document doc = builder.parse(new InputSource(new StringReader(record)));
+			InputSource doc = new InputSource(new StringReader(record));
+			
+			props.put("id", xpath.evaluate("//*[local-name()='objIdentifier']", doc));
+			props.put("originalId", xpath.evaluate("//*[local-name()='efgEntity']/*/*[local-name()='identifier']", doc));
+			
+//			String date = xpath.evaluate("//*[local-name()='dateOfCollection'][1]", doc);
+//			props.put("date", new Date(date).getTime());	
+				
+		} catch (Exception e) {
+			log.warn("got exception while parsing document", e);
+			log.warn("record is:");
+			log.warn(record);
+			log.warn("------------");
+		}
+		return props;
+
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,100 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() {
+		return retriever.getDao().listMDStores();
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsEpr, final String storingType) {
+		feeder.feed(mdId, rsEpr, storingType);
+		return true;
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/BulkRecordMapperFactory.java	(revision 45150)
@@ -0,0 +1,133 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.events.Namespace;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class BulkRecordMapperFactory implements Factory<Function<String, Pair<String, String>>> {
+	
+	private static final Log log = LogFactory.getLog(BulkRecordMapperFactory.class); // NOPMD by marko on 11/24/08 5:02 PM
+	
+	protected static final String MD_RECORD = "mdRecord";
+	
+	protected static final String MD_ID = "mdId";
+	
+	protected static final String RECORD = "record";
+
+	protected ThreadLocal<XMLInputFactory> inputFactory = new ThreadLocal<XMLInputFactory>() {
+		@Override
+		protected XMLInputFactory initialValue() {
+			return XMLInputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLOutputFactory> outputFactory = new ThreadLocal<XMLOutputFactory>() {
+		@Override
+		protected XMLOutputFactory initialValue() {
+			return XMLOutputFactory.newInstance();
+		}
+	};
+
+	protected ThreadLocal<XMLEventFactory> eventFactory = new ThreadLocal<XMLEventFactory>() {
+		@Override
+		protected XMLEventFactory initialValue() {
+			return XMLEventFactory.newInstance();
+		}
+	};
+	
+	@Override
+	public Function<String, Pair<String, String>> newInstance() {
+		return new Function<String, Pair<String, String>>() {
+			private String mdId = null;
+			private String record = null;
+			@Override
+			public Pair<String, String> apply(String embeddedRecord) {
+				try {
+					final XMLEventReader parser = inputFactory.get().createXMLEventReader(new StringReader(embeddedRecord));
+
+					while (parser.hasNext()) {
+						final XMLEvent event = parser.nextEvent();
+						if (event != null && event.isStartElement()) {
+							final String localName = event.asStartElement().getName().getLocalPart();
+
+							if (MD_RECORD.equals(localName)) {
+								mdId = event.asStartElement().getAttributeByName(new QName(MD_ID)).getValue();
+
+							} else if (RECORD.equals(localName)) {
+								record = getRecord(embeddedRecord, parser);
+							} 
+						}
+					}
+				} catch (final XMLStreamException e) {
+					log.error("error parsing record: " + embeddedRecord);
+				}				
+				return new Pair<String, String>(mdId, record);
+			}
+		};
+	}
+	
+	/**
+	 * Copy the /indexRecord/result element and children, preserving namespace declarations etc.
+	 * 
+	 * @param indexDocument
+	 * @param results
+	 * @param parser
+	 * @throws XMLStreamException
+	 */
+	protected String getRecord(final String record, final XMLEventReader parser) throws XMLStreamException {
+		StringWriter results = new StringWriter();
+		final XMLEventWriter writer = outputFactory.get().createXMLEventWriter(results);
+
+		// TODO: newRecord should copy all the namespace prefixes setup in parents
+		// fortunately the only parent of the result element is the 'indexrecord', so it should be easy to get
+		// the namespaces declared on the root element (and fast)
+
+		final List<Namespace> namespaces = Lists.newArrayList(
+				eventFactory.get().createNamespace("dri", "http://www.driver-repository.eu/namespace/dri"),
+				eventFactory.get().createNamespace("dr", "http://www.driver-repository.eu/namespace/dr"),
+				eventFactory.get().createNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"),
+				eventFactory.get().createNamespace("dc", "http://purl.org/dc/elements/1.1/"));
+
+		StartElement newRecord = eventFactory.get().createStartElement("", null, RECORD, null, namespaces.iterator());
+
+		// new root record
+		writer.add(newRecord);
+
+		// copy the rest as it is
+		while (parser.hasNext()) {
+			final XMLEvent resultEvent = parser.nextEvent();
+
+			// TODO: replace with depth tracking instead of close tag tracking. 
+			if (resultEvent.isEndElement() && resultEvent.asEndElement().getName().getLocalPart().equals(RECORD)) {
+				writer.add(resultEvent);
+				break;
+			}
+
+			writer.add(resultEvent);
+		}
+		writer.close();
+
+		return results.toString();
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+bin
+.settings
+.project
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/ModularMDStoreService.java	(revision 45150)
@@ -0,0 +1,100 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.MDStoreService;
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.resultset.IterableResultSetFactory;
+import eu.dnetlib.enabling.tools.AbstractBaseService;
+import eu.dnetlib.enabling.tools.blackboard.NotificationHandler;
+
+public class ModularMDStoreService extends AbstractBaseService implements MDStoreService {
+
+	/**
+	 * notification handler.
+	 */
+	private NotificationHandler notificationHandler;
+
+	private MDStoreFeeder feeder;
+
+	private MDStoreRetriever retriever;
+
+	private IterableResultSetFactory iterableResultSetFactory;
+
+	@Override
+	public W3CEndpointReference deliverMDRecords(final String mdId, final String from, final String until, final String recordFilter)
+			throws MDStoreServiceException {
+		return retriever.deliver(mdId, from, until, recordFilter);
+	}
+
+	@Override
+	public W3CEndpointReference bulkDeliverMDRecords(final String format, final String layout, final String interpretation) {
+		return getIterableResultSetFactory().createIterableResultSet(retriever.deliver(format, layout, interpretation));
+	}
+
+	@Override
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return retriever.deliverRecord(mdId, recordId);
+	}
+
+	@Override
+	public List<String> getListOfMDStores() {
+		return retriever.getDao().listMDStores();
+	}
+
+	@Override
+	public List<String> listMDStores(final String format, final String layout, final String interpretation) {
+		return retriever.getDao().listMDStores(format, layout, interpretation);
+	}
+
+	@Override
+	public boolean storeMDRecordsFromRS(final String mdId, final String rsEpr, final String storingType) {
+		feeder.feed(mdId, rsEpr, storingType);
+		return true;
+	}
+
+	@Override
+	public void notify(final String subscriptionId, final String topic, final String isId, final String message) {
+		getNotificationHandler().notified(subscriptionId, topic, isId, message);
+	}
+
+	public NotificationHandler getNotificationHandler() {
+		return notificationHandler;
+	}
+
+	@Required
+	public void setNotificationHandler(final NotificationHandler notificationHandler) {
+		this.notificationHandler = notificationHandler;
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+	public MDStoreRetriever getRetriever() {
+		return retriever;
+	}
+
+	public void setRetriever(final MDStoreRetriever retriever) {
+		this.retriever = retriever;
+	}
+
+	public IterableResultSetFactory getIterableResultSetFactory() {
+		return iterableResultSetFactory;
+	}
+
+	@Required
+	public void setIterableResultSetFactory(final IterableResultSetFactory iterableResultSetFactory) {
+		this.iterableResultSetFactory = iterableResultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		final String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+		try {
+			transactionManager.createMDStore(mdId);
+		} catch (MDStoreServiceException e) {
+			throw new ISRegistryException("Error on create mdStore", e);
+		}
+		getDao().createMDStore(mdId, format, interpretation, layout);
+
+		job.getParameters().put("id", mdId);
+
+		handler.done(job);
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,6 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,15 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+public interface MDStoreDao {
+	MDStore getMDStore(String mdId);
+
+	List<String> listMDStores();
+	
+	List<String> listMDStores(String format, String layout, String interpretation);
+
+	void createMDStore(String mdId, String format, String interpretation, String layout);
+
+	void deleteMDStore(String id);
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,60 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Callable;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private MDStoreFeeder feeder;
+	
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws Exception {
+			
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) {
+			throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+		}
+		
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) {
+			throw new MDStoreServiceException("Blackboard param (mdId) is empty");
+		}
+		
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+		
+		feeder.feed(mdId, epr, storingType, true, new Callable<Object>() {
+			@Override
+			public Object call() {
+				job.getParameters().put("total", "" + getDao().getMDStore(mdId).getSize());
+				handler.done(job);
+				return null;
+			}
+		}, new Callable<Object>() {
+			@Override
+			public Object call() {
+				handler.failed(job, new Exception("Error during feeding of " + mdId));
+				return null;
+			}
+		});
+		
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,150 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private MDStoreTransactionManager transactionManager;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		String temporaryID = "";
+		try {
+			final boolean incremental = !"REFRESH".equals(storingType);
+
+			temporaryID = transactionManager.startTransaction(mdId, !incremental);
+
+			final MDStore mdstore = dao.getMDStore(temporaryID);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (!incremental) {
+				mdstore.truncate();
+			}
+
+			final int size = mdstore.feed(records, incremental);
+
+			transactionManager.commit(temporaryID, mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId + ", temporary id: " + temporaryID);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 * 
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//LAST_STORAGE_DATE with '" + now
+							+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate =
+					"for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']" + "return update value $x//NUMBER_OF_RECORDS with '" + size
+							+ "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	/**
+	 * @return the transactionManager
+	 */
+	public MDStoreTransactionManager getTransactionManager() {
+		return transactionManager;
+	}
+
+	/**
+	 * @param transactionManager
+	 *            the transactionManager to set
+	 */
+	@Required
+	public void setTransactionManager(final MDStoreTransactionManager transactionManager) {
+		this.transactionManager = transactionManager;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParser.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.Map;
+
+/**
+ * Parses a mdrecord and extracts the minimum information (like id, date etc) which is necessary for the mdstoring
+ * process.
+ * 
+ * @author marko
+ * 
+ */
+public interface RecordParser {
+
+	public Map<String, String> parseRecord(String record);
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml	(revision 45150)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<RESOURCE_PROFILE>
+	<HEADER>
+		<RESOURCE_IDENTIFIER value="" />
+		<RESOURCE_TYPE value="MDStoreDSResourceType" />
+		<RESOURCE_KIND value="MDStoreDSResources" />
+		<RESOURCE_URI value="$serviceUri$?wsdl" />
+		<DATE_OF_CREATION value="" />
+	</HEADER>
+	<BODY>
+		<CONFIGURATION>
+			<METADATA_FORMAT>$format$</METADATA_FORMAT>
+			<METADATA_FORMAT_INTERPRETATION>$interpretation$
+			</METADATA_FORMAT_INTERPRETATION>
+			<METADATA_FORMAT_LAYOUT>$layout$</METADATA_FORMAT_LAYOUT>
+		</CONFIGURATION>
+		<STATUS>
+			<PENULTIMATE_STORAGE_DATE></PENULTIMATE_STORAGE_DATE>
+			<LAST_STORAGE_DATE></LAST_STORAGE_DATE>
+			<NUMBER_OF_RECORDS>0</NUMBER_OF_RECORDS>
+			<FETCHING_FREQUENCY />
+			<STATISTICS_FIELDS />
+		</STATUS>
+		<SECURITY_PARAMETERS />
+	</BODY>
+</RESOURCE_PROFILE>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreProfileCreator.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.Endpoint;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.soap.EndpointReferenceBuilder;
+
+public class MDStoreProfileCreator {
+	/**
+	 * registry service locator.
+	 */
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	/**
+	 * mdstore ds template.
+	 */
+	private StringTemplate mdstoreDsTemplate;
+
+	/**
+	 * service endpoint.
+	 */
+	private Endpoint endpoint;
+
+	/**
+	 * endpoint builder.
+	 */
+	private EndpointReferenceBuilder<Endpoint> eprBuilder;
+
+	public String registerProfile(String format, String interpretation, String layout) throws ISRegistryException {
+		// XXX: mini hack
+		StringTemplate template = new StringTemplate(mdstoreDsTemplate.getTemplate());
+		template.setAttribute("serviceUri", eprBuilder.getAddress(endpoint));
+		template.setAttribute("format", format);
+		template.setAttribute("interpretation", interpretation);
+		template.setAttribute("layout", layout);
+
+		return registryLocator.getService().registerProfile(template.toString());
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public StringTemplate getMdstoreDsTemplate() {
+		return mdstoreDsTemplate;
+	}
+
+	@Required
+	public void setMdstoreDsTemplate(StringTemplate mdstoreDsTemplate) {
+		this.mdstoreDsTemplate = mdstoreDsTemplate;
+	}
+
+	public Endpoint getEndpoint() {
+		return endpoint;
+	}
+
+	@Required
+	public void setEndpoint(Endpoint endpoint) {
+		this.endpoint = endpoint;
+	}
+
+	public EndpointReferenceBuilder<Endpoint> getEprBuilder() {
+		return eprBuilder;
+	}
+
+	@Required
+	public void setEprBuilder(EndpointReferenceBuilder<Endpoint> eprBuilder) {
+		this.eprBuilder = eprBuilder;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/pom.xml	(revision 45150)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0-SNAPSHOT</version>
+		<relativePath></relativePath>
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>2.0.0-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0-SNAPSHOT]</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[1.0.0-SNAPSHOT]</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0-SNAPSHOT]</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[1.0.0-SNAPSHOT]</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[1.0.0-SNAPSHOT]</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/resources/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest-context.xml	(revision 45150)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
+
+	<bean id="blackboardHandler" class="eu.dnetlib.test.utils.MockBeanFactory"
+		p:clazz="eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler" />
+
+	<bean id="executor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler" p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="true">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.enabling.tools.blackboard.SampleCreateAction" />
+				</entry>
+			</map>
+		</property>
+
+	</bean>
+</beans>
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0
===================================================================
--- modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/tags/cnr-modular-mdstore-service-3.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+bin
+.settings
+.project
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreResults.java	(revision 45150)
@@ -0,0 +1,28 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+public class MDStoreResults {
+	private Iterable<String> records;
+	private int size;
+
+	public MDStoreResults(Iterable<String> records, int size) {
+		super();
+		this.records = records;
+		this.size = size;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(int size) {
+		this.size = size;
+	}
+
+	public Iterable<String> getRecords() {
+		return records;
+	}
+
+	public void setRecords(Iterable<String> records) {
+		this.records = records;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,38 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private MDStoreProfileCreator profileCreator;
+	
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryException {		
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+		
+		final String mdId = profileCreator.registerProfile(format, interpretation, layout);
+		
+		getDao().createMDStore(mdId, format, interpretation, layout);
+		
+		job.getParameters().put("id", mdId);
+		
+		handler.done(job);
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/MDStoreUtilTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/MDStoreUtilTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/test/java/eu/dnetlib/enabling/tools/blackboard/MDStoreUtilTest.java	(revision 45150)
@@ -0,0 +1,50 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import java.io.ByteArrayInputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class MDStoreUtilTest {
+
+	@Test
+	public void test() throws Exception {
+
+		String result = "<FIELDS> <FIELD indexable=\"false\" name=\"doi\" result=\"false\" stat=\"true\" xpath=\"//*[local-name()='resource']/*[local-name()='identifier' and ./@identifierType='DOI']\"/> </FIELDS>";
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder builder;
+		builder = factory.newDocumentBuilder();
+		Document doc = builder.parse(new ByteArrayInputStream(result.getBytes()));
+		XPathFactory xPathFactory = XPathFactory.newInstance();
+		XPath myXpath = xPathFactory.newXPath();
+		XPathExpression expression = myXpath.compile("//FIELD");
+		Object values = expression.evaluate(doc, XPathConstants.NODESET);
+		NodeList v = (NodeList) values;
+		for (int i = 0; i < v.getLength(); i++) {
+			Node currentItem = v.item(i);
+			NamedNodeMap attributes = currentItem.getAttributes();
+			String name = null;
+			String xpath = null;
+			if (attributes.getNamedItem("name") != null) {
+				name = attributes.getNamedItem("name").getNodeValue();
+			}
+			if (attributes.getNamedItem("xpath") != null) {
+				xpath = attributes.getNamedItem("xpath").getNodeValue();
+			}
+			if (attributes.getNamedItem("value") != null) {
+				xpath = attributes.getNamedItem("value").getNodeValue();
+			}
+		}
+
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/FeedAction.java	(revision 45150)
@@ -0,0 +1,74 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class FeedAction extends AbstractMDStoreAction {
+
+	private static final Log log = LogFactory.getLog(FeedAction.class);
+
+	private MDStoreFeeder feeder;
+
+	@Autowired
+	private MDStoreUtils mdstoreUtils;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+
+		final String mdId = job.getParameters().get("mdId");
+		if (mdId == null || mdId.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		final String epr = job.getParameters().get("epr");
+		if (epr == null || epr.isEmpty()) { throw new MDStoreServiceException("Blackboard param (mdId) is empty"); }
+
+		String storingType = job.getParameters().get("storingType");
+		if (storingType == null || storingType.isEmpty()) {
+			storingType = "REFRESH";
+		}
+
+		final String layoutIndex = job.getParameters().get("layoutIndex");
+		String format = feeder.getDao().getMDStore(mdId).getFormat();
+
+		List<MDFormatDescription> mdformats = mdstoreUtils.getField(format, layoutIndex);
+		if (mdformats != null) {
+			for (MDFormatDescription desc : mdformats) {
+				log.info("name: " + desc.getName());
+				log.info("xpath: " + desc.getXpath());
+			}
+		}
+
+		feeder.feed(mdId, epr, storingType, true, mdformats, new FeedDoneCallback() {
+
+			@Override
+			public void call(final int size) {
+				job.getParameters().put("total", "" + size);
+				completeWithSuccess(handler, job);
+			}
+		}, new FeedFailedCallback() {
+
+			@Override
+			public void call(final Throwable e) {
+				log.error("Error feeding mdstore: " + mdId, e);
+				completeWithFail(handler, job, e);
+			}
+		});
+	}
+
+	public MDStoreFeeder getFeeder() {
+		return feeder;
+	}
+
+	@Required
+	public void setFeeder(final MDStoreFeeder feeder) {
+		this.feeder = feeder;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreActions.java	(revision 45150)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package eu.dnetlib.data.mdstore.modular;
+
+public enum MDStoreActions {
+	CREATE,
+	DELETE,
+	FEED
+}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,35 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.MDStoreDescription;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore readMDStore(String mdId) throws MDStoreServiceException;
+
+	MDStore startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	void commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	List<MDStoreDescription> listMDStores() throws MDStoreServiceException;
+
+	List<String> listMDStores(String format, String layout, String interpretation) throws MDStoreServiceException;
+
+	void createMDStore(String mdId, String format, String interpretation, String layout) throws MDStoreServiceException;
+
+	void deleteMDStore(String id) throws MDStoreServiceException;
+
+	int getCachedSize(String id) throws MDStoreServiceException;
+
+	void refreshSizes() throws MDStoreServiceException;
+
+	int refreshSize(String id) throws MDStoreServiceException;
+
+	void startGarbage() throws MDStoreServiceException;
+
+	MDStoreDBStatus getDBStatus();
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/SampleCreateAction.java	(revision 45150)
@@ -0,0 +1,12 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+public class SampleCreateAction implements BlackboardServerAction<MDStoreActions> {
+
+	@Override
+	public void execute(BlackboardServerHandler handler, BlackboardJob job) {
+		handler.done(job);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreManagerInfo.java	(revision 45150)
@@ -0,0 +1,59 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MDStoreManagerInfo {
+
+	private String mdId;
+	private String currentId;
+	private List<MDStoreExpiredInfo> stillUsed;
+	private List<MDStoreTransactionInfo> transactions;
+
+	public String getMdId() {
+		return mdId;
+	}
+
+	public void setMdId(final String mdId) {
+		this.mdId = mdId;
+	}
+
+	public String getCurrentId() {
+		return currentId;
+	}
+
+	public void setCurrentId(final String currentId) {
+		this.currentId = currentId;
+	}
+
+	public List<MDStoreExpiredInfo> getStillUsed() {
+		return stillUsed;
+	}
+
+	public void setStillUsed(final List<MDStoreExpiredInfo> stillUsed) {
+		this.stillUsed = stillUsed;
+	}
+
+	public List<MDStoreTransactionInfo> getTransactions() {
+		return transactions;
+	}
+
+	public void setTransactions(final List<MDStoreTransactionInfo> transactions) {
+		this.transactions = transactions;
+	}
+
+	public void addExpiredItem(final MDStoreExpiredInfo info) {
+		if (stillUsed == null) {
+			stillUsed = new ArrayList<MDStoreExpiredInfo>();
+		}
+		stillUsed.add(info);
+	}
+
+	public void addTransactionInfo(final MDStoreTransactionInfo info) {
+		if (transactions == null) {
+			transactions = new ArrayList<MDStoreTransactionInfo>();
+		}
+		transactions.add(info);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/deploy.info
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/deploy.info	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/deploy.info	(revision 45150)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk/", "deploy_repository": "dnet4-snapshots", "version": "4", "mail": "sandro.labruzzo@isti.cnr.it,michele.artini@isti.cnr.it, claudio.atzori@isti.cnr.it, alessia.bardi@isti.cnr.it", "deploy_repository_url": "http://maven.research-infrastructures.eu/nexus/content/repositories/dnet4-snapshots", "name": "cnr-modular-mdstore-service"}
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,136 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+
+	private static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private UniqueServiceLocator serviceLocator;
+
+	private boolean syncFeed = true;
+
+	public void feed(final String mdId,
+			final String rsEpr,
+			final String storingType,
+			final boolean sync,
+			final List<MDFormatDescription> mdformats,
+			final FeedDoneCallback doneCallback,
+			final FeedFailedCallback failCallback) throws MDStoreServiceException {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+
+		try {
+			final boolean refresh = "REFRESH".equals(storingType);
+
+			final MDStore mdstore = dao.startTransaction(mdId, refresh);
+
+			final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+
+			if (refresh) {
+				mdstore.truncate();
+			}
+
+			if (mdformats == null) {
+				mdstore.feed(records, refresh);
+			} else {
+				mdstore.feed(records, refresh, mdformats);
+			}
+
+			dao.commit(mdstore.getId(), mdId);
+
+			int size = dao.refreshSize(mdId);
+
+			touch(mdId, size);
+
+			log.info("Finished feeding mdstore " + mdId + " - new size: " + size);
+
+			doneCallback.call(size);
+		} catch (Exception e) {
+			log.error("Error feeding mdstore: " + mdId);
+			failCallback.call(e);
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 *
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			serviceLocator.getService(ISRegistryService.class).executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(final boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/DeleteAction.java	(revision 45150)
@@ -0,0 +1,45 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class DeleteAction extends AbstractMDStoreAction {
+
+	private UniqueServiceLocator serviceLocator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void executeAsync(final BlackboardServerHandler handler, final BlackboardJob job) throws MDStoreServiceException {
+		final String currentId = job.getParameters().get("id");
+		try {
+			serviceLocator.getService(ISRegistryService.class).deleteProfile(currentId);
+
+			transactionManager.dropMDStore(currentId);
+
+			getDao().deleteMDStore(currentId);
+
+			completeWithSuccess(handler, job);
+		} catch (Exception e) {
+			throw new MDStoreServiceException("Error deleting mdstore with id " + currentId, e);
+		}
+	}
+
+	public UniqueServiceLocator getServiceLocator() {
+		return serviceLocator;
+	}
+
+	@Required
+	public void setServiceLocator(final UniqueServiceLocator serviceLocator) {
+		this.serviceLocator = serviceLocator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreDescription.java	(revision 45150)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.mdstore.modular;
+
+
+public class MDStoreDescription {
+
+	private String id;
+
+	private String format;
+
+	private String layout;
+
+	private String interpretation;
+
+	private int size;
+
+	private boolean indexed;
+
+	public MDStoreDescription(final String id, final String format, final String layout, final String interpretation, final int size, final boolean indexed) {
+		super();
+		this.id = id;
+		this.format = format;
+		this.layout = layout;
+		this.interpretation = interpretation;
+		this.size = size;
+		this.indexed = indexed;
+	}
+
+    public MDStoreDescription() {
+
+    }
+
+    public String getId() {
+		return id;
+	}
+
+	public void setId(final String id) {
+		this.id = id;
+	}
+
+	public String getFormat() {
+		return format;
+	}
+
+	public void setFormat(final String format) {
+		this.format = format;
+	}
+
+	public String getLayout() {
+		return layout;
+	}
+
+	public void setLayout(final String layout) {
+		this.layout = layout;
+	}
+
+	public String getInterpretation() {
+		return interpretation;
+	}
+
+	public void setInterpretation(final String interpretation) {
+		this.interpretation = interpretation;
+	}
+
+	public int getSize() {
+		return size;
+	}
+
+	public void setSize(final int size) {
+		this.size = size;
+	}
+
+	public boolean isIndexed() {
+		return indexed;
+	}
+
+	public void setIndexed(final boolean indexed) {
+		this.indexed = indexed;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
Index: modules/cnr-modular-mdstore-service/branches/indexFields/pom.xml
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields/pom.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields/pom.xml	(revision 45150)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+		<relativePath />
+	</parent>
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>cnr-modular-mdstore-service</artifactId>
+	<packaging>jar</packaging>
+	<version>4.0.4-SNAPSHOT</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/cnr-modular-mdstore-service/trunk</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework</groupId>
+			<artifactId>spring-test</artifactId>
+			<version>${spring.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mockito</groupId>
+			<artifactId>mockito-core</artifactId>
+			<version>1.6</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-test-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-rmi-api</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-blackboard-common</artifactId>
+			<version>[2.2.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-misc-utils</artifactId>
+			<version>[1.0.0,2.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-service</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>cnr-resultset-client</artifactId>
+			<version>[2.0.0,3.0.0)</version>
+		</dependency>
+	</dependencies>
+</project>
Index: modules/cnr-modular-mdstore-service/branches/indexFields
===================================================================
--- modules/cnr-modular-mdstore-service/branches/indexFields	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/indexFields	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/branches/indexFields
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+.classpath
+target
+bin
+.settings
+.project
+*.iml
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreTransactionManager.java	(revision 45150)
@@ -0,0 +1,110 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+
+public interface MDStoreTransactionManager {
+
+	/**
+	 * Creates the md store.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void createMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Drop md store.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract void dropMDStore(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Gets the MD store collection.
+	 * 
+	 * @param mdId
+	 *            the md id
+	 * @return the MD store collection
+	 * @throws MDStoreServiceException
+	 *             the MD store service exception
+	 */
+	public abstract String getMDStoreCollection(String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Start a new transaction for writing in the mdstore this will create a temporary mdstore in which save the content. and after finished
+	 * switch it to the existing one
+	 * 
+	 * @param mdId
+	 * @param refresh
+	 * @throws MDStoreServiceException
+	 *             if the mdStore Id doesn't exists in the metadata
+	 */
+	public abstract String startTransaction(String mdId, boolean refresh) throws MDStoreServiceException;
+
+	/**
+	 * Commit the transaction
+	 * 
+	 * 
+	 * @param transactionId
+	 * @param mdId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract boolean commit(String transactionId, String mdId) throws MDStoreServiceException;
+
+	/**
+	 * Book a a current mdstore, so the transaction manager can't delete during a possible commit, until the resultset associate has not
+	 * expired
+	 * 
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract String readMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Return a JSON about the transaction assigned to a particular mdstore
+	 * 
+	 * @param mdStoreId
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract MDStoreManagerInfo getInfoForCurrentMdStore(String mdStoreId) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 * 
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropUsed(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Manually drop an old collection assigned to a particular mdStore
+	 * 
+	 * @param mdId
+	 *            : the id of the mdStore
+	 * @param idToDrop
+	 *            : The id of the collection to be dropped
+	 * @return
+	 * @throws MDStoreServiceException
+	 */
+	public abstract Boolean dropTransaction(String mdId, String idToDrop) throws MDStoreServiceException;
+
+	/**
+	 * Start the garbage collection of the old mdstore not used
+	 * 
+	 * @throws MDStoreServiceException
+	 */
+	public abstract void garbage() throws MDStoreServiceException;
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/connector/MDStoreDao.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular.connector;
+
+import java.util.List;
+
+public interface MDStoreDao {
+
+	MDStore getMDStore(String mdId);
+
+	List<String> listMDStores();
+
+	List<String> listMDStores(String format, String layout, String interpretation);
+
+	void createMDStore(String mdId, String format, String interpretation, String layout);
+
+	void deleteMDStore(String id);
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/CreateAction.java	(revision 45150)
@@ -0,0 +1,49 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.MDStoreServiceException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreTransactionManager;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryException;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardJob;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerAction;
+import eu.dnetlib.enabling.tools.blackboard.BlackboardServerHandler;
+
+public class CreateAction extends AbstractMDStoreAction implements BlackboardServerAction<MDStoreActions> {
+
+	private MDStoreProfileCreator profileCreator;
+
+	@Autowired
+	private MDStoreTransactionManager transactionManager;
+
+	@Override
+	public void execute(final BlackboardServerHandler handler, final BlackboardJob job) throws ISRegistryException {
+		final String format = job.getParameters().get("format");
+		final String interpretation = job.getParameters().get("interpretation");
+		final String layout = job.getParameters().get("layout");
+
+		final String mdId = profileCreator.registerProfile(format, interpretation, layout);
+
+		try {
+			transactionManager.createMDStore(mdId);
+		} catch (MDStoreServiceException e) {
+			throw new ISRegistryException("Error on create mdStore", e);
+		}
+		getDao().createMDStore(mdId, format, interpretation, layout);
+
+		job.getParameters().put("id", mdId);
+
+		handler.done(job);
+	}
+
+	public MDStoreProfileCreator getProfileCreator() {
+		return profileCreator;
+	}
+
+	@Required
+	public void setProfileCreator(final MDStoreProfileCreator profileCreator) {
+		this.profileCreator = profileCreator;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public abstract class AbstractMDStoreAction {
+	private MDStoreDao dao;
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	public void setDao(MDStoreDao dao) {
+		this.dao = dao;
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java	(revision 45150)
@@ -0,0 +1,30 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.miscutils.factory.Factory;
+
+public class RecordParserFactory implements Factory<RecordParser> {
+	
+	private Class<? extends RecordParser> parserType;
+
+	@Override
+	public RecordParser newInstance() {
+		try {
+			return getParserType().newInstance();
+		} catch (Throwable e) {
+			throw new RuntimeException(e);
+		} 	
+	}
+
+	@Required
+	public void setParserType(Class<? extends RecordParser> parserType) {
+		this.parserType = parserType;
+	}
+
+	public Class<? extends RecordParser> getParserType() {
+		return parserType;
+	}
+
+
+}

Property changes on: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/java/eu/dnetlib/data/mdstore/modular/RecordParserFactory.java
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.properties	(revision 45150)
@@ -0,0 +1,7 @@
+services.mdstore.rsfactory=resultSetFactory
+services.mdstore.dao=mongodbMDStoreDao
+services.mdstore.syncFeed=true
+services.mdstore.recordParser=eu.dnetlib.data.mdstore.modular.StreamingRecordParser
+services.mdstore.rsfactory.pagesize=20
+services.mdstore.discardrecords=true
+services.mdstore.transaction=mongoMdStoreTransaction
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/branches/transaction-mdstore
===================================================================
--- modules/cnr-modular-mdstore-service/branches/transaction-mdstore	(nonexistent)
+++ modules/cnr-modular-mdstore-service/branches/transaction-mdstore	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/branches/transaction-mdstore
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+bin
+.settings
+.project
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreRetriever.java	(revision 45150)
@@ -0,0 +1,60 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+import org.springframework.beans.factory.annotation.Required;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
+import eu.dnetlib.data.mdstore.DocumentNotFoundException;
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.resultset.ResultSetFactory;
+
+public class MDStoreRetriever {
+
+	private MDStoreDao dao;
+
+	private ResultSetFactory resultSetFactory;
+
+	public W3CEndpointReference deliver(final String mdId, final String from, final String until, final String recordFilter) {
+
+		final MDStore mdStore = dao.getMDStore(mdId);
+
+		return getResultSetFactory().createResultSet(mdStore.deliver(from, until, recordFilter));
+	}
+
+	public Iterable<String> deliver(final String format, final String layout, final String interpretation) {
+		return Iterables.concat(Iterables.transform(dao.listMDStores(format, layout, interpretation), new Function<String, Iterable<String>>() {
+
+			@Override
+			public Iterable<String> apply(final String mdId) {
+				return dao.getMDStore(mdId).iterate();
+			}
+		}));
+	}
+
+	public String deliverRecord(final String mdId, final String recordId) throws DocumentNotFoundException {
+		return dao.getMDStore(mdId).getRecord(recordId);
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	@Required
+	public void setResultSetFactory(final ResultSetFactory resultSetFactory) {
+		this.resultSetFactory = resultSetFactory;
+	}
+
+	public ResultSetFactory getResultSetFactory() {
+		return resultSetFactory;
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/AbstractMDStoreAction.java	(revision 45150)
@@ -0,0 +1,16 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+
+public abstract class AbstractMDStoreAction {
+	private MDStoreDao dao;
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	public void setDao(MDStoreDao dao) {
+		this.dao = dao;
+	}
+	
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/StreamingRecordParser.java	(revision 45150)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.io.ByteArrayInputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * This method outperforms SimpleRecordParser by a vast amount, especially since we are just getting stuff in the
+ * header.
+ * 
+ * @author marko
+ * 
+ */
+public class StreamingRecordParser implements RecordParser {
+
+	@Override
+	public Map<String, String> parseRecord(String record) {
+
+		try {
+			XMLInputFactory factory = XMLInputFactory.newInstance();
+			XMLStreamReader parser = factory.createXMLStreamReader(new ByteArrayInputStream(record.getBytes()));
+
+			HashMap<String, String> res = new HashMap<String, String>();
+
+			Stack<String> elementStack = new Stack<String>();
+			elementStack.push("/");
+
+			while (parser.hasNext()) {
+				int event = parser.next();
+
+				if (event == XMLStreamConstants.END_ELEMENT) {
+					elementStack.pop();
+				} else if (event == XMLStreamConstants.START_ELEMENT) {
+					final String localName = parser.getLocalName();
+					elementStack.push(localName);
+
+					if ("objIdentifier".equals(localName)) {
+						parser.next();
+
+						res.put("id", parser.getText().trim());
+
+					} else if ("identifier".equals(localName) && "efgEntity".equals(grandParent(elementStack))) {
+						if (!res.containsKey("originalId")) {
+							parser.next();
+//							log.info("ZZZZZZ OK: found identifier at right depth " + elementStack);
+							res.put("originalId", parser.getText().trim());
+						}
+					}
+
+					else if ("identifier".equals(localName)) {
+
+//						log.info("ZZZZZZ: found identifier not at right depth " + elementStack + " grand parent " + grandParent(elementStack));
+					}
+
+					if (res.containsKey("id") && res.containsKey("originalId"))
+						return res;
+				}
+			}
+			return res;
+		} catch (XMLStreamException e) {
+			throw new IllegalStateException(e);
+		}
+
+	}
+
+	private String grandParent(Stack<String> elementStack) {
+		if (elementStack.size() <= 3)
+			return "";
+		return elementStack.get(elementStack.size() - 3);
+	}
+
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/java/eu/dnetlib/data/mdstore/modular/MDStoreFeeder.java	(revision 45150)
@@ -0,0 +1,149 @@
+package eu.dnetlib.data.mdstore.modular;
+
+import java.util.concurrent.Callable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Required;
+
+import eu.dnetlib.data.mdstore.modular.connector.MDStore;
+import eu.dnetlib.data.mdstore.modular.connector.MDStoreDao;
+import eu.dnetlib.enabling.is.registry.rmi.ISRegistryService;
+import eu.dnetlib.enabling.resultset.client.ResultSetClientFactory;
+import eu.dnetlib.enabling.tools.ServiceLocator;
+import eu.dnetlib.miscutils.datetime.DateUtils;
+
+public class MDStoreFeeder {
+	private MDStoreDao dao;
+
+	private ResultSetClientFactory resultSetClientFactory;
+
+	private ServiceLocator<ISRegistryService> registryLocator;
+
+	private boolean syncFeed = true;
+	
+	static final Log log = LogFactory.getLog(MDStoreFeeder.class);
+	
+	public void feed(final String mdId, final String rsEpr, final String storingType) {
+		feed(mdId, rsEpr, storingType, syncFeed, null, null);
+	}
+
+	public void feed(final String mdId, final String rsEpr, final String storingType, final boolean sync, final Callable<?> callback, final Callable<?> failCallback) {
+		log.info("Start feeding mdstore " + mdId + " with epr " + rsEpr);
+		
+		final Thread feederThread = new Thread(new Runnable() {
+			@Override
+			public void run() {
+				try {
+					final MDStore mdstore = dao.getMDStore(mdId);
+	
+					final Iterable<String> records = resultSetClientFactory.getClient(rsEpr);
+	
+					final boolean incremental = !"REFRESH".equals(storingType);
+	
+					if (!incremental)
+						mdstore.truncate();
+	
+					final int size = mdstore.feed(records, incremental);
+	
+					touch(mdId, size);
+	
+					log.info("Stop feeding mdstore " + mdId + " - new size: " + size);
+					
+					if (callback != null) {
+						try {
+							callback.call();
+						} catch (Exception e) {
+							log.error("Error executing callback", e);
+						}
+					}
+				} catch (Throwable e) {
+					log.error("Error in feeding thread", e);
+					if (failCallback != null) {
+						try {
+							failCallback.call();
+						} catch (Exception e1) {
+							log.error("Error executing failCallback", e);
+						}
+					}
+				}
+			}
+		});
+		
+		feederThread.start();
+		
+		if(sync) {
+			try {
+				feederThread.join();
+			} catch (InterruptedException e) {
+				throw new IllegalStateException(e);
+			}
+		}
+	}
+
+	/**
+	 * Sets the last modified date in the profile.
+	 * 
+	 * @param mdId
+	 */
+	public void touch(final String mdId, final int size) {
+		try {
+			final String now = DateUtils.now_ISO8601();
+
+			final String mdstoreXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//LAST_STORAGE_DATE with '" + now + "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreXUpdate);
+
+			touchSize(mdId, size);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public void touchSize(final String mdId, final int size) {
+		try {
+			final String mdstoreNumberXUpdate = "for $x in //RESOURCE_PROFILE[.//RESOURCE_IDENTIFIER/@value = '" + mdId + "']"
+					+ "return update value $x//NUMBER_OF_RECORDS with '" + size + "'";
+
+			registryLocator.getService().executeXUpdate(mdstoreNumberXUpdate);
+		} catch (final Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
+
+	public MDStoreDao getDao() {
+		return dao;
+	}
+
+	@Required
+	public void setDao(final MDStoreDao dao) {
+		this.dao = dao;
+	}
+
+	public ResultSetClientFactory getResultSetClientFactory() {
+		return resultSetClientFactory;
+	}
+
+	@Required
+	public void setResultSetClientFactory(final ResultSetClientFactory resultSetClientFactory) {
+		this.resultSetClientFactory = resultSetClientFactory;
+	}
+
+	public ServiceLocator<ISRegistryService> getRegistryLocator() {
+		return registryLocator;
+	}
+
+	@Required
+	public void setRegistryLocator(final ServiceLocator<ISRegistryService> registryLocator) {
+		this.registryLocator = registryLocator;
+	}
+
+	public boolean isSyncFeed() {
+		return syncFeed;
+	}
+
+	public void setSyncFeed(boolean syncFeed) {
+		this.syncFeed = syncFeed;
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/main/resources/eu/dnetlib/data/mdstore/modular/applicationContext-modular-mdstore.xml	(revision 45150)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
+	xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:wsa="http://cxf.apache.org/ws/addressing"
+	xmlns:p="http://www.springframework.org/schema/p" xmlns:http="http://cxf.apache.org/transports/http/configuration"
+	xmlns:t="http://dnetlib.eu/springbeans/t" xmlns:template="http://dnetlib.eu/springbeans/template"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+                                    http://cxf.apache.org/ws/addressing http://cxf.apache.org/schemas/ws-addr-conf.xsd
+                                    http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd
+                                    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+                            http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
+                            http://dnetlib.eu/springbeans/template http://dnetlib.eu/springbeans/template.xsd">
+
+	<!-- beans -->
+	<bean id="mdStoreService" class="eu.dnetlib.data.mdstore.modular.ModularMDStoreService"
+		init-method="start" destroy-method="stop" p:notificationHandler-ref="mdstoreNotificationHandler"
+		p:iterableResultSetFactory-ref="iterableResultSetFactory"
+		p:feeder-ref="mdstoreFeeder" p:retriever-ref="mdstoreRetriever" />
+
+	<bean id="mdstoreNotificationHandler"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerExecutorNotificationHandler"
+		p:blackboardExecutor-ref="mdstoreBlackboardExecutor" />
+
+	<bean id="mdstoreBlackboardExecutor"
+		class="eu.dnetlib.enabling.tools.blackboard.BlackboardServerActionExecutor"
+		p:blackboardHandler-ref="blackboardHandler"
+		p:actionType="eu.dnetlib.data.mdstore.modular.MDStoreActions"
+		p:incomplete="false">
+		<property name="actionMap">
+			<map>
+				<entry key="CREATE">
+					<bean class="eu.dnetlib.data.mdstore.modular.CreateAction"
+						p:profileCreator-ref="mdstoreProfileCreator"
+						p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="DELETE">
+					<bean class="eu.dnetlib.data.mdstore.modular.DeleteAction"
+						p:registryLocator-ref="registryLocator" p:dao-ref="${services.mdstore.dao}" />
+				</entry>
+				<entry key="FEED">
+					<bean class="eu.dnetlib.data.mdstore.modular.FeedAction"
+						p:dao-ref="${services.mdstore.dao}" 
+						p:feeder-ref="mdstoreFeeder"/>
+				</entry>
+			</map>
+		</property>
+	</bean>
+
+	<bean id="mdstoreProfileCreator" class="eu.dnetlib.data.mdstore.modular.MDStoreProfileCreator"
+		p:registryLocator-ref="registryLocator" p:mdstoreDsTemplate-ref="mdstoreDsTemplate"
+		p:endpoint-ref="mdStoreServiceEndpoint" p:eprBuilder-ref="jaxwsEndpointReferenceBuilder" />
+
+	<bean id="mdstoreDsTemplate"
+		class="eu.dnetlib.springutils.stringtemplate.StringTemplateFactory"
+		p:template="classpath:/eu/dnetlib/data/mdstore/modular/mdstoreds-template.xml"
+		scope="prototype" />
+
+	<bean id="mdstoreFeeder" class="eu.dnetlib.data.mdstore.modular.MDStoreFeeder"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetClientFactory-ref="mdstoreResultSetClientFactory"
+		p:syncFeed="${services.mdstore.syncFeed}" p:registryLocator-ref="registryLocator" />
+
+	<bean id="mdstoreResultSetClientFactory" parent="resultSetClientFactory"
+		p:pageSize="${services.mdstore.rsfactory.pagesize}" />
+
+
+	<bean id="mdstoreRetriever" class="eu.dnetlib.data.mdstore.modular.MDStoreRetriever"
+		p:dao-ref="${services.mdstore.dao}" p:resultSetFactory-ref="${services.mdstore.rsfactory}" />
+
+	<!-- <bean id="mdstoreRecordParser" class="eu.dnetlib.data.mdstore.modular.SimpleRecordParser" 
+		/> -->
+	<bean id="mdstoreRecordParser" 
+		factory-bean="recordParserFactory" factory-method="newInstance"/>
+	
+	<bean id="recordParserFactory" class="eu.dnetlib.data.mdstore.modular.RecordParserFactory"
+		p:parserType="${services.mdstore.recordParser}" />
+		
+	<bean id="bulkRecordMapperFactory" class="eu.dnetlib.data.mdstore.modular.BulkRecordMapperFactory" />
+
+	<!-- endpoints -->
+	<jaxws:endpoint id="mdStoreServiceEndpoint" implementor="#mdStoreService"
+		implementorClass="eu.dnetlib.data.mdstore.MDStoreService" address="/mdStore" />
+
+	<template:instance name="serviceRegistrationManager"
+		t:serviceRegistrationManagerClass="eu.dnetlib.enabling.tools.registration.ValidatingServiceRegistrationManagerImpl"
+		t:name="mdStoreServiceRegistrationManager" t:service="mdStoreService"
+		t:endpoint="mdStoreServiceEndpoint" t:jobScheduler="jobScheduler"
+		t:serviceRegistrator="blackboardServiceRegistrator" />
+</beans>
\ No newline at end of file
Index: modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0/src/test/java/eu/dnetlib/enabling/tools/blackboard/BlackboardServerActionExecutorTest.java	(revision 45150)
@@ -0,0 +1,58 @@
+package eu.dnetlib.enabling.tools.blackboard;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyObject;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import javax.annotation.Resource;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import eu.dnetlib.data.mdstore.modular.MDStoreActions;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class BlackboardServerActionExecutorTest {
+
+	@Resource
+	public transient BlackboardServerHandler blackboardHandler;
+
+	@Resource
+	public transient BlackboardServerActionExecutor<MDStoreActions> executor;
+
+	@Before
+	public void setUp() throws Exception {
+
+	}
+
+	@Test
+	public void testExecutor() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("CREATE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).done(eq(job));
+	}
+
+	@Test
+	public void testExecutorUnimplemented() {
+		assertNotNull(executor);
+
+		BlackboardJob job = mock(BlackboardJob.class);
+		when(job.getAction()).thenReturn("DELETE");
+
+		executor.execute(job);
+
+		verify(blackboardHandler).failed(eq(job), (Throwable) anyObject());
+	}
+}
Index: modules/cnr-modular-mdstore-service/releases/2.0.0
===================================================================
--- modules/cnr-modular-mdstore-service/releases/2.0.0	(nonexistent)
+++ modules/cnr-modular-mdstore-service/releases/2.0.0	(revision 45150)

Property changes on: modules/cnr-modular-mdstore-service/releases/2.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+target
+bin
+.settings
+.project
