You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/06/22 13:13:30 UTC

svn commit: r1352846 [1/2] - in /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub: ./ bundlelist/src/main/bundles/ parent/ store/file/src/main/java/org/apache/stanbol/contenthub/store/file/ store/file/src/main/java/org/apache/stan...

Author: suat
Date: Fri Jun 22 11:13:27 2012
New Revision: 1352846

URL: http://svn.apache.org/viewvc?rev=1352846&view=rev
Log:
STANBOL-498:
-unit tests for file store
-RESTful interfaces are updated according to new storage functionality. Content items are submitted under directly to the store endpoint (/store) without giving a specific index name
-revision retrieval policy updated such that all changes for revisions are returned as a whole
-added option for specifying mimetype during deserialization

Added:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/GraphDeserializerProvider.java
      - copied, changed from r1351229, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedGraphDeserializerProvider.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/MGraphDeserializerProvider.java
      - copied, changed from r1351229, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedMGraphDeserializerProvider.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/   (with props)
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartDeserializerTest.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartSerializerTest.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileRevisionManagerTest.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreDBManagerTest.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreTest.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/test/
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/copy_icon_16.png   (with props)
Removed:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedGraphDeserializerProvider.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedMGraphDeserializerProvider.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/edit_icon_16.png
Modified:
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/bundlelist/src/main/bundles/list.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/parent/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileRevisionManager.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartDeserializer.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartSerializer.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/pom.xml
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/style/contenthub.css
    incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/storeRestApi.ftl

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/bundlelist/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/bundlelist/src/main/bundles/list.xml?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/bundlelist/src/main/bundles/list.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/bundlelist/src/main/bundles/list.xml Fri Jun 22 11:13:27 2012
@@ -24,8 +24,33 @@
     </bundle>
     <bundle>
       <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.contenthub.store.solr</artifactId>
+      <version>0.10.0-incubating-SNAPSHOT</version>
+    </bundle>
+    <bundle>
+      <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.contenthub.web</artifactId>
       <version>0.10.0-incubating-SNAPSHOT</version>
     </bundle>
+    <bundle>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.contenthub.test</artifactId>
+      <version>0.10.0-incubating-SNAPSHOT</version>
+    </bundle>
+<!--     <bundle> -->
+<!--       <groupId>org.apache.stanbol</groupId> -->
+<!--       <artifactId>org.apache.stanbol.contenthub.index</artifactId> -->
+<!--       <version>0.10.0-incubating-SNAPSHOT</version> -->
+<!--     </bundle> -->
+    <bundle>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.junit.core</artifactId>
+      <version>1.0.6</version>
+    </bundle>
+    <bundle>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.commons.json</artifactId>
+      <version>2.0.6</version>
+    </bundle>
   </startLevel>
 </bundles>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/parent/pom.xml?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/parent/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/parent/pom.xml Fri Jun 22 11:13:27 2012
@@ -21,6 +21,7 @@
   </parent>
 
   <artifactId>org.apache.stanbol.contenthub.parent</artifactId>
+  <version>0.10.0-incubating-SNAPSHOT</version>
   <packaging>pom</packaging>
 
   <name>Apache Stanbol Contenthub parent POM</name>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/pom.xml?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/pom.xml Fri Jun 22 11:13:27 2012
@@ -28,7 +28,7 @@
 
   <scm>
     <connection>
-  		scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/
+      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/
     </connection>
     <developerConnection>
       scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/contenthub/
@@ -39,11 +39,12 @@
     <module>parent</module>
     <module>servicesapi</module>
     <module>store/file</module>
-<!--     <module>index</module> -->
+<!--     <module>store/solr</module> -->
 <!--     <module>search</module> -->
     <module>web</module>
     <module>bundlelist</module>
-<!--     <module>ldpath</module> -->
+<!--     <module>index</module> -->
+    <module>test</module>
   </modules>
 
 </project>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileRevisionManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileRevisionManager.java?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileRevisionManager.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileRevisionManager.java Fri Jun 22 11:13:27 2012
