Index: modules/dnet-fs-objectstore/trunk/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/trunk/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.8-SNAPSHOT</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/trunk</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,79 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				final long size = Files.size(path);
+
+				res.setHeader("Content-Length", String.valueOf(size));
+				IOUtils.copyLarge(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.5</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/trunk/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				final long size = Files.size(path);
+				res.setContentLengthLong(size);
+				res.setContentLength((int) size); //overflows in case of files larger than ~2GB
+
+				IOUtils.copyLarge(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.4</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.3</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/trunk/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/trunk/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/trunk/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/trunk/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/trunk/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/trunk/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/trunk
===================================================================
--- modules/dnet-fs-objectstore/trunk	(nonexistent)
+++ modules/dnet-fs-objectstore/trunk	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/trunk
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.7</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,79 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				final long size = Files.size(path);
+
+				res.setHeader("Content-Length", String.valueOf(size));
+				IOUtils.copyLarge(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				IOUtils.copy(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.2</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				IOUtils.copy(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				IOUtils.copy(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.1</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Long> saveAndGenerateMD5(final InputStream inputStream, final Path filePath) {
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		long size = 0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size = Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Long>(md5, size);
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				IOUtils.copy(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Integer size = 0;
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.0</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Integer size = 0;
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,220 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.find(query).first();
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.*;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+	public static Path objectStoreFilePath(final String basePath, final String objectStoreId, final String objectIdentifier) {
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(objectStoreId);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		final String fileName = StringUtils.substring(md5id, 4) + ".obj";
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel).resolve(fileName);
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.7
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/pom.xml	(revision 45184)
@@ -0,0 +1,49 @@
+<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/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<groupId>eu.dnetlib</groupId>
+		<artifactId>dnet-parent</artifactId>
+		<version>1.0.0</version>
+	</parent>
+	<groupId>eu.dnetlib</groupId>
+	<artifactId>dnet-fs-objectstore</artifactId>
+	<version>2.1.6</version>
+	<scm>
+		<developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6</developerConnection>
+	</scm>
+	<dependencies>
+		<dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.2.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>${javax.servlet.version}</version>
+			<scope>provided</scope>
+		</dependency>
+
+	</dependencies>
+</project>
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,117 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import com.mongodb.client.MongoDatabase;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * TODO: Test class set to ignored because it requires a mongo server running on localhost. Tests with mocks should be prepared.
+ * @author sandro
+ *
+ */
+@Ignore
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private MongoDatabase objectstoreMongoDB;
+
+	private String interpretation = "interp";
+	private String basePath = "/tmp/basePath";
+	//must be 36 chars
+	private String obsID = "test56789111315171921232527293133350";
+	private String pdfPath = "./test.pdf";
+
+	@Before
+	public void setup() throws IOException, ObjectStoreServiceException {
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(baseDirPath)) {
+			Files.createDirectory(baseDirPath);
+		}
+		objectStoreDAO.createObjectStore(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl", interpretation, basePath);
+	}
+
+	@After
+	public void tearDown() throws IOException, ObjectStoreServiceException {
+		objectstoreMongoDB.drop();
+		FileUtils.deleteDirectory(new File(basePath));
+	}
+
+	@Test
+	public void testList() {
+		final List<String> objectStores = this.objectStoreDAO.listObjectStores();
+		for (String o : objectStores)
+			System.out.println(o);
+		assertTrue(objectStores.contains(obsID + "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl"));
+	}
+
+	@Test
+	public void testGet() throws ObjectStoreServiceException {
+		ObjectStore o = objectStoreDAO.getObjectStore(obsID);
+		System.out.println(o.toString());
+		assertNotNull(o);
+	}
+
+	@Test
+	public void testFeed() throws ObjectStoreServiceException, FileNotFoundException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+	}
+
+	@Test
+	public void testDeliverObject() throws ObjectStoreServiceException {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		final ObjectStoreFile obj2 = objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2");
+		System.out.println(obj2.toJSON());
+		assertNotNull(obj2);
+	}
+
+	@Test
+	public void testGetStream() throws Exception {
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(), true);
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+		}
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,552 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final DBCollection mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+
+	private Path createObjectStorePath(final String objectIdentifier, final String basePath){
+
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel);
+	}
+
+
+	private String getFileName(final String objectIdentifier){
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		return StringUtils.substring(md5id, 4)+ ".obj";
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				Path objectStoreFilePath = createObjectStorePath(objectIdentifier, basePath);
+				if (Files.notExists(objectStoreFilePath.resolve(getFileName(objectIdentifier)))) {
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+						String md5Sum = null;
+						Integer size = 0;
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos =
+									FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(getFileName(objectIdentifier)));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if (!StringUtils.isEmpty(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(getFileName(objectIdentifier)).toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record != null && record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objectStoreFilePath + "exists ");
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (MetadataObjectRecord o : records) {
+			if (o == null || o.getRecord() == null) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+            log.debug(o.toJSON());
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath.resolve(thirdLevel + ".obj"))) {
+					InputStream is = null;
+					try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+						is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if (is != null) {
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel + ".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if (!StringUtils.isEmpty(md5Sum)) {
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(getFileName(objectIdentifier)).toAbsolutePath().toString());
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: " + metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter++;
+					}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " +o.toJSON());
+					} finally {
+						if (is != null) {
+							try {
+								is.close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				}
+				else{
+					log.debug("File already exists"+o.getId());
+				}
+
+
+			}
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record == null)
+			return null;
+
+		try {
+			Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+			if (!Files.exists(baseDirPath))
+				throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+			String url = null;
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath.resolve(thirdLevel + ".obj"))) {
+
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+
+					url = insertFileAndMetadata(record, url, thirdLevel, objectStoreFilePath);
+				}
+			}
+			return url;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException(e);
+		} finally {
+			if (record != null && record.getInputStream() != null) {
+				try {
+					record.getInputStream().close();
+				} catch (Exception e) {
+					log.error("Error on close inputStream", e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * @param record
+	 * @param url
+	 * @param thirdLevel
+	 * @param objectStoreFilePath
+	 * @return
+	 */
+	private String insertFileAndMetadata(final ObjectStoreRecord record, String url, final String thirdLevel, final Path objectStoreFilePath) {
+		try {
+			Files.createDirectories(objectStoreFilePath);
+			log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+			String md5Sum = null;
+			Integer size = 0;
+
+			if (record.getInputStream() != null) {
+				Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel + ".obj"));
+				md5Sum = info.getKey();
+				size = info.getValue();
+			}
+			if (!StringUtils.isEmpty(md5Sum)) {
+				double timestamp = System.currentTimeMillis();
+				BasicDBObject metadata = new BasicDBObject();
+				metadata.put("id", record.getFileMetadata().getObjectID());
+				metadata.put("mime", record.getFileMetadata().getMimeType());
+				metadata.put("originalObject", record.getFileMetadata().toJSON());
+				metadata.put("timestamp", timestamp);
+				metadata.put("md5Sum", md5Sum);
+
+				metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel + ".obj").toAbsolutePath().toString());
+				String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+						+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+				metadata.put(URI_FIELD, URI);
+				metadata.put("size", size);
+
+				url = URI;
+				log.debug("saving metadata object to the collection: " + metadata.toString());
+				mongoMetadata.insert(metadata);
+
+			}
+		} catch (Exception e) {
+			log.error("Something bad happen on inserting Record", e);
+			log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the in the path: " + path);
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ", e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the metadata db");
+		Path path = FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (basePath == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+
+		this.mongoMetadata.remove(new BasicDBObject());
+		log.info("Delete metadata");
+		return true;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,207 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.*;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.8</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.6
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Integer size = 0;
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,34 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.MongoClientOptions;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoClientOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoClientOptions getObject() throws BeansException {
+		return MongoClientOptions.builder().connectionsPerHost(connectionsPerHost).build();
+	}
+
+	@Override
+	public Class<MongoClientOptions> getObjectType() {
+		return MongoClientOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,78 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				res.setContentLengthLong(Files.size(path));
+
+				IOUtils.copyLarge(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+	private String pdfResourcePath = "test.pdf";
+	private Resource testPDF = new ClassPathResource(pdfResourcePath);
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+
+			fileMetadata.setDownloadedURL("file://" + pdfResourcePath);
+			fileMetadata.setURI("file://" + pdfResourcePath);
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(testPDF.getInputStream());
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,350 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		}
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from-1; i < Math.min(records.size(),to); i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.5
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Long.parseLong(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,504 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final DBCollection mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath)) {
+
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos =
+									FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel + ".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if (!StringUtils.isEmpty(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel + ".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record != null && record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objectStoreFilePath + "exists ");
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (MetadataObjectRecord o : records) {
+			if (o == null || o.getRecord() == null) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath)) {
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if (is != null) {
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel + ".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if (!StringUtils.isEmpty(md5Sum)) {
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: " + metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter++;
+					}
+				}
+			}
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record == null)
+			return null;
+
+		try {
+			Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+			if (!Files.exists(baseDirPath))
+				throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+			String url = null;
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath.resolve(thirdLevel + ".obj"))) {
+
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+
+					url = insertFileAndMetadata(record, url, thirdLevel, objectStoreFilePath);
+				}
+			}
+			return url;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException(e);
+		} finally {
+			if (record != null && record.getInputStream() != null) {
+				try {
+					record.getInputStream().close();
+				} catch (Exception e) {
+					log.error("Error on close inputStream", e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * @param record
+	 * @param url
+	 * @param thirdLevel
+	 * @param objectStoreFilePath
+	 * @return
+	 */
+	private String insertFileAndMetadata(final ObjectStoreRecord record, String url, final String thirdLevel, final Path objectStoreFilePath) {
+		try {
+			Files.createDirectories(objectStoreFilePath);
+			log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+			String md5Sum = null;
+			Integer size = 0;
+
+			if (record.getInputStream() != null) {
+				Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel + ".obj"));
+				md5Sum = info.getKey();
+				size = info.getValue();
+			}
+			if (!StringUtils.isEmpty(md5Sum)) {
+				double timestamp = System.currentTimeMillis();
+				BasicDBObject metadata = new BasicDBObject();
+				metadata.put("id", record.getFileMetadata().getObjectID());
+				metadata.put("mime", record.getFileMetadata().getMimeType());
+				metadata.put("originalObject", record.getFileMetadata().toJSON());
+				metadata.put("timestamp", timestamp);
+				metadata.put("md5Sum", md5Sum);
+
+				metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel + ".obj").toAbsolutePath().toString());
+				String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+						+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+				metadata.put(URI_FIELD, URI);
+				metadata.put("size", size);
+
+				url = URI;
+				log.debug("saving metadata object to the collection: " + metadata.toString());
+				mongoMetadata.insert(metadata);
+
+			}
+		} catch (Exception e) {
+			log.error("Something bad happen on inserting Record", e);
+			log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the in the path: " + path);
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ", e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the metadata db");
+		Path path = FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return mongoMetadata.count(query) > 0;
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.4
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.6</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,382 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.DeleteResult;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final MongoCollection<DBObject> mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final MongoCollection<DBObject> mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+			String url = feedObject(record);
+			if (StringUtils.isNotBlank(url)) {
+				addedCounter++;
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 *
+	 * This method handles the case of web crawl files and other cases when the metadata in mdstores are also the objects to put into the objectstores.
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		Iterable<ObjectStoreRecord> it = Iterables.transform(records, new Function<MetadataObjectRecord, ObjectStoreRecord>() {
+			@Override
+			public ObjectStoreRecord apply(final MetadataObjectRecord metadataObjectRecord) {
+				ObjectStoreRecord r = new ObjectStoreRecord();
+				r.setInputStream(new ByteArrayInputStream(metadataObjectRecord.getRecord().getBytes()));
+				ObjectStoreFile fileMetadata = new ObjectStoreFile();
+				fileMetadata.setObjectID(metadataObjectRecord.getId());
+				fileMetadata.setMimeType(metadataObjectRecord.getMime());
+				r.setFileMetadata(fileMetadata);
+				return r;
+			}
+		});
+		return feed(it, incremental);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		return feedObject(record);
+	}
+
+	private String feedObject(final ObjectStoreRecord record) {
+		if (record != null) {
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (StringUtils.isNotBlank(objectIdentifier)) {
+				final Path objResolvedPath = FileSystemUtility.objectStoreFilePath(basePath, id, objectIdentifier);
+
+				if (Files.notExists(objResolvedPath)) {
+					try {
+						log.debug("Creation of folder " + objResolvedPath.getParent());
+						Files.createDirectories(objResolvedPath.getParent());
+						log.debug("Folder " + objResolvedPath.getParent() + " created");
+						String md5Sum = null;
+						Long size = new Long(0);
+						if (record.getInputStream() != null) {
+							Pair<String, Long> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objResolvedPath);
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						final String url =
+								ModularObjectStoreRESTService.retrieveURL(getBaseURI(), getBasePath(), getId(), record.getFileMetadata().getObjectID());
+						if (StringUtils.isNotBlank(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objResolvedPath.toAbsolutePath().toString());
+							metadata.put(URI_FIELD, url);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insertOne(metadata);
+						}
+						return url;
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objResolvedPath.getParent() + "exists ");
+				}
+			}
+		}
+		log.warn("Record for object store is null");
+		return null;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setFromDate(from);
+		resultSet.setUntilDate(until);
+		resultSet.setBasePath(getBasePath());
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resultSet = new FileSystemObjectStoreResultSetListener();
+		resultSet.setBaseURI(getBaseURI());
+		resultSet.setMongoCollection(mongoMetadata);
+		resultSet.setObjectStoreID(getId());
+		resultSet.setRecords(Lists.newArrayList(ids));
+		resultSet.setBasePath(basePath);
+		return resultSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject resultQuery = mongoMetadata.find(query).first();
+		checkAndGetFsPathField(resultQuery, objectId);
+		return ObjectStoreFileUtility.build(resultQuery, getBaseURI(), getId(), basePath);
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectId) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found or missing " + FS_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " with blank " + FS_PATH_FIELD);
+		return pathStr;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.count();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", objectId);
+		DBObject response = mongoMetadata.find(query).first();
+		String pathStr = checkAndGetFsPathField(response, objectId);
+		Path path = FileSystems.getDefault().getPath(pathStr);
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.deleteOne(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		Bson query = Filters.eq("id", recordId);
+		DBObject response = mongoMetadata.find(query).first();
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		Bson query = Filters.regex("id", Pattern.compile(startId));
+		return mongoMetadata.count(query) > 0;
+	}
+
+	@Override
+	public boolean dropContent() throws ObjectStoreServiceException {
+		if (getBasePath() == null) {
+			throw new ObjectStoreServiceException("Error on dropping object store base_path required");
+		}
+		final Path baseDirPath = FileSystems.getDefault().getPath(getBasePath()).resolve(getId());
+		try {
+			FileSystemUtility.deleteFolderRecursive(baseDirPath);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Error on dropping store ", e);
+		}
+		log.info("Deleted folder" + baseDirPath.toString());
+		if (!Files.exists(baseDirPath)) {
+			log.info("Recreating folder " + baseDirPath);
+			try {
+				Files.createDirectory(baseDirPath);
+			} catch (IOException e) {
+				throw new ObjectStoreServiceException("Error on dropping store ", e);
+			}
+		}
+		final DeleteResult deleteResult = this.mongoMetadata.deleteMany(new BasicDBObject());
+		log.info("Dropped content for object store " + id + ". " + deleteResult.getDeletedCount() + " object(s) deleted.");
+		return true;
+	}
+
+	@Override
+	public String toString() {
+		return "FileSystemObjectStore{" +
+				"id='" + getId() + '\'' +
+				", interpretation='" + getInterpretation() + '\'' +
+				", basePath='" + getBasePath() + '\'' +
+				", baseURI='" + getBaseURI() + '\'' +
+				'}';
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,215 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import javax.annotation.Resource;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.result.UpdateResult;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	public static final String INTERPRETATION_FIELD = "interpretation";
+	public final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+	public final static String OBJECTSTORE_ID_FIELD = "obsId";
+	public final static String BASE_PATH_FIELD = "basePath";
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+	private static final String OBJECTSTORE_PROFILE_SUFFIX = "_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+	@Resource(name="objectstoreMongoDB")
+	private MongoDatabase db;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId = obsId.substring(0, 36);
+		String find_id = obsId;
+		if (find_id.length() == 36) {
+			find_id += OBJECTSTORE_PROFILE_SUFFIX;
+		}
+
+		MongoCollection<DBObject> metadataObjectStore = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, find_id);
+		log.debug("QUERY :" + query.toString());
+		DBObject resultQuery = metadataObjectStore.find(query).first();
+		log.debug("result " + resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		final String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		final String interpretation = resultQuery.get("interpretation").toString();
+
+		if (!resultQuery.containsField(BASE_PATH_FIELD) || StringUtils.isBlank(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contain info about the basepath");
+
+		final MongoCollection<DBObject> collection = getDb().getCollection(currentId, DBObject.class);
+		return new FileSystemObjectStore(currentId, interpretation, basePath, collection, objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		MongoCollection<DBObject> metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isBlank(basePath)) throw new ObjectStoreServiceException("Can't create the object store: the base path cannot be blank");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't create the object store: base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentObsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id " + currentObsId);
+			if (Files.exists(path.resolve(currentObsId)))
+				throw new ObjectStoreServiceException("Can't create the object store: base path: '" + path.resolve(currentObsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentObsId));
+			MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.insertOne(obj);
+			MongoCollection<DBObject> objectStore = getDb().getCollection(currentObsId, DBObject.class);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			objectStore.createIndex(new BasicDBObject("timestamp", 1));
+			return true;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put("$set", new BasicDBObject(INTERPRETATION_FIELD, interpretation));
+
+		final UpdateResult updateResult = coll.updateOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId), obj);
+		if (updateResult.isModifiedCountAvailable()) {
+			log.debug("Matched / Modified " + updateResult.getMatchedCount() + " / " + updateResult.getModifiedCount());
+		}
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		MongoCollection<DBObject> coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		Bson query = Filters.eq(OBJECTSTORE_ID_FIELD, obsId);
+		DBObject resultQuery = coll.find(query).first();
+		String basePath = checkAndGetFsPathField(resultQuery, obsId);
+		String currentObsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentObsId);
+		if (!Files.exists(basePathFS))
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId + ": the base path does not exist :" + basePathFS);
+		try {
+			FileSystemUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete ObjectStore " + obsId, e);
+		}
+		coll.deleteOne(Filters.eq(OBJECTSTORE_ID_FIELD, obsId));
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+	@Override
+	public boolean dropContent(final String obsId) throws ObjectStoreServiceException {
+		return getObjectStore(obsId).dropContent();
+	}
+
+	private String checkAndGetFsPathField(final DBObject resultQuery, final String objectStoreID) throws ObjectStoreServiceException {
+		if (resultQuery == null || !resultQuery.containsField(BASE_PATH_FIELD))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " not found or missing " + BASE_PATH_FIELD + " field");
+		String pathStr = (String) resultQuery.get(BASE_PATH_FIELD);
+		if (StringUtils.isBlank(pathStr))
+			throw new ObjectStoreServiceException("ObjectStore with identifier :" + objectStoreID + " with blank " + BASE_PATH_FIELD);
+		return pathStr;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public MongoDatabase getDb() {
+		return db;
+	}
+
+	public void setDb(final MongoDatabase db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.3
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.9</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,489 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				url = insertFileAndMetadata(record, url, thirdLevel, objectStoreFilePath);
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				if (resultQuery== null) {
+					
+				} else
+					
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+
+	/**
+	 * @param record
+	 * @param url
+	 * @param thirdLevel
+	 * @param objectStoreFilePath
+	 * @return
+	 */
+	private String insertFileAndMetadata(final ObjectStoreRecord record, String url, final String thirdLevel, Path objectStoreFilePath) {
+		try {
+			Files.createDirectories(objectStoreFilePath);
+			log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+			String md5Sum = null;
+			Integer size = 0;
+
+			if((record.getInputStream()!= null)){
+				Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+				md5Sum = info.getKey();
+				size = info.getValue();
+			}
+			if(!StringUtils.isEmpty(md5Sum)){
+				double timestamp = System.currentTimeMillis();
+				BasicDBObject metadata = new BasicDBObject();
+				metadata.put("id", record.getFileMetadata().getObjectID());
+				metadata.put("mime", record.getFileMetadata().getMimeType());
+				metadata.put("originalObject", record.getFileMetadata().toJSON());
+				metadata.put("timestamp", timestamp);
+				metadata.put("md5Sum", md5Sum);
+
+				metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+				String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+						+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+				metadata.put(URI_FIELD, URI);
+				metadata.put("size", size);
+
+				url = URI;
+				log.debug("saving metadata object to the collection: "+metadata.toString());
+				mongoMetadata.insert(metadata);
+
+			}
+		} catch (Exception e) {
+			log.error("Something bad happen on inserting Record", e);
+			log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/IndexIntegrityChecker.java	(revision 45184)
@@ -0,0 +1,55 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.IndexOptions;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_ID_FIELD;
+import static eu.dnetlib.data.objectstore.filesystem.FileSystemObjectStoreDao.OBJECTSTORE_METADATA_NAME_FIELD;
+
+/**
+ * Created by claudio on 15/09/16.
+ */
+public class IndexIntegrityChecker {
+
+	private static final Log log = LogFactory.getLog(IndexIntegrityChecker.class);
+
+	@Autowired
+	private ObjectStoreDao dao;
+
+	public void check() {
+		checkIndexes();
+	}
+
+	private void checkIndexes() {
+		log.info("objectStore indexes integrity start");
+
+		final MongoDatabase db = ((FileSystemObjectStoreDao) dao).getDb();
+		final IndexOptions bg = new IndexOptions().background(true);
+
+		for (String objectStoreId : dao.listObjectStores()) {
+			final String id = StringUtils.substringBefore(objectStoreId, "_");
+			final MongoCollection<DBObject> objectStore = db.getCollection(id, DBObject.class);
+			if (log.isDebugEnabled()) {
+				log.debug(String.format("creating index (id, timestamp) on objectStore %s", id));
+			}
+			objectStore.createIndex(new BasicDBObject("id", 1), bg);
+			objectStore.createIndex(new BasicDBObject("timestamp", 1), bg);
+		}
+		if (log.isDebugEnabled()) {
+			log.debug(String.format("creating index (%s) on %s", OBJECTSTORE_ID_FIELD, OBJECTSTORE_METADATA_NAME_FIELD));
+		}
+		final MongoCollection<DBObject> metadata = db.getCollection(OBJECTSTORE_METADATA_NAME_FIELD, DBObject.class);
+		metadata.createIndex(new BasicDBObject(OBJECTSTORE_ID_FIELD, 1), bg);
+
+		log.info("objectStore indexes integrity completed");
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,63 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+
+import com.mongodb.DBObject;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID, final String basePath) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+		}
+		try {
+			newFile.setURI(ModularObjectStoreRESTService.retrieveURL(baseURI, basePath, objectStoreID, newFile.getObjectID()));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID, final String basePath) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID, basePath).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.properties	(revision 45184)
@@ -0,0 +1,8 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectstore.mongodb.integritycheck.cron=0 0 2 1/1 * ? *
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,51 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoDatabase;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public MongoDatabase objectstoreMongoDB() throws UnknownHostException {
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDatabase("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ModularObjectStoreRESTService.java	(revision 45184)
@@ -0,0 +1,76 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import javax.servlet.http.HttpServletResponse;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.datetime.HumanTime;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * The Class ModularObjectStoreRESTService implement the controller REST of the object Store.
+ */
+@Controller
+public class ModularObjectStoreRESTService {
+
+	private static final Log log = LogFactory.getLog(ModularObjectStoreRESTService.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	public static String retrieveURL(final String baseURI, final String basePath, final String objectStoreId, final String objectId)
+			throws UnsupportedEncodingException {
+		final StringBuilder sb = new StringBuilder(baseURI)
+				.append("?objectStore=" + encode(objectStoreId))
+				.append("&objectId=" + encode(objectId))
+				.append("&basePath=" + encode(basePath));
+		return sb.toString();
+	}
+
+	private static String encode(final String s) throws UnsupportedEncodingException {
+		return URLEncoder.encode(s, "UTF-8");
+	}
+
+	/**
+	 *
+	 * @param res
+	 * @param basePath
+	 * @param objectStoreId
+	 * @param objectId
+	 * @throws IOException
+	 * @throws ObjectStoreServiceException
+	 */
+	@RequestMapping(value = "/**/objectStore/retrieve.do")
+	public void retrieve(final HttpServletResponse res,
+			@RequestParam(value = "basePath", required = true) final String basePath,
+			@RequestParam(value = "objectStore", required = true) final String objectStoreId,
+			@RequestParam(value = "objectId", required = true) final String objectId) throws IOException, ObjectStoreServiceException {
+
+		final long start = System.currentTimeMillis();
+		final Path path = FileSystemUtility.objectStoreFilePath(basePath, objectStoreId, objectId);
+
+		if (!Files.exists(path) || !Files.isReadable(path)) {
+			final String msg = String.format("Object with identifier: %s not found the in %s", objectId, path);
+			res.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
+			log.warn(msg);
+		} else {
+			try (final InputStream is = new BufferedInputStream(new FileInputStream(path.toFile()))) {
+
+				IOUtils.copy(is, res.getOutputStream());
+
+				if (log.isDebugEnabled()) {
+					log.debug(String.format("retrive.do completed in %s, objId: %s", HumanTime.exactly(System.currentTimeMillis() - start), objectId));
+				}
+			} catch (IOException e) {
+				final String msg = "unable to close input Stream";
+				res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg);
+				log.error(msg, e);
+			}
+		}
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.4</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,352 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DBObject;
+import com.mongodb.client.FindIterable;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoCursor;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.Sorts;
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.bson.conversions.Bson;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private MongoCollection<DBObject> mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/**
+	 * The base path
+	 */
+	private String basePath;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private MongoCursor<DBObject> currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			Bson q = Filters.in("id", ids);
+			FindIterable<DBObject> res = getMongoCollection().find(q);
+			return MappedCollection.listMap(res, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(getBaseURI(), getObjectStoreID(), getBasePath()));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(timestampQuery).sort(Sorts.orderBy(Filters.eq("_id", 1))).iterator();
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			Bson query = Filters.in("id", records);
+			return (int) getMongoCollection().count(query);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			Bson timestampQuery = Filters.and(Filters.gt("timestamp", fromDate.doubleValue()), Filters.lt("timestamp", untilDate.doubleValue()));
+			return (int) getMongoCollection().count(timestampQuery);
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public MongoCursor<DBObject> getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final MongoCursor<DBObject> currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public MongoCollection<DBObject> getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final MongoCollection<DBObject> mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+	public String getBasePath() {
+		return basePath;
+	}
+
+	public void setBasePath(final String basePath) {
+		this.basePath = basePath;
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/main/resources/eu/dnetlib/data/objectstore/filesystem/applicationContext-filesystem-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/resources/test.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/resources/test.pdf
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/resources/test.pdf	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/resources/test.pdf	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0/src/test/resources/test.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-2.1.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,81 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import eu.dnetlib.miscutils.collections.Pair;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public static boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.2</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.9
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,525 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore {
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier
+	 *            the identifier
+	 * @param interpretation
+	 *            the interpretation
+	 * @param basePath
+	 *            the base path
+	 * @param mongoMetadata
+	 *            the mongo metadata
+	 * @param baseURI
+	 *            the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath, final DBCollection mongoMetadata,
+			final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+
+	private Path createObjectStorePath(final String objectIdentifier, final String basePath){
+
+		final Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		final String firstLevel = StringUtils.substring(md5id, 0, 2);
+		final String secondLevel = StringUtils.substring(md5id, 2, 4);
+		return baseDirPath.resolve(firstLevel).resolve(secondLevel);
+	}
+
+
+	private String getFileName(final String objectIdentifier){
+		final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+		return StringUtils.substring(md5id, 4)+ ".obj";
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records == null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (ObjectStoreRecord record : records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				Path objectStoreFilePath = createObjectStorePath(objectIdentifier, basePath);
+				if (Files.notExists(objectStoreFilePath.resolve(getFileName(objectIdentifier)))) {
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+						String md5Sum = null;
+						Integer size = 0;
+						if (record.getInputStream() != null) {
+							Pair<String, Integer> infos =
+									FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(getFileName(objectIdentifier)));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if (!StringUtils.isEmpty(md5Sum)) {
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(getFileName(objectIdentifier)).toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: " + metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+					} finally {
+						if (record != null && record.getInputStream() != null) {
+							try {
+								record.getInputStream().close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				} else {
+					log.debug("The File in the path" + objectStoreFilePath + "exists ");
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int  feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+		int addedCounter = 0;
+		for (MetadataObjectRecord o : records) {
+			if (o == null || o.getRecord() == null) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+            log.debug(o.toJSON());
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath.resolve(thirdLevel + ".obj"))) {
+					InputStream is = null;
+					try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+						is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if (is != null) {
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel + ".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if (!StringUtils.isEmpty(md5Sum)) {
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(getFileName(objectIdentifier)).toAbsolutePath().toString());
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: " + metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter++;
+					}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: " +o.toJSON());
+					} finally {
+						if (is != null) {
+							try {
+								is.close();
+							} catch (Exception e) {
+								log.error("Error on close inputStream", e);
+							}
+						}
+					}
+				}
+				else{
+					log.debug("File already exists"+o.getId());
+				}
+
+
+			}
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record == null)
+			return null;
+
+		try {
+			Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+			if (!Files.exists(baseDirPath))
+				throw new ObjectStoreServiceException("Error can't feed objects because the folder " + baseDirPath + " does not exist");
+
+			String url = null;
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)) {
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel = StringUtils.substring(md5id, 0, 2);
+				final String secondLevel = StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel = StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath = baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath.resolve(thirdLevel + ".obj"))) {
+
+					log.debug("The folder " + objectStoreFilePath.toString() + " doesn't exist! It should be created");
+
+					url = insertFileAndMetadata(record, url, thirdLevel, objectStoreFilePath);
+				}
+			}
+			return url;
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException(e);
+		} finally {
+			if (record != null && record.getInputStream() != null) {
+				try {
+					record.getInputStream().close();
+				} catch (Exception e) {
+					log.error("Error on close inputStream", e);
+				}
+			}
+		}
+	}
+
+	/**
+	 * @param record
+	 * @param url
+	 * @param thirdLevel
+	 * @param objectStoreFilePath
+	 * @return
+	 */
+	private String insertFileAndMetadata(final ObjectStoreRecord record, String url, final String thirdLevel, final Path objectStoreFilePath) {
+		try {
+			Files.createDirectories(objectStoreFilePath);
+			log.debug("Creation of folder " + objectStoreFilePath + " Done!");
+
+			String md5Sum = null;
+			Integer size = 0;
+
+			if (record.getInputStream() != null) {
+				Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel + ".obj"));
+				md5Sum = info.getKey();
+				size = info.getValue();
+			}
+			if (!StringUtils.isEmpty(md5Sum)) {
+				double timestamp = System.currentTimeMillis();
+				BasicDBObject metadata = new BasicDBObject();
+				metadata.put("id", record.getFileMetadata().getObjectID());
+				metadata.put("mime", record.getFileMetadata().getMimeType());
+				metadata.put("originalObject", record.getFileMetadata().toJSON());
+				metadata.put("timestamp", timestamp);
+				metadata.put("md5Sum", md5Sum);
+
+				metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel + ".obj").toAbsolutePath().toString());
+				String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+						+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+				metadata.put(URI_FIELD, URI);
+				metadata.put("size", size);
+
+				url = URI;
+				log.debug("saving metadata object to the collection: " + metadata.toString());
+				mongoMetadata.insert(metadata);
+
+			}
+		} catch (Exception e) {
+			log.error("Something bad happen on inserting Record", e);
+			log.error("Record: " + new Gson().toJson(record.getFileMetadata()));
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if (resultQuery == null || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found the in the path: " + path);
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ", e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the metadata db");
+		Path path = FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if (Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :" + objectId + " not found in the assigned path " + path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ", e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if (response == null || !response.containsField(URI_FIELD))
+			return null;
+		return (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return mongoMetadata.count(query) > 0;
+	}
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,472 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+					String md5Sum = null;
+					Integer size = 0;
+
+					if((record.getInputStream()!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						double timestamp = System.currentTimeMillis();
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", record.getFileMetadata().getObjectID());
+						metadata.put("mime", record.getFileMetadata().getMimeType());
+						metadata.put("originalObject", record.getFileMetadata().toJSON());
+						metadata.put("timestamp", timestamp);
+						metadata.put("md5Sum", md5Sum);
+
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+						String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+								+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+						metadata.put(URI_FIELD, URI);
+						metadata.put("size", size);
+
+						url = URI;
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+
+					}
+				} catch (Exception e) {
+					log.error("Something bad happen on inserting Record", e);
+					log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+				}
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,482 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				} else {
+					log.debug("The File in the path"+objectStoreFilePath+ "exists ");
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath.resolve(thirdLevel+".obj")))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				url = insertFileAndMetadata(record, url, thirdLevel, objectStoreFilePath);
+			}
+		}
+		return url;
+	}
+
+
+	/**
+	 * @param record
+	 * @param url
+	 * @param thirdLevel
+	 * @param objectStoreFilePath
+	 * @return
+	 */
+	private String insertFileAndMetadata(final ObjectStoreRecord record, String url, final String thirdLevel, final Path objectStoreFilePath) {
+		try {
+			Files.createDirectories(objectStoreFilePath);
+			log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+			String md5Sum = null;
+			Integer size = 0;
+
+			if((record.getInputStream()!= null)){
+				Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+				md5Sum = info.getKey();
+				size = info.getValue();
+			}
+			if(!StringUtils.isEmpty(md5Sum)){
+				double timestamp = System.currentTimeMillis();
+				BasicDBObject metadata = new BasicDBObject();
+				metadata.put("id", record.getFileMetadata().getObjectID());
+				metadata.put("mime", record.getFileMetadata().getMimeType());
+				metadata.put("originalObject", record.getFileMetadata().toJSON());
+				metadata.put("timestamp", timestamp);
+				metadata.put("md5Sum", md5Sum);
+
+				metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+				String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+						+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+				metadata.put(URI_FIELD, URI);
+				metadata.put("size", size);
+
+				url = URI;
+				log.debug("saving metadata object to the collection: "+metadata.toString());
+				mongoMetadata.insert(metadata);
+
+			}
+		} catch (Exception e) {
+			log.error("Something bad happen on inserting Record", e);
+			log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.8
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,6 ##
+*.iml
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.7</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.5</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.7
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.6
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,214 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+		if ((resultQuery == null)) throw new ObjectStoreFileNotFoundException("the objectStore with identifier: "+obsId+" was not found");
+
+		if ( !resultQuery.containsField(BASE_PATH_FIELD) ||  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,472 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+					String md5Sum = null;
+					Integer size = 0;
+
+					if((record.getInputStream()!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						double timestamp = System.currentTimeMillis();
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", record.getFileMetadata().getObjectID());
+						metadata.put("mime", record.getFileMetadata().getMimeType());
+						metadata.put("originalObject", record.getFileMetadata().toJSON());
+						metadata.put("timestamp", timestamp);
+						metadata.put("md5Sum", md5Sum);
+
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+						String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+								+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+						metadata.put(URI_FIELD, URI);
+						metadata.put("size", size);
+
+						url = URI;
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+
+					}
+				} catch (Exception e) {
+					log.error("Something bad happen on inserting Record", e);
+					log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+				}
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,472 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 2);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 2, 4);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 4);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+					String md5Sum = null;
+					Integer size = 0;
+
+					if((record.getInputStream()!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						double timestamp = System.currentTimeMillis();
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", record.getFileMetadata().getObjectID());
+						metadata.put("mime", record.getFileMetadata().getMimeType());
+						metadata.put("originalObject", record.getFileMetadata().toJSON());
+						metadata.put("timestamp", timestamp);
+						metadata.put("md5Sum", md5Sum);
+
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+						String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+								+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+						metadata.put(URI_FIELD, URI);
+						metadata.put("size", size);
+
+						url = URI;
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+
+					}
+				} catch (Exception e) {
+					log.error("Something bad happen on inserting Record", e);
+					log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+				}
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,210 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), basePath, getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.3</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return currentSize - 1;
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,472 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+					String md5Sum = null;
+					Integer size = 0;
+
+					if((record.getInputStream()!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						double timestamp = System.currentTimeMillis();
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", record.getFileMetadata().getObjectID());
+						metadata.put("mime", record.getFileMetadata().getMimeType());
+						metadata.put("originalObject", record.getFileMetadata().toJSON());
+						metadata.put("timestamp", timestamp);
+						metadata.put("md5Sum", md5Sum);
+
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+						String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+								+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+						metadata.put(URI_FIELD, URI);
+						metadata.put("size", size);
+
+						url = URI;
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+
+					}
+				} catch (Exception e) {
+					log.error("Something bad happen on inserting Record", e);
+					log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+				}
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStore.java	(revision 45184)
@@ -0,0 +1,472 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.regex.Pattern;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.rmi.MetadataObjectRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFileNotFoundException;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions;
+
+
+/**
+ * The Class FileSystemObjectStore.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStore implements ObjectStore{
+
+	/**
+	 *
+	 */
+	private static final String URI_FIELD = "uri";
+
+
+	/**
+	 *
+	 */
+	private static final String FS_PATH_FIELD = "fsPath";
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStore.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The id. */
+	private final String id;
+
+	/** The interpretation. */
+	private final String interpretation;
+
+	/** The base path. */
+	private final String basePath;
+
+	/** The base uri. */
+	private  final String baseURI;
+
+	/** The mongo metadata. */
+	private final DBCollection mongoMetadata;
+
+
+
+	/**
+	 * Instantiates a new file system object store.
+	 *
+	 * @param identifier the identifier
+	 * @param interpretation the interpretation
+	 * @param basePath the base path
+	 * @param mongoMetadata the mongo metadata
+	 * @param baseURI the base uri
+	 */
+	public FileSystemObjectStore(final String identifier, final String interpretation, final String basePath,final DBCollection mongoMetadata, final String baseURI) {
+		this.id = identifier;
+		this.basePath = basePath;
+		this.interpretation = interpretation;
+		this.mongoMetadata = mongoMetadata;
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getId()
+	 */
+	@Override
+	public String getId() {
+		return this.id;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getInterpretation()
+	 */
+	@Override
+	public String getInterpretation() {
+		return this.interpretation;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feed(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feed(final Iterable<ObjectStoreRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+
+		if (records== null)
+			return 0;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter = 0 ;
+		for (ObjectStoreRecord record: records) {
+
+			String objectIdentifier = record.getFileMetadata().getObjectID();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+					log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+					try {
+						Files.createDirectories(objectStoreFilePath);
+						log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+						String md5Sum = null;
+						Integer size = 0;
+
+						if((record.getInputStream()!= null)){
+							Pair<String, Integer> infos = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+							md5Sum = infos.getKey();
+							size = infos.getValue();
+						}
+						if(!StringUtils.isEmpty(md5Sum)){
+							double timestamp = System.currentTimeMillis();
+							BasicDBObject metadata = new BasicDBObject();
+							metadata.put("id", record.getFileMetadata().getObjectID());
+							metadata.put("mime", record.getFileMetadata().getMimeType());
+							metadata.put("originalObject", record.getFileMetadata().toJSON());
+							metadata.put("timestamp", timestamp);
+							metadata.put("md5Sum", md5Sum);
+							metadata.put("size", size);
+
+							metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+							String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+									+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+							log.debug("saving metadata object to the collection: "+metadata.toString());
+							mongoMetadata.insert(metadata);
+							addedCounter ++;
+						}
+					} catch (Exception e) {
+						log.error("Something bad happen on inserting Record", e);
+						log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+					}
+				}
+			}
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedMetadataRecord(java.lang.Iterable, boolean)
+	 */
+	@Override
+	public int feedMetadataRecord(final Iterable<MetadataObjectRecord> records, final boolean incremental) throws ObjectStoreServiceException {
+		long timestamp = System.currentTimeMillis();
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		int addedCounter =0;
+		for (MetadataObjectRecord o : records) {
+			if ((o == null) || (o.getRecord() == null)) {
+				log.debug("Null object metadata record");
+				continue;
+			}
+			String objectIdentifier = o.getId();
+			if (!StringUtils.isEmpty(objectIdentifier)){
+				final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+				final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+				final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+				final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+				Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+				if (Files.notExists(objectStoreFilePath))
+				{
+
+
+					InputStream is = new ByteArrayInputStream(o.getRecord().getBytes());
+					String md5Sum = null;
+					Integer size = 0;
+					if((is!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(is, objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", o.getId());
+						metadata.put("mime", o.getMime());
+						metadata.put("timestamp", timestamp);
+						metadata.put("size", size);
+						try {
+							String URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId=" + URLEncoder.encode(o.getId(), "UTF-8");
+							metadata.put(URI_FIELD, URI);
+
+						} catch (UnsupportedEncodingException e) {
+							log.error("Got an exception during the feed ", e);
+						}
+						metadata.put("md5Sum", md5Sum);
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+						addedCounter ++;
+					}
+				}
+			}
+
+
+		}
+		return addedCounter;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#feedObjectRecord(eu.dnetlib.data.objectstore.modular.ObjectStoreRecord)
+	 */
+	@Override
+	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
+		if (record== null)
+			return null;
+
+		Path baseDirPath = FileSystems.getDefault().getPath(basePath).resolve(id);
+
+		if (!Files.exists(baseDirPath))
+			throw new ObjectStoreServiceException("Error can't feed objects because the folder "+baseDirPath +" does not exist");
+
+		String url = null;
+
+		String objectIdentifier = record.getFileMetadata().getObjectID();
+		if (!StringUtils.isEmpty(objectIdentifier)){
+			final String md5id = DnetXsltFunctions.md5(objectIdentifier);
+			final String firstLevel 	=  	StringUtils.substring(md5id, 0, 10);
+			final String secondLevel 	=  	StringUtils.substring(md5id, 10, 20);
+			final String thirdLevel		= 	StringUtils.substring(md5id, 20);
+			Path objectStoreFilePath =baseDirPath.resolve(firstLevel).resolve(secondLevel);
+
+			if (Files.notExists(objectStoreFilePath))
+			{
+
+				log.debug("The folder "+objectStoreFilePath.toString()+" doesn't exist! It should be created");
+
+				try {
+					Files.createDirectories(objectStoreFilePath);
+					log.debug("Creation of folder "+objectStoreFilePath+ " Done!");
+
+					String md5Sum = null;
+					Integer size = 0;
+
+					if((record.getInputStream()!= null)){
+						Pair<String, Integer> info = FileSystemUtility.saveAndGenerateMD5(record.getInputStream(), objectStoreFilePath.resolve(thirdLevel+".obj"));
+						md5Sum = info.getKey();
+						size = info.getValue();
+					}
+					if(!StringUtils.isEmpty(md5Sum)){
+						double timestamp = System.currentTimeMillis();
+						BasicDBObject metadata = new BasicDBObject();
+						metadata.put("id", record.getFileMetadata().getObjectID());
+						metadata.put("mime", record.getFileMetadata().getMimeType());
+						metadata.put("originalObject", record.getFileMetadata().toJSON());
+						metadata.put("timestamp", timestamp);
+						metadata.put("md5Sum", md5Sum);
+
+						metadata.put(FS_PATH_FIELD, objectStoreFilePath.resolve(thirdLevel+".obj").toAbsolutePath().toString());
+						String URI = getBaseURI() + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
+								+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
+						metadata.put(URI_FIELD, URI);
+						metadata.put("size", size);
+
+						url = URI;
+						log.debug("saving metadata object to the collection: "+metadata.toString());
+						mongoMetadata.insert(metadata);
+
+					}
+				} catch (Exception e) {
+					log.error("Something bad happen on inserting Record", e);
+					log.error("Record: "+new Gson().toJson(record.getFileMetadata()));
+				}
+			}
+			else {
+				DBObject query = QueryBuilder.start("id").is(record.getFileMetadata().getObjectID()).get();
+				DBObject resultQuery = mongoMetadata.findOne(query);
+				url =(String) resultQuery.get(URI_FIELD);
+			}
+		}
+		return url;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliver(java.lang.Long, java.lang.Long)
+	 */
+	@Override
+	public ResultSetListener deliver(final Long from, final Long until) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setFromDate(from);
+		resutlSet.setUntilDate(until);
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverIds(java.lang.Iterable)
+	 */
+	@Override
+	public ResultSetListener deliverIds(final Iterable<String> ids) throws ObjectStoreServiceException {
+		FileSystemObjectStoreResultSetListener resutlSet = new FileSystemObjectStoreResultSetListener();
+		resutlSet.setBaseURI(baseURI);
+		resutlSet.setMongoCollection(mongoMetadata);
+		resutlSet.setObjectStoreID(id);
+		resutlSet.setRecords(Lists.newArrayList(ids));
+		return resutlSet;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverObject(java.lang.String)
+	 */
+	@Override
+	public ObjectStoreFile deliverObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+		return ObjectStoreFileUtility.build(resultQuery, baseURI, objectId);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deliverStream(java.lang.String)
+	 */
+	@Override
+	public InputStream deliverStream(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject resultQuery = mongoMetadata.findOne(query);
+
+		if ((resultQuery == null) || !resultQuery.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found");
+
+		String pathStr = (String) resultQuery.get(FS_PATH_FIELD);
+		if (StringUtils.isEmpty(pathStr))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the path metadata is empty! ");
+
+		Path path = FileSystems.getDefault().getPath(pathStr);
+
+		if (!Files.exists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found the in the path: "+path);
+
+
+		try {
+			FileInputStream is = new FileInputStream(path.toFile());
+			return is;
+		} catch (FileNotFoundException e) {
+
+			throw new ObjectStoreServiceException("something wrong happened on getting data stream ",e);
+		}
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getSize()
+	 */
+	@Override
+	public int getSize() throws ObjectStoreServiceException {
+		return (int) mongoMetadata.getCount();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#deleteObject(java.lang.String)
+	 */
+	@Override
+	public void deleteObject(final String objectId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(objectId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(FS_PATH_FIELD))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the metadata db");
+		Path path =FileSystems.getDefault().getPath((String) response.get(FS_PATH_FIELD));
+		if(Files.notExists(path))
+			throw new ObjectStoreFileNotFoundException("Object with identifier :"+objectId+" not found in the assigned path "+path);
+
+		try {
+			Files.delete(path);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("An error occurs on delete file ",e);
+		}
+		mongoMetadata.remove(query);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#getObject(java.lang.String)
+	 */
+	@Override
+	public String getObject(final String recordId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").is(recordId).get();
+		DBObject response = mongoMetadata.findOne(query);
+		if ((response== null) || !response.containsField(URI_FIELD))
+			return null;
+		return  (String) response.get(URI_FIELD);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStore#existIDStartsWith(java.lang.String)
+	 */
+	@Override
+	public boolean existIDStartsWith(final String startId) throws ObjectStoreServiceException {
+		DBObject query = QueryBuilder.start("id").regex(Pattern.compile(startId)).get();
+		return  mongoMetadata.count(query)> 0;
+	}
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/deploy.info
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/deploy.info	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5/deploy.info	(revision 45184)
@@ -0,0 +1 @@
+{"type_source": "SVN", "goal": "package -U -T 4C source:jar", "url": "http://svn-public.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/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": "dnet-fs-objectstore"}
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.5
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreFileUtility.java	(revision 45184)
@@ -0,0 +1,80 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.mongodb.DBObject;
+
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * The Class ObjectStoreFileBuilder generates an objectStoreFile bean
+ *
+ */
+public class ObjectStoreFileUtility {
+
+	private static final int KB_SIZE = 1024;
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(ObjectStoreFileUtility.class);
+
+	/**
+	 * Builds the.
+	 *
+	 * @param input
+	 *            the input File
+	 * @param baseURI
+	 *            the base URI to associate to the metadata
+	 * @param objectStoreID
+	 *            The objectStoreID the input file
+	 * @return the object store file
+	 */
+
+	public static ObjectStoreFile build(final DBObject metadata, final String baseURI, final String objectStoreID) {
+
+		String originalFile = (String) metadata.get("originalObject");
+		ObjectStoreFile original = ObjectStoreFile.createObject(originalFile);
+		ObjectStoreFile newFile = new ObjectStoreFile();
+		newFile.setObjectID((String) metadata.get("id"));
+		newFile.setAccessProtocol(Protocols.HTTP);
+		newFile.setMimeType((String) metadata.get("mime"));
+		newFile.setMd5Sum((String) metadata.get("md5Sum"));
+		try{
+			newFile.setFileSizeKB(Integer.parseInt(metadata.get("size").toString()) / KB_SIZE);
+		} catch (Throwable e) {
+			log.error("Error on getting size",e);
+		}
+		if (originalFile != null) {
+			newFile.setMetadataRelatedID(original.getMetadataRelatedID());
+			if ((original.getDownloadedURL() == null) || (original.getDownloadedURL().length() == 0)) {
+				newFile.setDownloadedURL(original.getURI());
+			} else {
+				newFile.setDownloadedURL(original.getDownloadedURL());
+			}
+
+		}
+		try {
+			newFile.setURI(baseURI + "?objectStore=" + URLEncoder.encode(objectStoreID, "UTF-8") + "&objectId="
+					+ URLEncoder.encode(newFile.getObjectID(), "UTF-8"));
+		} catch (UnsupportedEncodingException e) {
+			log.error("Error on Build objectStoreFile ", e);
+		}
+		return newFile;
+	}
+
+	public static UnaryFunction<String, DBObject> asJSON(final String baseURI, final String objectStoreID) {
+		return new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject input) {
+				return build(input, baseURI, objectStoreID).toJSON();
+
+			}
+		};
+	}
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4/src/test/java/eu/dnetlib/data/objectstore/filesystem/ConfigurationTestConfig.java	(revision 45184)
@@ -0,0 +1,52 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.net.UnknownHostException;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.mongodb.DB;
+import com.mongodb.MongoClient;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ConfigurationTestConfig.
+ */
+@Configuration
+public class ConfigurationTestConfig {
+
+	/**
+	 * Mongo db.
+	 *
+	 * @return the db
+	 * @throws UnknownHostException the unknown host exception
+	 */
+	@Bean
+	public DB mongoDB() throws UnknownHostException{
+		MongoClient mongoClient = new MongoClient("localhost");
+		return mongoClient.getDB("objectStoreTest");
+
+	}
+
+
+	@Bean
+	public FileSystemObjectStoreDao fsObjectStoreDAO() {
+		FileSystemObjectStoreDao fileSystemObjectStoreDao = new FileSystemObjectStoreDao();
+
+		fileSystemObjectStoreDao.setObjectStoreRESTURI("http://www.objectstore.com");
+		return fileSystemObjectStoreDao;
+
+	}
+
+	/**
+	 * Fs utility.
+	 *
+	 * @return the file system utility
+	 */
+	@Bean
+	public FileSystemUtility fsUtility () {
+		return new FileSystemUtility();
+	}
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.4
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,210 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), basePath, getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreResultSetListener.java	(revision 45184)
@@ -0,0 +1,358 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.common.collect.Lists;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.enabling.resultset.ResultSet;
+import eu.dnetlib.enabling.resultset.ResultSetAware;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The listener interface for receiving fileSystemObjectStoreResultSet events.
+ * The class that is interested in processing a fileSystemObjectStoreResultSet
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addFileSystemObjectStoreResultSetListener<code> method. When
+ * the fileSystemObjectStoreResultSet event occurs, that object's appropriate
+ * method is invoked.
+ *
+ * @author sandro
+ */
+public class FileSystemObjectStoreResultSetListener implements ResultSetListener, ResultSetAware {
+
+
+	/** The Constant log. */
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreResultSetListener.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+	/** The from date. */
+	private Long fromDate;
+
+	/** The until date. */
+	private Long untilDate;
+
+	/** The records. */
+	private List<String> records;
+
+	/** The object store id. */
+	private String objectStoreID;
+
+
+	/** The mongo collection. */
+	private DBCollection mongoCollection;
+
+	/** The base uri. */
+	private String baseURI;
+
+	/** The current size. */
+	private int currentSize = -1;
+
+	/** The current cursor. */
+	private DBCursor currentCursor;
+
+	/** The cursor position. */
+	private long cursorPosition;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
+	 */
+	@Override
+	public List<String> getResult(final int from, final int to) {
+		log.debug(String.format("ObjectStoreId :%s, from: %d, to: %d", objectStoreID, from, to));
+		if (records != null) {
+			List<String> ids = Lists.newArrayList();
+			for (int i = from; i < to; i++) {
+				ids.add(records.get(i));
+			}
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(ids);
+			DBObject q = qBuilder.get();
+			DBCursor out = getMongoCollection().find(q);
+
+			List<DBObject> result = Lists.newArrayList();
+
+			while(out.hasNext()) {
+				result.add(out.next());
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		} else if ((fromDate != null) && (untilDate != null)) {
+			if ((currentCursor == null) || (cursorPosition > from)) {
+				createCurrentCursor();
+			}
+			while (cursorPosition < from) {
+				currentCursor.next();
+				cursorPosition++;
+			}
+			List<DBObject> result = Lists.newArrayList();
+
+			for (int i = from; i <= to; i++) {
+				if (currentCursor.hasNext()) {
+					result.add(currentCursor.next());
+					cursorPosition++;
+				}
+			}
+
+			return MappedCollection.listMap(result, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
+		}
+
+		throw new IllegalArgumentException("Missing parameters on Delivery must provide either from, to, or ObjectStoreIDs");
+	}
+
+	/**
+	 * Creates the current cursor.
+	 */
+	private void createCurrentCursor() {
+		BasicDBObject query = new BasicDBObject();
+		query.put("$gt", fromDate.doubleValue());
+		query.put("$lt", untilDate.doubleValue());
+		if (currentCursor != null) {
+			currentCursor.close();
+		}
+		currentCursor = getMongoCollection().find(new BasicDBObject("timestamp", query)).sort(new BasicDBObject("_id", 1));
+		cursorPosition = 1;
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
+	 */
+	@Override
+	public int getSize() {
+		if (currentSize == -1) {
+			currentSize = calculateSize();
+		}
+		return Math.max(0, currentSize - 1);
+	}
+
+	/**
+	 * Calculate size.
+	 *
+	 * @return the int
+	 */
+	private int calculateSize() {
+		if (records != null) {
+			QueryBuilder qBuilder = QueryBuilder.start("id").in(records);
+			DBObject q = qBuilder.get();
+			return (int) getMongoCollection().count(q);
+		} else if ((fromDate != null) && (untilDate != null)) {
+			BasicDBObject query = new BasicDBObject();
+			query.put("$gt", fromDate);
+			query.put("$lt", untilDate);
+			return (int) getMongoCollection().count(new BasicDBObject("timestamp", query));
+		}
+		return 0;
+	}
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
+	 */
+	@Override
+	public void setResultSet(final ResultSet resultSet) {
+		resultSet.close();
+	}
+
+
+	/**
+	 * Gets the from date.
+	 *
+	 * @return the fromDate
+	 */
+	public Long getFromDate() {
+		return fromDate;
+	}
+
+
+	/**
+	 * Sets the from date.
+	 *
+	 * @param fromDate the fromDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setFromDate(final Long fromDate) {
+		this.fromDate = fromDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the until date.
+	 *
+	 * @return the untilDate
+	 */
+	public Long getUntilDate() {
+		return untilDate;
+	}
+
+
+	/**
+	 * Sets the until date.
+	 *
+	 * @param untilDate the untilDate to set
+	 */
+	public FileSystemObjectStoreResultSetListener setUntilDate(final Long untilDate) {
+		this.untilDate = untilDate;
+		return this;
+	}
+
+
+	/**
+	 * Gets the records.
+	 *
+	 * @return the records
+	 */
+	public List<String> getRecords() {
+		return records;
+	}
+
+
+	/**
+	 * Sets the records.
+	 *
+	 * @param records the records to set
+	 */
+	public void setRecords(final List<String> records) {
+		this.records = records;
+	}
+
+
+	/**
+	 * Gets the object store id.
+	 *
+	 * @return the objectStoreID
+	 */
+	public String getObjectStoreID() {
+		return objectStoreID;
+	}
+
+
+	/**
+	 * Sets the object store id.
+	 *
+	 * @param objectStoreID the objectStoreID to set
+	 */
+	public void setObjectStoreID(final String objectStoreID) {
+		this.objectStoreID = objectStoreID;
+	}
+
+
+
+
+
+	/**
+	 * Gets the base uri.
+	 *
+	 * @return the baseURI
+	 */
+	public String getBaseURI() {
+		return baseURI;
+	}
+
+
+	/**
+	 * Sets the base uri.
+	 *
+	 * @param baseURI the baseURI to set
+	 */
+	public void setBaseURI(final String baseURI) {
+		this.baseURI = baseURI;
+	}
+
+
+	/**
+	 * Gets the current size.
+	 *
+	 * @return the currentSize
+	 */
+	public int getCurrentSize() {
+		return currentSize;
+	}
+
+
+	/**
+	 * Sets the current size.
+	 *
+	 * @param currentSize the currentSize to set
+	 */
+	public void setCurrentSize(final int currentSize) {
+		this.currentSize = currentSize;
+	}
+
+
+	/**
+	 * Gets the current cursor.
+	 *
+	 * @return the currentCursor
+	 */
+	public DBCursor getCurrentCursor() {
+		return currentCursor;
+	}
+
+
+	/**
+	 * Sets the current cursor.
+	 *
+	 * @param currentCursor the currentCursor to set
+	 */
+	public void setCurrentCursor(final DBCursor currentCursor) {
+		this.currentCursor = currentCursor;
+	}
+
+
+	/**
+	 * Gets the cursor position.
+	 *
+	 * @return the cursorPosition
+	 */
+	public long getCursorPosition() {
+		return cursorPosition;
+	}
+
+
+	/**
+	 * Sets the cursor position.
+	 *
+	 * @param cursorPosition the cursorPosition to set
+	 */
+	public void setCursorPosition(final long cursorPosition) {
+		this.cursorPosition = cursorPosition;
+	}
+
+	/**
+	 * Gets the mongo collection.
+	 *
+	 * @return the mongo collection
+	 */
+	public DBCollection getMongoCollection() {
+		return mongoCollection;
+	}
+
+	/**
+	 * Sets the mongo collection.
+	 *
+	 * @param mongoCollection the new mongo collection
+	 */
+	public void setMongoCollection(final DBCollection mongoCollection) {
+		this.mongoCollection = mongoCollection;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/main/java/eu/dnetlib/data/objectstore/filesystem/MongoFSOptionsFactory.java	(revision 45184)
@@ -0,0 +1,37 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.FactoryBean;
+
+import com.mongodb.MongoOptions;
+
+public class MongoFSOptionsFactory implements FactoryBean<MongoOptions> {
+
+	private int connectionsPerHost;
+
+	@Override
+	public MongoOptions getObject() throws BeansException {
+		MongoOptions opts = new MongoOptions();
+		opts.connectionsPerHost = connectionsPerHost;
+		return opts;
+	}
+
+	@Override
+	public Class<MongoOptions> getObjectType() {
+		return MongoOptions.class;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		return false;
+	}
+
+	public int getConnectionsPerHost() {
+		return connectionsPerHost;
+	}
+
+	public void setConnectionsPerHost(final int connectionsPerHost) {
+		this.connectionsPerHost = connectionsPerHost;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3/src/test/java/eu/dnetlib/data/objectstore/filesystem/InputIterator.java	(revision 45184)
@@ -0,0 +1,80 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Iterator;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+
+
+/**
+ * @author sandro
+ *
+ */
+public class InputIterator implements Iterable<ObjectStoreRecord>, Iterator<ObjectStoreRecord> {
+
+	private int counter = 0;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#hasNext()
+	 */
+	@Override
+	public boolean hasNext() {
+
+		return counter<100;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#next()
+	 */
+	@Override
+	public ObjectStoreRecord next() {
+		try {
+			counter ++;
+			ObjectStoreRecord record = new ObjectStoreRecord();
+			ObjectStoreFile fileMetadata = new ObjectStoreFile();
+			fileMetadata.setAccessProtocol(Protocols.File_System);
+			fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+			fileMetadata.setObjectID("Oggetto_"+counter);
+			fileMetadata.setMimeType("Application/pdf");
+			System.out.println("Aggiungo Elemento "+counter);
+			record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+			record.setFileMetadata(fileMetadata );
+			return record;
+		} catch (FileNotFoundException e) {
+			return null;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.util.Iterator#remove()
+	 */
+	@Override
+	public void remove() {
+		// TODO Auto-generated method stub
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * @see java.lang.Iterable#iterator()
+	 */
+	@Override
+	public Iterator<ObjectStoreRecord> iterator() {
+		counter =0;
+		return this;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.3
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemObjectStoreDao.java	(revision 45184)
@@ -0,0 +1,212 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.IOException;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBObject;
+import com.mongodb.QueryBuilder;
+
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.miscutils.collections.MappedCollection;
+import eu.dnetlib.miscutils.functional.UnaryFunction;
+
+/**
+ * @author sandro
+ *
+ */
+public class FileSystemObjectStoreDao implements ObjectStoreDao {
+
+	private static final Log log = LogFactory.getLog(FileSystemObjectStoreDao.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	private static final String INTERPRETATION_FIELD = "interpretation";
+
+	private final static String OBJECTSTORE_METADATA_NAME_FIELD = "metadataObjectStore";
+
+	private final static String OBJECTSTORE_ID_FIELD = "obsId";
+
+	private final static String BASE_PATH_FIELD = "basePath";
+
+	@Resource(name="objectstoreMongoDB")
+	private DB db;
+
+	@Autowired
+	private FileSystemUtility fsUtility;
+
+	private boolean upsert;
+
+	private String objectStoreRESTURI;
+
+
+
+	/**
+	 * {@inheritDoc}
+	 * @throws ObjectStoreServiceException
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#getObjectStore(java.lang.String)
+	 */
+	@Override
+	public ObjectStore getObjectStore(final String obsId) throws ObjectStoreServiceException {
+		String currentId =obsId.substring(0, 36);
+		String find_id = obsId;
+		if(find_id.length()==36) {
+			find_id+="_T2JqZWN0U3RvcmVEU1Jlc291cmNlcy9PYmplY3RTdG9yZURTUmVzb3VyY2VUeXBl";
+		}
+
+
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(find_id).get();
+		log.debug("QUERY :"+query.toString());
+		DBObject resultQuery = coll.findOne(query);
+		log.debug("result "+resultQuery);
+
+		if (resultQuery.containsField(BASE_PATH_FIELD) &&  StringUtils.isEmpty(resultQuery.get(BASE_PATH_FIELD).toString()))
+			throw new ObjectStoreServiceException("Can't Get Objectstore, the metadata doesn't contains information about which is the basepath");
+		return new FileSystemObjectStore(currentId, resultQuery.get("interpretation").toString(), resultQuery.get(BASE_PATH_FIELD).toString(), getDb().getCollection(currentId), objectStoreRESTURI);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#listObjectStores()
+	 */
+	@Override
+	public List<String> listObjectStores() {
+		DBCollection metadata = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		return MappedCollection.listMap(metadata.find(), new UnaryFunction<String, DBObject>() {
+
+			@Override
+			public String evaluate(final DBObject object) {
+				return (String) object.get(OBJECTSTORE_ID_FIELD);
+			}
+		});
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#createObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean createObjectStore(final String obsId, final String interpretation, final String basePath) throws ObjectStoreServiceException {
+
+		log.debug(String.format("Create object Store method\n\t Id:%s  Interpretation:%s BasePath : %s", obsId, interpretation, basePath) );
+
+		if (StringUtils.isEmpty(basePath)) throw new ObjectStoreServiceException("Can't Create the object Store The base path cannot be null");
+		Path path = FileSystems.getDefault().getPath(basePath);
+		if (!Files.exists(path) || !Files.isDirectory(path))
+			throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + basePath + "' doesn't exist or it is not a folder");
+		try {
+			String currentobsId = obsId.substring(0, 36);
+			log.debug("Cleaned objectStore Id "+currentobsId);
+			if (Files.exists(path.resolve(currentobsId)))
+				throw new ObjectStoreServiceException("Can't Create the object Store The base path: '" + path.resolve(currentobsId) + "' already exists");
+			Files.createDirectory(path.resolve(currentobsId));
+			DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+			final BasicDBObject obj = new BasicDBObject();
+			obj.put(OBJECTSTORE_ID_FIELD, obsId);
+			obj.put(INTERPRETATION_FIELD, interpretation);
+			obj.put(BASE_PATH_FIELD, basePath);
+			coll.save(obj);
+			DBCollection objectStore = getDb().getCollection(currentobsId);
+			objectStore.createIndex(new BasicDBObject("id", 1));
+			return true;
+
+		} catch (Throwable e) {
+			throw new ObjectStoreServiceException("Can't Create the object Store id: '" + obsId, e);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#updateObjectStore(java.lang.String, java.lang.String)
+	 */
+	@Override
+	public boolean updateObjectStore(final String obsId, final String interpretation) {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		final BasicDBObject obj = new BasicDBObject();
+		obj.put(OBJECTSTORE_ID_FIELD, obsId);
+		obj.put(INTERPRETATION_FIELD, interpretation);
+		coll.update(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId), obj, true, false);
+		coll.save(obj);
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 *
+	 * @throws ObjectStoreServiceException
+	 * @see eu.dnetlib.data.objectstore.modular.connector.ObjectStoreDao#deleteObjectStore(java.lang.String)
+	 */
+	@Override
+	public boolean deleteObjectStore(final String obsId) throws ObjectStoreServiceException {
+		DBCollection coll = getDb().getCollection(OBJECTSTORE_METADATA_NAME_FIELD);
+		DBObject query = QueryBuilder.start(OBJECTSTORE_ID_FIELD).is(obsId).get();
+		DBObject resultQuery = coll.findOne(query);
+		String basePath = resultQuery.get(BASE_PATH_FIELD).toString();
+		if (StringUtils.isEmpty(basePath))
+			throw new ObjectStoreServiceException("Can't Delete Objectstore, the metadata doesn't contains information about which is the basepath");
+
+		String currentobsId = obsId.substring(0, 36);
+		Path basePathFS = FileSystems.getDefault().getPath(basePath, currentobsId);
+		if (Files.exists(basePathFS)) {
+
+		} else throw new ObjectStoreServiceException("Can't Delete Objectstore the path of the objectStore doesn't exists :" + basePathFS);
+
+		try {
+			fsUtility.deleteFolderRecursive(basePathFS);
+		} catch (IOException e) {
+			throw new ObjectStoreServiceException("Can't Delete Objectstore ", e);
+		}
+		coll.remove(new BasicDBObject(OBJECTSTORE_ID_FIELD, obsId));
+
+
+		getDb().getCollection(obsId).drop();
+		return true;
+	}
+
+
+	public boolean isUpsert() {
+		return upsert;
+	}
+
+	public void setUpsert(final boolean upsert) {
+		this.upsert = upsert;
+	}
+
+	public String getObjectStoreRESTURI() {
+		return objectStoreRESTURI;
+	}
+
+	public void setObjectStoreRESTURI(final String objectStoreRESTURI) {
+		this.objectStoreRESTURI = objectStoreRESTURI;
+	}
+
+	public DB getDb() {
+		return db;
+	}
+
+	public void setDb(final DB db) {
+		this.db = db;
+	}
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2/src/test/java/eu/dnetlib/data/objectstore/filesystem/ObjectStoreServiceDAOTest.java	(revision 45184)
@@ -0,0 +1,115 @@
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.google.common.collect.Lists;
+import com.mongodb.DB;
+
+import eu.dnetlib.data.objectstore.modular.ObjectStoreRecord;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreFile;
+import eu.dnetlib.data.objectstore.rmi.ObjectStoreServiceException;
+import eu.dnetlib.data.objectstore.rmi.Protocols;
+import eu.dnetlib.enabling.resultset.ResultSetListener;
+
+
+
+
+/**
+ * @author sandro
+ *
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ConfigurationTestConfig.class)
+public class ObjectStoreServiceDAOTest {
+	private static final Log log = LogFactory.getLog(ObjectStoreServiceDAOTest.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+	@Autowired
+	private FileSystemObjectStoreDao objectStoreDAO;
+
+	@Autowired
+	private DB db;
+
+
+
+	@Test
+	@Ignore
+	public void test () throws ObjectStoreServiceException, FileNotFoundException {
+
+		String obsID ="testOBJECTSTORE111111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+		List<ObjectStoreRecord> input = Lists.newArrayList();
+		objectStoreDAO.getObjectStore(obsID).feed(new InputIterator(),true);
+		//objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+	@Test
+	@Ignore
+	public void testGetStream() throws Exception {
+		String obsID ="testOBJECTSTORE111111111111111111111";
+
+		System.out.println(objectStoreDAO.getObjectStore(obsID).deliverObject("Oggetto_2").toJSON());
+
+
+		ResultSetListener rs = objectStoreDAO.getObjectStore(obsID).deliver(0L, System.currentTimeMillis());
+
+
+
+		for (int i=1; i< (rs.getSize()/10); ) {
+
+			int from  = i;
+			int to = Math.max(rs.getSize(), i*10);
+
+			List<String> data = rs.getResult(from, to);
+
+			for (String s: data) {
+				System.out.println(s);
+			}
+
+			i= to ;
+
+		}
+
+	}
+
+
+	@Test
+	@Ignore
+	public void testFeedRecord() throws ObjectStoreServiceException, FileNotFoundException {
+		String obsID ="testOBJECTSTORE211111111111111111111";
+		objectStoreDAO.createObjectStore(obsID, "test", "/data/home/sandro/objData");
+
+		ObjectStoreRecord record = new ObjectStoreRecord();
+		ObjectStoreFile fileMetadata = new ObjectStoreFile();
+		fileMetadata.setAccessProtocol(Protocols.File_System);
+		fileMetadata.setDownloadedURL("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setURI("file:///data/home/sandro/Book/arduino_cookbook.pdf");
+		fileMetadata.setObjectID("Oggetto_1");
+		fileMetadata.setMimeType("Application/pdf");
+		record.setInputStream(new FileInputStream(new File("/data/home/sandro/Book/arduino_cookbook.pdf")));
+		record.setFileMetadata(fileMetadata );
+		String url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		url = objectStoreDAO.getObjectStore(obsID).feedObjectRecord(record);
+		System.out.println(url);
+		objectStoreDAO.deleteObjectStore(obsID);
+	}
+
+
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.2
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.1</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/xml
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.xml
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/xml
\ No newline at end of property
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.1
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/pom.xml
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/pom.xml	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/pom.xml	(revision 45184)
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>eu.dnetlib</groupId>
+    <artifactId>dnet-parent</artifactId>
+    <version>1.0.0</version>
+  </parent>
+  <groupId>eu.dnetlib</groupId>
+  <artifactId>dnet-fs-objectstore</artifactId>
+  <version>1.0.0</version>
+  <scm>
+	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0</developerConnection>
+	</scm>
+  <dependencies>
+  <dependency>
+			<groupId>eu.dnetlib</groupId>
+			<artifactId>dnet-modular-objectstore-service</artifactId>
+			<version>[4.0.0,5.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>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>${junit.version}</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mongodb</groupId>
+			<artifactId>mongo-java-driver</artifactId>
+			<version>${mongodb.driver.version}</version>
+		</dependency>
+  
+  </dependencies>
+</project>
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/resources/eu/dnetlib/data/objectstore/modular/FS/applicationContext-FS-objectstore.properties	(revision 45184)
@@ -0,0 +1,7 @@
+services.objectStore.mongodb.host=localhost
+services.objectStore.mongodb.port=27017
+services.objectStore.mongodb.db=objectStore
+services.objectStore.mongodb.connectionsPerHost=20
+services.objectStore.mongodb.upsert=true
+services.objectStore.RESTURI=http://${container.hostname}:${container.port}/${container.context}/mvc/objectStore/retrieve.do
+services.objectstore.dao=fSObjectstoreDao
\ No newline at end of file
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0/src/main/java/eu/dnetlib/data/objectstore/filesystem/FileSystemUtility.java	(revision 45184)
@@ -0,0 +1,82 @@
+/**
+ *
+ */
+package eu.dnetlib.data.objectstore.filesystem;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import eu.dnetlib.miscutils.collections.Pair;
+
+
+
+/**
+ * The Class FileSystemUtility.
+ *
+ * @author sandro
+ */
+public class FileSystemUtility {
+
+	private static final Log log = LogFactory.getLog(FileSystemUtility.class); // NOPMD by marko on 11/24/08 5:02 PM
+
+
+
+	public static Pair<String, Integer> saveAndGenerateMD5(final InputStream inputStream, final Path filePath ){
+		if(inputStream==null) return null;
+
+		String md5 = null;
+		int size =0;
+		try {
+			Files.copy(inputStream, filePath);
+
+			FileInputStream fis = new FileInputStream(filePath.toFile());
+			md5 = org.apache.commons.codec.digest.DigestUtils.md5Hex(fis);
+			fis.close();
+			size =(int) Files.size(filePath);
+
+		} catch (IOException e1) {
+			log.error(e1);
+		}
+
+		return new Pair<String, Integer>(md5, size );
+	}
+
+
+
+	/**
+	 * Delete folder recursive.
+	 *
+	 * @param path the path
+	 * @return true, if successful
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public boolean deleteFolderRecursive(final Path path) throws IOException {
+
+		Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
+			@Override
+			public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
+				Files.delete(file);
+				return FileVisitResult.CONTINUE;
+			}
+
+			@Override
+			public FileVisitResult postVisitDirectory(final Path dir, final IOException exc) throws IOException {
+				Files.delete(dir);
+				return FileVisitResult.CONTINUE;
+			}
+		});
+		return true;
+	}
+
+
+
+}
Index: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0
===================================================================
--- modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0	(nonexistent)
+++ modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0	(revision 45184)

Property changes on: modules/dnet-fs-objectstore/tags/dnet-fs-objectstore-1.0.0
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,5 ##
+.classpath
+.settings
+target
+.project
+
