Index: modules/dnet-efg/trunk/src/main/java/eu/dnetlib/efg/thumbnails/ThumbnailController.java
===================================================================
--- modules/dnet-efg/trunk/src/main/java/eu/dnetlib/efg/thumbnails/ThumbnailController.java	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/java/eu/dnetlib/efg/thumbnails/ThumbnailController.java	(revision 46802)
@@ -0,0 +1,100 @@
+package eu.dnetlib.efg.thumbnails;
+
+import eu.dnetlib.data.objectstore.connector.ObjectStore;
+import eu.dnetlib.data.objectstore.gridFS.GridFSObjectStore;
+import eu.dnetlib.data.objectstore.gridFS.GridFSObjectstoreDaoImpl;
+import eu.dnetlib.enabling.locators.UniqueServiceLocator;
+import eu.dnetlib.miscutils.collections.Pair;
+import eu.dnetlib.rmi.data.ObjectStoreFile;
+import eu.dnetlib.rmi.enabling.ISLookUpService;
+import org.apache.commons.io.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by sandro on 4/12/17.
+ */
+@Controller
+public class ThumbnailController {
+
+
+    @Autowired
+    UniqueServiceLocator serviceLocator;
+
+    @Autowired
+    GridFSObjectstoreDaoImpl objectstoreDao;
+
+
+    private Map<String, String> objectStoresThumbnail;
+
+
+    @RequestMapping(value = "/ui/thumbnail/objectStoresThumbnail")
+    @ResponseBody
+    public Map<String, String> getObjectStoresThumbnail(ModelMap map) throws Exception {
+        if (objectStoresThumbnail == null) {
+            createObjectStoreThumbnail();
+        }
+        return objectStoresThumbnail;
+    }
+
+
+    @RequestMapping(value = "/ui/thumbnail/getThumbnail")
+    public void getThumbnail(final HttpServletResponse response, @RequestParam(name = "metadataId") final String metadataId, @RequestParam(name = "imageSize") final int imageSize, @RequestParam(name = "imageType") final String type) throws Exception {
+        if (imageSize != 96 && imageSize != 250) throw new Exception("Image size not supported!");
+        if (objectStoresThumbnail == null) {
+            createObjectStoreThumbnail();
+        }
+        final GridFSObjectStore objectStore = (GridFSObjectStore) objectstoreDao.getObjectStore(objectStoresThumbnail.get(String.format("thumb%d", imageSize == 250 ? 256 : imageSize)));
+
+        final ObjectStoreFile objectStoreFile = objectStore.deliverObjectFromMetadataIdentifier(metadataId);
+        InputStream inputStream = null;
+        if (objectStoreFile == null) {
+            inputStream = getClass().getResourceAsStream(String.format("/eu/dnetlib/thumbnail/NF%s_%d.jpg", type.toLowerCase(), imageSize));
+        } else {
+            inputStream = objectStore.deliverStream(objectStoreFile.getObjectID());
+        }
+        if (inputStream != null) {
+            try {
+                final ServletOutputStream outputStream = response.getOutputStream();
+                IOUtils.copy(inputStream, outputStream);
+            } finally {
+                inputStream.close();
+            }
+        }
+    }
+
+
+    private void createObjectStoreThumbnail() throws Exception {
+        final String query = "for $x in collection('/db/DRIVER/ObjectStoreDSResources/ObjectStoreDSResourceType')\n" +
+                "where  $x//OBJECTSTORE_INTERPRETATION = 'thumb96' or $x//OBJECTSTORE_INTERPRETATION = 'thumb256' \n" +
+                " return concat($x//OBJECTSTORE_INTERPRETATION, '<-->',   $x//RESOURCE_IDENTIFIER/@value/string())";
+        final ISLookUpService lookUpService = serviceLocator.getService(ISLookUpService.class);
+        final List<String> queryResult = lookUpService.quickSearchProfile(query);
+        if (queryResult == null) {
+            throw new Exception("Missing objectStore Thumbnail");
+        }
+        objectStoresThumbnail = new HashMap<>();
+        queryResult.stream().forEach(item -> {
+            final String[] splitString = item.split("<-->");
+            if (splitString == null || splitString.length != 2)
+                throw new RuntimeException("Error wrong splitting");
+            objectStoresThumbnail.put(splitString[0], splitString[1]);
+
+        });
+
+
+    }
+
+}
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_250.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_250.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_250.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_250.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_250.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_96.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_96.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_96.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_96.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_96.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_96.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_96.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_96.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_96.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_96.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_96.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_96.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_96.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_96.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFvideo_96.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_250.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_250.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_250.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_250.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFimage_250.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_250.jpg
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_250.jpg
===================================================================
--- modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_250.jpg	(nonexistent)
+++ modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_250.jpg	(revision 46802)

Property changes on: modules/dnet-efg/trunk/src/main/resources/eu/dnetlib/thumbnail/NFtext_250.jpg
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: modules/dnet-efg/trunk/pom.xml
===================================================================
--- modules/dnet-efg/trunk/pom.xml	(revision 46801)
+++ modules/dnet-efg/trunk/pom.xml	(revision 46802)
@@ -49,5 +49,13 @@
 		</dependency>
 
 
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>javax.servlet-api</artifactId>
+			<version>LATEST</version>
+			<scope>provided</scope>
+		</dependency>
+
+
 	</dependencies>
 </project>