@@ -59,7 +59,10 @@ public class FileRevisionManager {
                                                   + " SET revision=? WHERE id=?";
 
     private static final String SELECT_CHANGES = "SELECT id, revision FROM " + REVISION_TABLE_NAME
-                                                 + " WHERE revision > ? ORDER BY revision ASC OFFSET ? ROWS";
+                                                 + " WHERE revision > ? ORDER BY revision ASC";
+
+    private static final String SELECT_MORECHANGES = "SELECT id, revision FROM " + REVISION_TABLE_NAME
+                                                     + " WHERE revision >= ? ORDER BY revision ASC";
 
     @Reference
     FileStoreDBManager dbManager;
@@ -128,22 +131,18 @@ public class FileRevisionManager {
     }
 
     /**
-     * Returns the updates after the given revision number. It returns at most <code>batchSize</code> number
-     * of changes within the returned {@link ChangeSet} object starting from the given <code>offset</code>.
-     * This method does not necessarily return the all changes for the given revision number. If there are
-     * more changes than the batch size for the given version, only batch size number of changes are returned.
-     * Other changes must be obtained by giving the same revision and the suitable offset.
+     * Returns the updates after the given revision number. If the total size of revisions after the given
+     * revision number fit in <code>batchSize</code>, result size is <code>batchSize</code> within the
+     * returned {@link ChangeSet} object; else results are greater than <code>batchSize</code>
      * 
      * @param revision
      *            Starting revision number for the returned {@link ChangeSet}
-     * @param offset
-     *            Starting number of the changes as of the given <code>revision</code>.
      * @param batchSize
      *            Maximum number of changes to be returned
      * @return a {@link ChangeSet} including the changes in the store
      * @throws StoreException
      */
-    public ChangeSet getChanges(long revision, int offset, int batchSize) throws StoreException {
+    public ChangeSet getChanges(long revision, int batchSize) throws StoreException {
         ChangeSetImpl changes = new ChangeSetImpl();
 
         // get connection
@@ -156,21 +155,58 @@ public class FileRevisionManager {
             ps = con.prepareStatement(SELECT_CHANGES, ResultSet.TYPE_SCROLL_INSENSITIVE,
                 ResultSet.CONCUR_READ_ONLY);
             ps.setLong(1, revision);
-            ps.setLong(2, offset);
-            ps.setMaxRows(batchSize);
+            ps.setMaxRows(batchSize + 1);
             rs = ps.executeQuery();
 
-            // set changed uris
             Set<UriRef> changedUris = new LinkedHashSet<UriRef>();
-            while (rs.next()) {
-                changedUris.add(new UriRef(rs.getString(1)));
+
+            if(!rs.first()){
+                changes.setChangedUris(changedUris);
+                changes.setFrom(-1);
+                changes.setTo(-1);
+                return changes;
+            }
+            if (rs.absolute(batchSize + 1)) {
+                long lastRowRevision = rs.getLong(2);
+                rs.previous();
+                long nextToLastRowRevision = rs.getLong(2);
+                rs.beforeFirst();
+                // if we are in the middle of a revision, add all changes in that revision to changedUris
+                if (lastRowRevision == nextToLastRowRevision) {
+                    ps = con.prepareStatement(SELECT_MORECHANGES, ResultSet.TYPE_SCROLL_INSENSITIVE,
+                        ResultSet.CONCUR_READ_ONLY);
+                    ps.setLong(1, revision);
+                    rs = ps.executeQuery();
+
+                    while (rs.next()) {
+                        changedUris.add(new UriRef(rs.getString(1)));
+                    }
+                } else {
+                    while (rs.next()) {
+                        if (rs.isLast()) {
+                            break;
+                        }
+                        changedUris.add(new UriRef(rs.getString(1)));
+                    }
+                }
+
+            } else {
+                rs.beforeFirst();
+                while (rs.next()) {
+                    changedUris.add(new UriRef(rs.getString(1)));
+                }
             }
+
             changes.setChangedUris(changedUris);
             // set minimum and maximum revision numbers of the change set
+            if (rs.isLast()) {
+                rs.previous();
+            } else {
+                rs.last();
+            }
+            changes.setTo(rs.getLong(2));
             rs.first();
             changes.setFrom(rs.getLong(2));
-            rs.last();
-            changes.setTo(rs.getLong(2));
 
         } catch (SQLException e) {
             log.error("Failed to get changes", e);
@@ -182,5 +218,4 @@ public class FileRevisionManager {
         }
         return changes;
     }
-
 }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/FileStore.java Fri Jun 22 11:13:27 2012
@@ -46,6 +46,8 @@ import org.apache.clerezza.rdf.core.UriR
 import org.apache.commons.io.IOUtils;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
@@ -63,9 +65,9 @@ import org.apache.stanbol.enhancer.servi
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 import org.apache.stanbol.enhancer.servicesapi.impl.StreamSource;
 import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
-import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import org.osgi.framework.Constants;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -89,13 +91,20 @@ import org.slf4j.LoggerFactory;
  * the {@link ContentItem}s. Additional metadata is also stored in the Apache Derby database.
  * </p>
  * 
+ * To be able to use other {@link Store} implementations rather than this, the
+ * {@link Constants#SERVICE_RANKING} property of other implementations should be set higher than of this one.
+ * 
  * @author suat
  * @author meric
  * 
  */
-@Component(immediate = false)
+@Component(immediate = true)
 @Service
+@Properties(value = {@Property(name = Constants.SERVICE_RANKING, intValue = 100)})
 public class FileStore implements Store {
+    // @Property(name = Constants.SERVICE_RANKING)
+    // private int ranking;
+
     public static final String RECENTLY_ENHANCED_TABLE_NAME = "recently_enhanced_content_items";
 
     public static final UriRef CONSTRAINTS_URI = new UriRef("org.apache.stanbol.contenthub.constraints");
@@ -109,6 +118,8 @@ public class FileStore implements Store 
     public static final String FIELD_TITLE = "title";
 
     public static final String FIELD_ID = "id";
+    
+    public static final String FILE_STORE_NAME = "filestore";
 
     private static final String SELECT_RECENTLY_ENHANCED_ITEMS = "SELECT t1.id, mimeType, enhancementCount, title FROM "
                                                                  + FileRevisionManager.REVISION_TABLE_NAME
@@ -165,8 +176,7 @@ public class FileStore implements Store 
     protected void activate(ComponentContext componentContext) throws StoreException {
         // check store folder
         String stanbolHome = componentContext.getBundleContext().getProperty("sling.home");
-        String fileStoreName = "filestore";
-        storeFolder = new File(stanbolHome + "/" + fileStoreName);
+        storeFolder = new File(stanbolHome + "/" + FILE_STORE_NAME);
         if (!storeFolder.exists()) {
             storeFolder.mkdirs();
         }
@@ -195,7 +205,7 @@ public class FileStore implements Store 
         removeFromRecentlyEnhancedTable(id.getUnicodeString());
     }
 
-    public void removeFromRecentlyEnhancedTable(String contentItemID) throws StoreException {
+    private void removeFromRecentlyEnhancedTable(String contentItemID) throws StoreException {
         // get connection
         Connection con = dbManager.getConnection();
 
@@ -236,7 +246,8 @@ public class FileStore implements Store 
 
     private long getEnhancementCount(ContentItem ci) {
         long enhancementCount = 0;
-        Iterator<Triple> it = ci.getMetadata().filter(null, Properties.ENHANCER_EXTRACTED_FROM,
+        Iterator<Triple> it = ci.getMetadata().filter(null,
+            org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_EXTRACTED_FROM,
             new UriRef(ci.getUri().getUnicodeString()));
         while (it.hasNext()) {
             it.next();
@@ -527,9 +538,15 @@ public class FileStore implements Store 
     public ContentItem get(UriRef id) throws StoreException {
         // get the zip file
         String fileName = encodeId(id.getUnicodeString());
+        File file = new File(storeFolder.getPath() + "/" + fileName + ".zip");
+        if (!file.exists()) {
+            log.info("Failed to get file for the given id: {}", id);
+            return null;
+        }
+
         ZipFile zipFile;
         try {
-            zipFile = new ZipFile(new File(storeFolder.getPath() + "/" + fileName + ".zip"));
+            zipFile = new ZipFile(file);
         } catch (ZipException e) {
             throw new StoreException(String.format("Failed to get file for the given id: %s", id), e);
         } catch (IOException e) {
@@ -627,12 +644,18 @@ public class FileStore implements Store 
         String partType;
         String partUri;
         String partSuperType;
+        String partMimeType;
         T contentPart;
 
         try {
             partType = contentPartMetadata.getString("class");
             partUri = contentPartMetadata.getString("uri");
             partSuperType = contentPartMetadata.getString("superclass");
+            try {
+                partMimeType = contentPartMetadata.getString("metadata");
+            } catch (JSONException e1) {
+                partMimeType = null;
+            }
 
         } catch (JSONException e) {
             throw new StoreException("Failed to read content part metadata from the header", e);
@@ -647,20 +670,21 @@ public class FileStore implements Store 
                 encodeId(partUri), contentItem.getUri().getUnicodeString()), e);
         }
         try {
-            contentPart = contentPartDeserializer.deserializeContentPart(partStream, partType);
+            contentPart = contentPartDeserializer.deserializeContentPart(partStream, partType, partMimeType);
         } catch (StoreException e) {
             log.warn(
                 "Failed to deserialize main blob for the class: {}. Trying to serialize with the superclass: {}",
                 partType, partSuperType);
-            contentPart = contentPartDeserializer.deserializeContentPart(partStream, partSuperType);
+            contentPart = contentPartDeserializer.deserializeContentPart(partStream, partSuperType,
+                partMimeType);
         }
 
         return contentPart;
     }
 
     @Override
-    public ChangeSet changes(long revision, int offset, int batchSize) throws StoreException {
-        ChangeSetImpl changesSet = (ChangeSetImpl) revisionManager.getChanges(revision, offset, batchSize);
+    public ChangeSet changes(long revision, int batchSize) throws StoreException {
+        ChangeSetImpl changesSet = (ChangeSetImpl) revisionManager.getChanges(revision, batchSize);
         changesSet.setStore(this);
         return changesSet;
     }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartDeserializer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartDeserializer.java?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartDeserializer.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartDeserializer.java Fri Jun 22 11:13:27 2012
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
 public class ContentPartDeserializer {
     private static final Logger log = LoggerFactory.getLogger(ContentPartDeserializer.class);
 
-    private static Map<Class<?>,ContentPartDeserializerProvider> deserializerMap = new HashMap<Class<?>,ContentPartDeserializerProvider>();
+    private Map<Class<?>,ContentPartDeserializerProvider> deserializerMap = new HashMap<Class<?>,ContentPartDeserializerProvider>();
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, referenceInterface = ContentPartDeserializerProvider.class, policy = ReferencePolicy.DYNAMIC, strategy = ReferenceStrategy.EVENT, bind = "bindContentPartDeserializerProvider", unbind = "unbindContentPartDeserializerProvider")
     private List<ContentPartDeserializerProvider> deserializerList = new ArrayList<ContentPartDeserializerProvider>();
@@ -69,6 +69,29 @@ public class ContentPartDeserializer {
      * @throws StoreException
      */
     public <T> T deserializeContentPart(InputStream is, Class<?> klass) throws StoreException {
+        return deserializeContentPart(is, klass, null);
+    }
+
+    /**
+     * Deserializes the content part which will be read from the given {@link InputStream} using a
+     * {@link ContentPartDeserializerProvider} which will be obtained by the given {@link Class}. The first
+     * deserializer compatible with the given class is used. The types supported by a deserializer are
+     * compared with the given class parameter through the {@link Class#isAssignableFrom(Class)} method. This
+     * means that a deserializer is compatible with the given class if one of the supported types by
+     * deserializer either is a superclass or superinterface of the given class or same with the given class.
+     * 
+     * @param <T>
+     *            Generic type representing the content part to be returned
+     * @param is
+     *            {@link InputStream} from which the content part data will be read
+     * @param klass
+     *            Type for which a deserializer instance will be obtained.
+     * @param mimeType
+     *            Mime type of the content part to be serialized
+     * @return the deserialized content part
+     * @throws StoreException
+     */
+    public <T> T deserializeContentPart(InputStream is, Class<?> klass, String mimeType) throws StoreException {
         ContentPartDeserializerProvider deserializer = null;
         synchronized (deserializerList) {
             for (Entry<Class<?>,ContentPartDeserializerProvider> e : deserializerMap.entrySet()) {
@@ -82,9 +105,9 @@ public class ContentPartDeserializer {
             throw new StoreException(String.format(
                 "Failed to obtain serializer for the content part having type: %s", klass.getName()));
         }
-        return deserializer.deserialize(is);
+        return deserializer.deserialize(is, mimeType);
     }
-
+    
     /**
      * Deserializes the content part which will be read from the given {@link InputStream} using a
      * {@link ContentPartDeserializerProvider} which will be obtained by the given class name. In the first
@@ -104,6 +127,30 @@ public class ContentPartDeserializer {
      * @throws StoreException
      */
     public <T> T deserializeContentPart(InputStream is, String className) throws StoreException {
+        return deserializeContentPart(is, className, null);
+    }
+
+    /**
+     * Deserializes the content part which will be read from the given {@link InputStream} using a
+     * {@link ContentPartDeserializerProvider} which will be obtained by the given class name. In the first
+     * step, to be able to get a dedicated deserializer for the given <code>className</code>, this method
+     * checks a suitable deserializers using this name. This is done by comparing the name parameter with the
+     * name of the supported types of registered deserializers. If this attempt is unsuccessful, a serializer
+     * is tried to be obtained through the {@link #deserializeContentPart(InputStream, Class)} method after
+     * getting a {@link Class} from the given class name by {@link Class#forName(String)}.
+     * 
+     * @param <T>
+     *            Generic type of representing content part to be returned
+     * @param is
+     *            {@link InputStream} from which the content part data will be read
+     * @param className
+     *            Name of the class for which a deserializer instance will be obtained.
+     * @param mimeType
+     *            Mime type of the content part to be serialized
+     * @return the deserialized content part
+     * @throws StoreException
+     */
+    public <T> T deserializeContentPart(InputStream is, String className, String mimeType) throws StoreException {
         ContentPartDeserializerProvider deserializer = null;
         synchronized (deserializerList) {
             for (Entry<Class<?>,ContentPartDeserializerProvider> e : deserializerMap.entrySet()) {
@@ -117,7 +164,7 @@ public class ContentPartDeserializer {
             log.info("No deserializer supporting directly the class: {}", className);
             try {
                 Class<?> klass = Class.forName(className);
-                return deserializeContentPart(is, klass);
+                return deserializeContentPart(is, klass, mimeType);
             } catch (ClassNotFoundException e) {
                 throw new StoreException(String.format("Failed to load class: %s", className));
             }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartSerializer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartSerializer.java?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartSerializer.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/ContentPartSerializer.java Fri Jun 22 11:13:27 2012
@@ -42,7 +42,7 @@ import org.apache.stanbol.contenthub.ser
 @Component
 @Service(value = ContentPartSerializer.class)
 public class ContentPartSerializer {
-    private static Map<Class<?>,ContentPartSerializerProvider> serializerMap = new HashMap<Class<?>,ContentPartSerializerProvider>();
+    private Map<Class<?>,ContentPartSerializerProvider> serializerMap = new HashMap<Class<?>,ContentPartSerializerProvider>();
 
     @Reference(cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, referenceInterface = ContentPartSerializerProvider.class, policy = ReferencePolicy.DYNAMIC, strategy = ReferenceStrategy.EVENT, bind = "bindContentPartSerializerProvider", unbind = "unbindContentPartSerializerProvider")
     private List<ContentPartSerializerProvider> serializerList = new ArrayList<ContentPartSerializerProvider>();

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/GraphDeserializerProvider.java (from r1351229, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedGraphDeserializerProvider.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/GraphDeserializerProvider.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/GraphDeserializerProvider.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedGraphDeserializerProvider.java&r1=1351229&r2=1352846&rev=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedGraphDeserializerProvider.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/GraphDeserializerProvider.java Fri Jun 22 11:13:27 2012
@@ -23,7 +23,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.felix.scr.annotations.Component;
@@ -33,16 +32,15 @@ import org.apache.stanbol.commons.indexe
 import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
 
 /**
- * This {@link ContentPartDeserializerProvider} implementation supports {@link IndexedGraph}, {@link Graph}
- * and {@link TripleCollection} parts. In each case, as a result an {@link IndexedGraph} is returned as a
- * specific implementation.
+ * This {@link ContentPartDeserializerProvider} implementation supports {@link Graph} parts. As a result, an
+ * {@link IndexedGraph} is returned as a specific implementation.
  * 
  * @author suat
  * 
  */
 @Component
 @Service
-public class IndexedGraphDeserializerProvider implements ContentPartDeserializerProvider {
+public class GraphDeserializerProvider implements ContentPartDeserializerProvider {
 
     @Reference
     Parser parser;
@@ -50,9 +48,7 @@ public class IndexedGraphDeserializerPro
     @Override
     public Set<Class<?>> getSupportedContentPartTypes() {
         Set<Class<?>> supportedClasses = new HashSet<Class<?>>();
-        supportedClasses.add(IndexedGraph.class);
         supportedClasses.add(Graph.class);
-        supportedClasses.add(TripleCollection.class);
         return supportedClasses;
     }
 

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/MGraphDeserializerProvider.java (from r1351229, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedMGraphDeserializerProvider.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/MGraphDeserializerProvider.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/MGraphDeserializerProvider.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedMGraphDeserializerProvider.java&r1=1351229&r2=1352846&rev=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/IndexedMGraphDeserializerProvider.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/store/file/src/main/java/org/apache/stanbol/contenthub/store/file/serializer/MGraphDeserializerProvider.java Fri Jun 22 11:13:27 2012
@@ -23,7 +23,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.felix.scr.annotations.Component;
@@ -33,16 +32,15 @@ import org.apache.stanbol.commons.indexe
 import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
 
 /**
- * This {@link ContentPartDeserializerProvider} implementation supports {@link IndexedMGraph}, {@link MGraph}
- * and {@link TripleCollection} parts. In each case, as a result an {@link IndexedMGraph} is returned as a
- * specific implementation.
+ * This {@link ContentPartDeserializerProvider} implementation supports {@link IndexedMGraph} parts. As a
+ * result an {@link IndexedMGraph} is returned as a specific implementation.
  * 
  * @author suat
  * 
  */
 @Component
 @Service
-public class IndexedMGraphDeserializerProvider implements ContentPartDeserializerProvider {
+public class MGraphDeserializerProvider implements ContentPartDeserializerProvider {
 
     @Reference
     private Parser parser;
@@ -50,9 +48,7 @@ public class IndexedMGraphDeserializerPr
     @Override
     public Set<Class<?>> getSupportedContentPartTypes() {
         Set<Class<?>> supportedClasses = new HashSet<Class<?>>();
-        supportedClasses.add(IndexedMGraph.class);
         supportedClasses.add(MGraph.class);
-        supportedClasses.add(TripleCollection.class);
         return supportedClasses;
     }
 

Propchange: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun 22 11:13:27 2012
@@ -0,0 +1,4 @@
+target
+.settings
+.classpath
+.project

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/pom.xml?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/pom.xml (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/pom.xml Fri Jun 22 11:13:27 2012
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+  license agreements. See the NOTICE file distributed with this work for additional 
+  information regarding copyright ownership. The ASF licenses this file to 
+  you under the Apache License, Version 2.0 (the "License"); you may not use 
+  this file except in compliance with the License. You may obtain a copy of 
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+  by applicable law or agreed to in writing, software distributed under the 
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+  OF ANY KIND, either express or implied. See the License for the specific 
+  language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>org.apache.stanbol.contenthub.parent</artifactId>
+    <version>0.10.0-incubating-SNAPSHOT</version>
+    <relativePath>../parent</relativePath>
+  </parent>
+  
+  <artifactId>org.apache.stanbol.contenthub.test</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Contenthub Tests</name>
+  <description>This bundle contains unit and integrations of Contenthub.</description>
+
+  <build>
+    <plugins>
+      <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>maven-bundle-plugin</artifactId>
+          <extensions>true</extensions>
+          <configuration>
+              <instructions>
+                  <Export-Package>org.apache.stanbol.contenthub.test.*</Export-Package>
+                  <Sling-Test-Regexp>.*Test</Sling-Test-Regexp>
+              </instructions>
+          </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+   <dependencies>
+      <dependency>
+        <groupId>org.apache.stanbol</groupId>
+        <artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
+        <version>0.10.0-incubating-SNAPSHOT</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.stanbol</groupId>
+        <artifactId>org.apache.stanbol.contenthub.store.file</artifactId>
+        <version>0.10.0-incubating-SNAPSHOT</version>
+      </dependency>
+      
+      <dependency>
+        <groupId>org.apache.clerezza</groupId>
+        <artifactId>rdf.core</artifactId>
+      </dependency>
+      <dependency>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.core</artifactId>
+      </dependency>
+      <dependency>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.compendium</artifactId>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.felix</groupId>
+          <artifactId>org.apache.felix.scr.annotations</artifactId>
+          <scope>provided</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-api</artifactId>
+          <scope>provided</scope>
+      </dependency>
+      <dependency>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+          <scope>provided</scope>
+      </dependency>
+      <dependency>
+          <groupId>org.apache.sling</groupId>
+          <artifactId>org.apache.sling.junit.core</artifactId>
+          <scope>provided</scope>
+      </dependency>
+   </dependencies>
+</project>

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartDeserializerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartDeserializerTest.java?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartDeserializerTest.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartDeserializerTest.java Fri Jun 22 11:13:27 2012
@@ -0,0 +1,118 @@
+package org.apache.stanbol.contenthub.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.store.file.serializer.ContentPartDeserializer;
+import org.apache.stanbol.enhancer.servicesapi.Blob;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class ContentPartDeserializerTest {
+    private static final Logger log = LoggerFactory.getLogger(FileStoreDBManagerTest.class);
+
+    @TestReference
+    ContentPartDeserializer contentPartDeserializer;
+
+    @TestReference
+    ContentItemFactory contentItemFactory;
+
+    @TestReference
+    Serializer serializer;
+
+    @Test
+    public void testBlobDeserializerProvider() throws StoreException {
+        Blob blobExpected = null;
+        try {
+            blobExpected = contentItemFactory.createBlob(new StringSource("I live in Paris."));
+        } catch (IOException e) {
+            log.error("Blob cannot be created.");
+            throw new StoreException("Blob cannot be created.", e);
+        }
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        try {
+            IOUtils.copy(blobExpected.getStream(), os);
+        } catch (IOException e) {
+            log.error("Failed to serialize Blob into OutputStream");
+            throw new StoreException("Failed to serialize Blob into OutputStream", e);
+        }
+
+        InputStream is = new ByteArrayInputStream(os.toByteArray());
+        Blob blobActual = contentPartDeserializer.deserializeContentPart(is, Blob.class,
+            blobExpected.getMimeType());
+
+        assertEquals(blobExpected.getMimeType(), blobActual.getMimeType());
+        assertEquals(blobExpected.getContentLength(), blobActual.getContentLength());
+        try {
+            assertEquals(org.apache.commons.io.IOUtils.toString(blobExpected.getStream()),
+                org.apache.commons.io.IOUtils.toString(blobActual.getStream()));
+        } catch (IOException e) {
+            log.error("Failed to convert InputStream to String.");
+            throw new StoreException("Failed to convert InputStream to String.", e);
+        }
+    }
+
+    @Test
+    public void testGraphDeserializerProvider() throws StoreException {
+        TripleCollection gExpected = new SimpleMGraph();
+        gExpected.add(new TripleImpl(new UriRef("http://dbpedia.org/resource/Paris"), new UriRef(
+                "http://dbpedia.org/ontology/label"), new UriRef(
+                "http://www.w3.org/2000/01/rdf-schema#label/Paris")));
+        gExpected.add(new TripleImpl(new UriRef("http://dbpedia.org/resource/Paris"), new UriRef(
+                "http://dbpedia.org/ontology/populationTotal"), new UriRef(
+                "http://www.w3.org/2001/XMLSchema#long/2193031")));
+
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        serializer.serialize(os, gExpected, SupportedFormat.RDF_XML);
+
+        ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+
+        Graph gActual = contentPartDeserializer.deserializeContentPart(is, Graph.class);
+        assertTrue(gExpected.containsAll(gActual));
+        assertTrue(gActual.containsAll(gExpected));
+    }
+
+    @Test
+    public void testIndexedMGraphDeserializerProvider() throws StoreException {
+        TripleCollection tc = new SimpleMGraph();
+        tc.add(new TripleImpl(new UriRef("http://dbpedia.org/resource/Paris"), new UriRef(
+                "http://dbpedia.org/ontology/label"), new UriRef(
+                "http://www.w3.org/2000/01/rdf-schema#label/Paris")));
+        tc.add(new TripleImpl(new UriRef("http://dbpedia.org/resource/Paris"), new UriRef(
+                "http://dbpedia.org/ontology/populationTotal"), new UriRef(
+                "http://www.w3.org/2001/XMLSchema#long/2193031")));
+
+        IndexedMGraph gExpected = new IndexedMGraph(tc);
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        serializer.serialize(os, tc, SupportedFormat.RDF_XML);
+
+        ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+
+        MGraph gActual = contentPartDeserializer.deserializeContentPart(is, MGraph.class);
+        assertTrue(gExpected.containsAll(gActual));
+        assertTrue(gActual.containsAll(gExpected));
+    }
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartSerializerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartSerializerTest.java?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartSerializerTest.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/ContentPartSerializerTest.java Fri Jun 22 11:13:27 2012
@@ -0,0 +1,83 @@
+package org.apache.stanbol.contenthub.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.store.file.serializer.ContentPartSerializer;
+import org.apache.stanbol.enhancer.servicesapi.Blob;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class ContentPartSerializerTest {
+	private static final Logger log = LoggerFactory
+			.getLogger(FileStoreDBManagerTest.class);
+
+	@TestReference
+	ContentPartSerializer contentPartSerializer;
+
+	@TestReference
+	ContentItemFactory contentItemFactory;
+
+	@TestReference
+	private Parser parser;
+
+	@Test
+	public void testBlobSerializerProvider() throws StoreException {
+		String strExpected = "I live in Paris.";
+		Blob blob = null;
+		try {
+			blob = contentItemFactory.createBlob(new StringSource(strExpected));
+		} catch (IOException e) {
+			log.error("Blob cannot be created.");
+		}
+
+		ByteArrayOutputStream os = new ByteArrayOutputStream();
+		contentPartSerializer.serializeContentPart(os, blob);
+
+		String strActual = new String(os.toByteArray());
+		assertEquals(strExpected, strActual);
+	}
+
+	@Test
+	public void testTripleCollectionSerializerProvider() throws StoreException {
+		TripleCollection tcExpected = new SimpleMGraph();
+		tcExpected.add(new TripleImpl(new UriRef(
+				"http://dbpedia.org/resource/Paris"), new UriRef(
+				"http://dbpedia.org/ontology/label"), new UriRef(
+				"http://www.w3.org/2000/01/rdf-schema#label/Paris")));
+		tcExpected.add(new TripleImpl(new UriRef(
+				"http://dbpedia.org/resource/Paris"), new UriRef(
+				"http://dbpedia.org/ontology/populationTotal"), new UriRef(
+				"http://www.w3.org/2001/XMLSchema#long/2193031")));
+
+		ByteArrayOutputStream os = new ByteArrayOutputStream();
+		contentPartSerializer.serializeContentPart(os, tcExpected);
+
+		InputStream is = new ByteArrayInputStream(os.toByteArray());
+		MGraph tcActual = new SimpleMGraph();
+		parser.parse(tcActual, is, SupportedFormat.RDF_XML);
+
+		assertTrue(tcExpected.containsAll(tcActual));
+		assertTrue(tcActual.containsAll(tcExpected));
+	}
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileRevisionManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileRevisionManagerTest.java?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileRevisionManagerTest.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileRevisionManagerTest.java Fri Jun 22 11:13:27 2012
@@ -0,0 +1,282 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Set;
+
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.stanbol.contenthub.servicesapi.store.ChangeSet;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.store.file.FileRevisionManager;
+import org.apache.stanbol.contenthub.store.file.FileStoreDBManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class FileRevisionManagerTest {
+    private static Logger log = LoggerFactory.getLogger(FileRevisionManagerTest.class);
+
+    @TestReference
+    FileRevisionManager fileRevisionManager;
+
+    @TestReference
+    FileStoreDBManager dbManager;
+
+    @Test
+    public void fileRevisionManagerTest() {
+        assertNotNull("Expecting FileRevisionManager to be injected by Sling test runner",
+            fileRevisionManager);
+    }
+
+    @Test
+    public void dbManagerTest() {
+        assertNotNull("Expecting FileStoreDBManager to be injected by Sling test runner", dbManager);
+    }
+
+    @Test
+    public void updateChangeTest() throws StoreException, SQLException {
+        // do the update
+        String contentItemID = "contenthub_test_content_item_id";
+        fileRevisionManager.updateRevision(contentItemID);
+
+        // check the update
+        String query = "SELECT id, revision FROM content_item_revisions WHERE id = ?";
+        Connection con = dbManager.getConnection();
+        PreparedStatement ps = null;
+        ResultSet rs = null;
+        boolean recordExist = false;
+        long revisionNumber = Long.MAX_VALUE;
+        try {
+            ps = con.prepareStatement(query);
+            ps.setString(1, contentItemID);
+            rs = ps.executeQuery();
+            if (rs.next()) {
+                recordExist = true;
+                revisionNumber = rs.getLong(2);
+            }
+        } finally {
+            dbManager.closeResultSet(rs);
+            dbManager.closeStatement(ps);
+        }
+
+        assertTrue("failed to obtain content item revision", recordExist);
+        assertTrue("wrong revision number", (revisionNumber <= System.currentTimeMillis()));
+
+        // clear the update
+        query = "DELETE FROM content_item_revisions WHERE id = ?";
+        ps = null;
+        try {
+            ps = con.prepareStatement(query);
+            ps.setString(1, contentItemID);
+            int result = ps.executeUpdate();
+            if (result != 1) {
+                log.warn(
+                    "Wrong number of updated records while removing the test record. Updated record number: {}",
+                    result);
+            }
+        } catch (SQLException e) {
+            log.warn("Failed to remove the test record", e);
+        } finally {
+            dbManager.closeConnection(con);
+            dbManager.closeStatement(ps);
+        }
+    }
+
+    /**
+     * IMPORTANT NOTE: At time of executing the test below, there MUST be no other requests updating the
+     * revision table, otherwise the test will fail.
+     * 
+     * @throws InterruptedException
+     * @throws SQLException
+     */
+    @Test
+    public void iterativeChangesTest() throws StoreException, InterruptedException, SQLException {
+        log.warn("DO NOT UPDATE REVISION MANAGER DURING EXECUTION OF THIS TEST");
+        Connection con = dbManager.getConnection();
+        String contentItemID = "contenthub_test_content_item_id";
+        PreparedStatement ps = null;
+        int insertCount = 0;
+        try {
+            // do the update
+            String query = "INSERT INTO " + FileRevisionManager.REVISION_TABLE_NAME
+                           + " (id, revision) VALUES (?,?)";
+            long startRevision = System.currentTimeMillis();
+            long revision = System.currentTimeMillis();
+            for (int i = 0; i < 5; i++) {
+                // to ensure different revisions
+                ps = con.prepareStatement(query);
+                ps.setString(1, contentItemID + i);
+                ps.setLong(2, ++revision);
+                ps.executeUpdate();
+                ps.clearParameters();
+                insertCount++;
+            }
+
+            // check changes
+            ChangeSet changeSet = fileRevisionManager.getChanges(startRevision, 3);
+            Set<UriRef> changedItems = changeSet.changed();
+            assertTrue("Wrong number of changed items", (changedItems.size() == 3));
+            for (int i = 0; i < 3; i++) {
+                assertTrue("Changes does not include correct URIs",
+                    changedItems.contains(new UriRef(contentItemID + i)));
+            }
+            assertTrue("Changes does not include correct fromRevision value",
+                (changeSet.fromRevision() == revision - 4));
+            assertTrue("Changes does not include correct toRevision value",
+                (changeSet.toRevision() == revision - 2));
+
+            changeSet = fileRevisionManager.getChanges(revision - 2, 3);
+            changedItems = changeSet.changed();
+            assertTrue("Wrong number of changed items", (changedItems.size() == 2));
+            for (int i = 0; i < 2; i++) {
+                assertTrue("Changes does not include correct URIs",
+                    changedItems.contains(new UriRef(contentItemID + (i + 3))));
+            }
+            assertTrue("Changes does not include correct fromRevision value",
+                (changeSet.fromRevision() == revision - 1));
+            assertTrue("Changes does not include correct toRevision value",
+                (changeSet.toRevision() == revision));
+        } finally {
+            // clear test changes
+            String query = "DELETE FROM content_item_revisions WHERE id = ? OR id = ? OR id = ? OR id = ? OR id = ?";
+            try {
+                ps = con.prepareStatement(query);
+                for (int i = 0; i < insertCount; i++) {
+                    ps.setString(i + 1, contentItemID + i);
+                }
+                int result = ps.executeUpdate();
+                if (result != 5) {
+                    log.warn(
+                        "Wrong number of updated records while removing the test record. Updated record number: {}",
+                        result);
+                }
+            } catch (SQLException e) {
+                log.warn("Failed to remove the test record", e);
+            } finally {
+                dbManager.closeStatement(ps);
+                dbManager.closeConnection(con);
+                printDBTables();
+            }
+        }
+    }
+
+    private void printDBTables() {
+        Connection con = null;
+        Statement stmt = null;
+        ResultSet rs = null;
+        try {
+            con = dbManager.getConnection();
+            String selectRevisionsQuery = "SELECT * FROM content_item_revisions";
+            String selectRecentlyEnhancedQuery = "SELECT * from recently_enhanced_content_items";
+            stmt = con.createStatement();
+            rs = stmt.executeQuery(selectRevisionsQuery);
+            System.out.println("===============REVISION TABLE================");
+            while (rs.next()) {
+                System.out.println(rs.getString(1));
+            }
+            System.out.println("===============RECENTLY ENHANCED TABLE================");
+            rs = stmt.executeQuery(selectRecentlyEnhancedQuery);
+            while (rs.next()) {
+                System.out.println(rs.getString(1));
+            }
+
+        } catch (SQLException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } catch (StoreException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        } finally {
+            dbManager.closeConnection(con);
+            dbManager.closeStatement(stmt);
+            dbManager.closeResultSet(rs);
+        }
+    }
+
+    @Test
+    public void batchSizeDoesNotFitToRevisionTest() throws StoreException, SQLException {
+        log.warn("DO NOT UPDATE REVISION MANAGER DURING EXECUTION OF THIS TEST");
+        Connection con = dbManager.getConnection();
+        String contentItemID = "contenthub_test_content_item_id";
+        PreparedStatement ps = null;
+        int insertCount = 0;
+        try {
+            // do the update
+            String query = "INSERT INTO " + FileRevisionManager.REVISION_TABLE_NAME
+                           + " (id, revision) VALUES (?,?)";
+            long revision = System.currentTimeMillis();
+            for (int i = 0; i < 2; i++) {
+                ps = con.prepareStatement(query);
+                ps.setString(1, contentItemID + i);
+                ps.setLong(2, revision + 1);
+                ps.executeUpdate();
+                ps.clearParameters();
+                insertCount++;
+            }
+
+            // get changes
+            Set<UriRef> changedItems = fileRevisionManager.getChanges(revision, 1).changed();
+            assertTrue("Wrong number of changed items", (changedItems.size() == 2));
+            for (int i = 0; i < 2; i++) {
+                assertTrue("Changes does not include correct URIs",
+                    changedItems.contains(new UriRef(contentItemID + i)));
+            }
+        } finally {
+            // clear test changes
+            String query = "DELETE FROM content_item_revisions WHERE id = ? OR id = ?";
+            try {
+                ps = con.prepareStatement(query);
+                for (int i = 0; i < insertCount; i++) {
+                    ps.setString(i + 1, contentItemID + i);
+                }
+                int result = ps.executeUpdate();
+                if (result != 2) {
+                    log.warn(
+                        "Wrong number of updated records while removing the test record. Updated record number: {}",
+                        result);
+                }
+            } catch (SQLException e) {
+                log.warn("Failed to remove the test record", e);
+            } finally {
+                dbManager.closeStatement(ps);
+                dbManager.closeConnection(con);
+                printDBTables();
+            }
+        }
+    }
+
+    @Test
+    public void emptyChangesTest() throws StoreException {
+        long revision = System.currentTimeMillis();
+        ChangeSet changeSet = fileRevisionManager.getChanges(revision, 1);
+        assertTrue("There must be no changes", changeSet.changed().size() == 0);
+        assertTrue("Wrong start version", changeSet.fromRevision() == -1);
+        assertTrue("Wrong end version", changeSet.toRevision() == -1);
+    }
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreDBManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreDBManagerTest.java?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreDBManagerTest.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreDBManagerTest.java Fri Jun 22 11:13:27 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.contenthub.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.store.file.FileStoreDBManager;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class FileStoreDBManagerTest {
+    private static final Logger log = LoggerFactory.getLogger(FileStoreDBManagerTest.class);
+
+    @TestReference
+    FileStoreDBManager dbManager;
+    
+    @Test
+    public void dbManagerTest() {
+        assertNotNull("Expecting FileStoreDBManager to be injected by Sling test runner", dbManager);
+    }
+
+    @Test
+    public void testConnection() throws StoreException {
+        Connection connection = dbManager.getConnection();
+        assertTrue("Null connection", connection != null);
+        if (connection != null) {
+            try {
+                connection.close();
+            } catch (SQLException e) {
+                log.warn("Failed to close test connection");
+            }
+        }
+    }
+
+    @Test
+    public void testTables() throws StoreException {
+        assertTrue("recently_enhanced_content_items does not exist", dbManager.existsTable("recently_enhanced_content_items"));
+        assertTrue("content_item_revisions does not exist", dbManager.existsTable("content_item_revisions"));
+    }
+}

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreTest.java?rev=1352846&view=auto
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreTest.java (added)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/test/src/main/java/org/apache/stanbol/contenthub/test/FileStoreTest.java Fri Jun 22 11:13:27 2012
@@ -0,0 +1,198 @@
+package org.apache.stanbol.contenthub.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
+import org.apache.stanbol.contenthub.servicesapi.store.Store;
+import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.contenthub.store.file.FileStore;
+import org.apache.stanbol.contenthub.store.file.FileStoreDBManager;
+import org.apache.stanbol.enhancer.servicesapi.Blob;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.codehaus.jettison.json.JSONException;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class FileStoreTest {
+    private static final Logger log = LoggerFactory.getLogger(FileStoreTest.class);
+
+    @TestReference(name = "FileStore")
+    private Store store;
+
+    @TestReference()
+    private BundleContext bundleContext;
+
+    @TestReference
+    private ContentItemFactory contentItemFactory;
+
+    @TestReference
+    private FileStoreDBManager dbManager;
+
+    @Test
+    public void fileStoreTest() {
+        assertNotNull("Expecting FileStore to be injected by Sling test runner", store);
+        assertTrue("Expection FileStore implementation of Store interface", store instanceof FileStore);
+    }
+
+    @Test
+    public void bundleContextTest() {
+        assertNotNull("Expecting BundleContext to be injected by Sling test runner", bundleContext);
+    }
+
+    @Test
+    public void contentItemFactoryTest() {
+        assertNotNull("Expecting ContentItemFactory to be injected by Sling test runner", contentItemFactory);
+    }
+
+    @Test
+    public void dbManagerTest() {
+        assertNotNull("Expecting FileStoreDBManager to be injected by Sling test runner", dbManager);
+    }
+
+    @Test
+    public void storeFolderTest() {
+        String stanbolHome = bundleContext.getProperty("sling.home");
+        File storeFolder = new File(stanbolHome + "/filestore");
+        assertTrue("No store folder exists", storeFolder.exists());
+    }
+
+    @Test
+    public void putTest() throws IOException, StoreException, JSONException {
+        String id = null;
+        try {
+            StringSource stringSource = new StringSource("I love Paris.");
+            ContentItem ci = contentItemFactory.createContentItem(stringSource);
+            id = store.put(ci);
+
+            // check zip file
+            String stanbolHome = bundleContext.getProperty("sling.home");
+            File storeFolder = new File(stanbolHome + "/filestore");
+            String[] fileNames = storeFolder.list();
+            boolean zipExists = false;
+            for (String fileName : fileNames) {
+                if (fileName.equals(encodeId(id) + ".zip")) {
+                    zipExists = true;
+                    break;
+                }
+            }
+            assertTrue("Failed to find content item in store folder", zipExists);
+
+            // check content of zip file
+            ZipFile zipFile = new ZipFile(new File(storeFolder.getPath() + "/" + encodeId(id) + ".zip"));
+            ZipEntry zipEntry = zipFile.getEntry("metadata");
+            assertTrue("Zip file does not contain the metadata entry", zipEntry != null);
+            zipEntry = zipFile.getEntry("org.apache.stanbol.contenthub.htmlmetadata");
+            assertTrue("Zip file does not contain the html metadata entry", zipEntry != null);
+            zipEntry = zipFile.getEntry(encodeId(id) + "_main");
+            assertTrue("Zip file does not contain the metadata entry", zipEntry != null);
+            zipEntry = zipFile.getEntry("header");
+            assertTrue("Zip file does not contain the header entry", zipEntry != null);
+
+        } finally {
+            if (id != null) {
+                clearTestContentItem(id);
+            }
+        }
+    }
+
+    @Test
+    public void getTest() throws IOException, StoreException {
+        String id = null;
+        try {
+            // put a content item
+            StringSource stringSource = new StringSource("I love Paris.");
+            ContentItem ci = contentItemFactory.createContentItem(stringSource);
+            ci.addPart(new UriRef("dummypart"), new IndexedMGraph());
+            id = store.put(ci);
+
+            // check metadata
+            ci = store.get(new UriRef(id));
+            assertTrue("Failed to find metadata of retrieved content item", ci.getMetadata() != null);
+
+            // check main blob
+            assertTrue("Failed to find main blob of retrieved content item",
+                ci.getPart(new UriRef(id + "_main"), Blob.class) != null);
+
+            // check additional part
+            assertTrue("Failed to find additional part of retrieved content item",
+                ci.getPart(new UriRef("dummypart"), MGraph.class) != null);
+
+        } finally {
+            if (id != null) {
+                clearTestContentItem(id);
+            }
+        }
+    }
+
+    private void clearTestContentItem(String id) throws StoreException {
+        // delete the file
+        String fileStoreFolder = bundleContext.getProperty("sling.home") + "/" + FileStore.FILE_STORE_NAME;
+        File f = new File(fileStoreFolder + "/" + encodeId(id) + ".zip");
+        f.delete();
+
+        // delete the database records
+        String query = "DELETE FROM content_item_revisions WHERE id = ?";
+        Connection connection = dbManager.getConnection();
+        PreparedStatement ps = null;
+        try {
+            ps = connection.prepareStatement(query);
+            ps.setString(1, id);
+            int result = ps.executeUpdate();
+            if (result != 1) {
+                log.warn(
+                    "Wrong number of updated records while removing the test record. Updated record number: {}",
+                    result);
+            }
+        } catch (SQLException e) {
+            log.warn("Failed to remove the test record", e);
+        } finally {
+            dbManager.closeStatement(ps);
+        }
+        try {
+            query = "DELETE FROM recently_enhanced_content_items WHERE id = ?";
+            ps = connection.prepareStatement(query);
+            ps.setString(1, id);
+            int result = ps.executeUpdate();
+            if (result != 1) {
+                log.warn(
+                    "Wrong number of updated records while removing the test record. Updated record number: {}",
+                    result);
+            }
+        } catch (SQLException e) {
+            log.warn("Failed to remove the test record", e);
+        } finally {
+            dbManager.closeStatement(ps);
+            dbManager.closeConnection(connection);
+        }
+    }
+
+    private String encodeId(String id) throws StoreException {
+        try {
+            return URLEncoder.encode(id, "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            log.error("Failed to encode id. {}", id, e);
+            throw new StoreException("Failed to encode id: " + id, e);
+        }
+    }
+}

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/pom.xml?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/pom.xml (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/pom.xml Fri Jun 22 11:13:27 2012
@@ -23,7 +23,7 @@
   <artifactId>org.apache.stanbol.contenthub.web</artifactId>
   <packaging>bundle</packaging>
 
-  <name>Apache Stanbol Content Hub JAX-RS API</name>
+  <name>Apache Stanbol Contenthub JAX-RS API</name>
   <description>HTTP endpoint to create and search for content items enriched
     with enhancer's annotations and links to entities from the entity hub.
   </description>
@@ -110,7 +110,7 @@
     <dependency>
       <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.entityhub.core</artifactId>
-      <version>0.10.0-incubating-SNAPSHOT</version>
+      <version>0.10.1-incubating-SNAPSHOT</version>
     </dependency>
 
     <!-- Jersey -->
@@ -171,7 +171,7 @@
     <dependency>
       <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.commons.solr.core</artifactId>
-      <version>0.10.0-incubating-SNAPSHOT</version>
+      <version>0.10.1-incubating-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.stanbol</groupId>

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java?rev=1352846&r1=1352845&r2=1352846&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/fragment/ContenthubWebFragment.java Fri Jun 22 11:13:27 2012
@@ -31,6 +31,7 @@ import org.apache.stanbol.commons.web.ba
 import org.apache.stanbol.commons.web.base.ScriptResource;
 import org.apache.stanbol.commons.web.base.WebFragment;
 import org.apache.stanbol.contenthub.web.resources.RootResource;
+import org.apache.stanbol.contenthub.web.resources.SemanticIndexManagerResource;
 import org.apache.stanbol.contenthub.web.resources.StoreResource;
 import org.apache.stanbol.contenthub.web.writers.LDProgramCollectionWriter;
 import org.apache.stanbol.contenthub.web.writers.SearchResultWriter;
@@ -70,7 +71,7 @@ public class ContenthubWebFragment imple
         Set<Class<?>> classes = new HashSet<Class<?>>();
         classes.add(RootResource.class);
         classes.add(StoreResource.class);
-
+        classes.add(SemanticIndexManagerResource.class);
         classes.add(LDProgramCollectionWriter.class);
         classes.add(SearchResultWriter.class);