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/11/27 10:37:38 UTC

svn commit: r1414034 - in /stanbol/trunk/contenthub: search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/ servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/ servicesapi/src/main/java/org/apache/stanbol/co...

Author: suat
Date: Tue Nov 27 09:37:36 2012
New Revision: 1414034

URL: http://svn.apache.org/viewvc?rev=1414034&view=rev
Log:
STANBOL-783:

Till now Contenthub didn't allow to specify the chain name to be used in the enhancement process of the documents submitted to it. To be able to allow indexing of different enhancements which might be produced by different enhancement engines in different chains, it is necessary to allow configuring the chain name. 

Now, there is an additional "chain" parameter in the SolrStore#enhanceAndPut methods allowing to specify the name of the chain. Based on this, the SolrStoreImpl has been updated. Also, corresponding RESTful services has also been update.

Note that in this commit SolrStoreImpl contains other changes which are basically usage of ContentItem instead of SolrContentItem (sorry for the bulk update).

Removed:
    stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/util/ContentItemIDOrganizer.java
Modified:
    stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DocumentResultImpl.java
    stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java
    stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
    stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java

Modified: stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DocumentResultImpl.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DocumentResultImpl.java?rev=1414034&r1=1414033&r2=1414034&view=diff
==============================================================================
--- stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DocumentResultImpl.java (original)
+++ stanbol/trunk/contenthub/search/featured/src/main/java/org/apache/stanbol/contenthub/search/featured/DocumentResultImpl.java Tue Nov 27 09:37:36 2012
@@ -17,7 +17,6 @@
 package org.apache.stanbol.contenthub.search.featured;
 
 import org.apache.stanbol.contenthub.servicesapi.search.featured.DocumentResult;
-import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
 
 public class DocumentResultImpl implements DocumentResult {
 
@@ -27,33 +26,30 @@ public class DocumentResultImpl implemen
     private long enhancementCount;
     private String title;
 
-    public DocumentResultImpl(String uri,
-                                 String mimeType,
-                                 long enhancementCount,
-                                 String title) {
-        this.id = ContentItemIDOrganizer.detachBaseURI(uri);
+    public DocumentResultImpl(String uri, String mimeType, long enhancementCount, String title) {
+        this.id = uri;
         this.mimetype = mimeType;
         this.title = (title == null || title.trim().equals("") ? id : title);
         this.enhancementCount = enhancementCount;
     }
 
     public DocumentResultImpl(String uri,
-                                 String dereferencableURI,
-                                 String mimeType,
-                                 long enhancementCount,
-                                 String title) {
-        this.id = ContentItemIDOrganizer.detachBaseURI(uri);
+                              String dereferencableURI,
+                              String mimeType,
+                              long enhancementCount,
+                              String title) {
+        this.id = uri;
         this.dereferencableURI = dereferencableURI;
         this.mimetype = mimeType;
         this.title = (title == null || title.trim().equals("") ? id : title);
         this.enhancementCount = enhancementCount;
     }
-    
+
     @Override
     public String getLocalId() {
         return this.id;
     }
-    
+
     @Override
     public String getDereferencableURI() {
         return this.dereferencableURI;
@@ -93,5 +89,5 @@ public class DocumentResultImpl implemen
     public void setTitle(String title) {
         this.title = title;
     }
-    
+
 }

Modified: stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java?rev=1414034&r1=1414033&r2=1414034&view=diff
==============================================================================
--- stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java (original)
+++ stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/Store.java Tue Nov 27 09:37:36 2012
@@ -1,57 +1,58 @@
 /*
-* 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.
-*/
+ * 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.servicesapi.store;
 
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
 
-
 /**
  * Store and retrieve ContentItem instances.
- *
- * Incomplete CRUD for now, we don't need it for our
- * initial use cases.
+ * 
+ * Incomplete CRUD for now, we don't need it for our initial use cases.
  */
 public interface Store {
 
     /**
-     * Creates a {@link ContentItem} item based on supplied data,
-     * using an implementation that suits this store.
+     * Creates a {@link ContentItem} item based on supplied data, using an implementation that suits this
+     * store.
      * <p>
-     * Calling this method creates an empty data transfer object in
-     * memory suitable for later saving using the {@link Store#put(ContentItem)} method.
-     * The Store state is unchanged by the call to the
+     * Calling this method creates an empty data transfer object in memory suitable for later saving using the
+     * {@link Store#put(ContentItem)} method. The Store state is unchanged by the call to the
      * {@link #create(String, byte[], String)} method.
-     *
-     * @param id The value to use {@link ContentItem#getId}. If <code>null</code>
-     * is parsed as id, an id need to be computed based on the parsed content (
-     * e.g. calculating the stream digest (see also
-     * {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
-     * @param content the binary content
-     * @param contentType The Mime-Type of the binary data
+     * 
+     * @param id
+     *            The value to use {@link ContentItem#getId}. If <code>null</code> is parsed as id, an id need
+     *            to be computed based on the parsed content ( e.g. calculating the stream digest (see also
+     *            {@link ContentItemHelper#streamDigest(java.io.InputStream, java.io.OutputStream, String)})
+     * @param content
+     *            the binary content
+     * @param contentType
+     *            The Mime-Type of the binary data
      * @return the {@link ContentItem} that was created
+     * @throws StoreException
      */
-    ContentItem create(String id, byte[] content, String contentType);
+    ContentItem create(String id, byte[] content, String contentType) throws StoreException;
 
-    /** Store supplied {@link ContentItem} and return its id, which
-     *  is assigned by the store if not defined yet.
-     *
-     *  If the {@link ContentItem} already exists, it is overwritten.
+    /**
+     * Store supplied {@link ContentItem} and return its id, which is assigned by the store if not defined
+     * yet.
+     * 
+     * If the {@link ContentItem} already exists, it is overwritten.
      */
     String put(ContentItem ci) throws StoreException;
 
@@ -59,8 +60,7 @@ public interface Store {
     ContentItem get(String id) throws StoreException;
 
     /**
-     * Get the graph of triples of enhancements related to the content item from
-     * this store
+     * Get the graph of triples of enhancements related to the content item from this store
      */
     MGraph getEnhancementGraph();
 

Modified: stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java?rev=1414034&r1=1414033&r2=1414034&view=diff
==============================================================================
--- stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java (original)
+++ stanbol/trunk/contenthub/servicesapi/src/main/java/org/apache/stanbol/contenthub/servicesapi/store/solr/SolrStore.java Tue Nov 27 09:37:36 2012
@@ -18,10 +18,11 @@
 package org.apache.stanbol.contenthub.servicesapi.store.solr;
 
 import java.util.List;
-import java.util.Map;
 
+import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.stanbol.contenthub.servicesapi.store.Store;
 import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
+import org.apache.stanbol.enhancer.servicesapi.Chain;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
 
@@ -34,9 +35,11 @@ import org.apache.stanbol.enhancer.servi
  */
 public interface SolrStore extends Store {
 
+    public static final UriRef TITLE_URI = new UriRef("org.apache.stanbol.contenthub.store.solr.title");
+
     /**
-     * Creates a {@link SolrContentItem} with the given parameters. Created {@link SolrContentItem} is not
-     * persisted, this function just creates the object.
+     * Creates a {@link ContentItem} with the given parameters. Created {@link ContentItem} is not persisted,
+     * this function just creates the object.
      * 
      * @param content
      *            The content itself.
@@ -47,70 +50,71 @@ public interface SolrStore extends Store
      *            The title for the content item.
      * @param contentType
      *            The mimeType of the content.
-     * @param constraints
-     *            The facets in <code>key:[value1,value2]</code> pairs.
-     * @return Created {@link SolrContentItem}.
+     * @return Created {@link ContentItem}.
+     * @throws StoreException
      */
-    SolrContentItem create(byte[] content,
-                           String id,
-                           String title,
-                           String contentType,
-                           Map<String,List<Object>> constraints);
+    ContentItem create(byte[] content, String id, String title, String contentType) throws StoreException;
 
     /**
-     * Sends the {@link SolrContentItem} to the {@link EnhancementJobManager} to enhance the content.
-     * Afterwards saves the item in the default Solr core of the Contenthub.
+     * Sends the {@link ContentItem} to the {@link EnhancementJobManager} to enhance the content. Afterwards
+     * saves the item in the default Solr core of the Contenthub.
      * 
-     * @param sci
-     *            The {@link SolrContentItem} to be enhanced and saved.
-     * @return The unique ID of the {@link SolrContentItem}.
+     * @param ci
+     *            The {@link ContentItem} to be enhanced and saved.
+     * @param chain
+     *            name of a particular {@link Chain} in which the enhancement engines are ordered according to
+     *            a specific use case or need
+     * @return The unique ID of the {@link ContentItem}.
      * @throws StoreException
      */
-    String enhanceAndPut(SolrContentItem sci) throws StoreException;
+    String enhanceAndPut(ContentItem ci, String chain) throws StoreException;
 
     /**
-     * Sends the {@link SolrContentItem} to the {@link EnhancementJobManager} to enhance the content.
-     * Afterwards saves the item in the Solr core corresponding to the given <code>indexName</code>.
+     * Sends the {@link ContentItem} to the {@link EnhancementJobManager} to enhance the content. Afterwards
+     * saves the item in the Solr core corresponding to the given <code>indexName</code>.
      * 
-     * @param sci
-     *            The {@link SolrContentItem} to be enhanced and saved
+     * @param ci
+     *            The {@link ContentItem} to be enhanced and saved
      * @param indexName
      *            LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core to
      *            store the content item
-     * @return The unique ID of the {@link SolrContentItem}.
+     * @param chain
+     *            name of a particular {@link Chain} in which the enhancement engines are ordered according to
+     *            a specific use case or need
+     * @return The unique ID of the {@link ContentItem}.
      * @throws StoreException
      */
-    String enhanceAndPut(SolrContentItem sci, String indexName) throws StoreException;
+    String enhanceAndPut(ContentItem ci, String indexName, String chain) throws StoreException;
 
     /**
-     * Stores the passed {@link SolrContentItem} in the Solr core corresponding to the specified
+     * Stores the passed {@link ContentItem} in the Solr core corresponding to the specified
      * <code>indexName</code>. If <code>null</code> is passed as the LDPath program name (index name), the
      * default Solr core of Contenthub is used.
      * 
      * @param ci
-     *            {@link SolrContentItem} to be stored
+     *            {@link ContentItem} to be stored
      * @param indexName
      *            LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core to
      *            store the content item
-     * @return The unique ID of the {@link SolrContentItem}.
+     * @return The unique ID of the {@link ContentItem}.
      * @throws StoreException
      */
-    String put(SolrContentItem ci, String indexName) throws StoreException;
+    String put(ContentItem ci, String indexName) throws StoreException;
 
     /**
-     * Retrieves the {@link SolrContentItem} from the Solr core corresponding to the specified
+     * Retrieves the {@link ContentItem} from the Solr core corresponding to the specified
      * <code>indexName</code>. If <code>null</code> is passed as the LDPath program name (index name), the
      * default Solr core of Contenthub is used.
      * 
      * @param id
-     *            The ID of {@link SolrContentItem} to be retrieved.
+     *            The ID of {@link ContentItem} to be retrieved.
      * @param indexName
      *            LDPath program name (name of the Solr core/index) to obtain the corresponding Solr core from
      *            which the content item will be retrieved
-     * @return {@link SolrContentItem} having the specified id
+     * @return {@link ContentItem} having the specified id
      * @throws StoreException
      */
-    SolrContentItem get(String id, String indexName) throws StoreException;
+    ContentItem get(String id, String indexName) throws StoreException;
 
     /**
      * Deletes the {@link ContentItem} from the default Solr core/index of Contenthub.

Modified: stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java?rev=1414034&r1=1414033&r2=1414034&view=diff
==============================================================================
--- stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java (original)
+++ stanbol/trunk/contenthub/store/solr/src/main/java/org/apache/stanbol/contenthub/store/solr/SolrStoreImpl.java Tue Nov 27 09:37:36 2012
@@ -18,15 +18,13 @@
 package org.apache.stanbol.contenthub.store.solr;
 
 import java.io.IOException;
-import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.Dictionary;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -35,6 +33,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
+import javax.ws.rs.core.MediaType;
+
 import org.apache.clerezza.rdf.core.Literal;
 import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.Resource;
@@ -67,18 +67,21 @@ import org.apache.stanbol.contenthub.ser
 import org.apache.stanbol.contenthub.servicesapi.ldpath.LDPathException;
 import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
 import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
-import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
 import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrStore;
 import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary;
 import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
 import org.apache.stanbol.contenthub.store.solr.manager.SolrCoreManager;
-import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
 import org.apache.stanbol.contenthub.store.solr.util.QueryGenerator;
 import org.apache.stanbol.enhancer.servicesapi.Blob;
+import org.apache.stanbol.enhancer.servicesapi.Chain;
+import org.apache.stanbol.enhancer.servicesapi.ChainManager;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementException;
 import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
+import org.apache.stanbol.enhancer.servicesapi.NoSuchPartException;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
+import org.apache.stanbol.enhancer.servicesapi.impl.ByteArraySource;
 import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.InvalidSyntaxException;
@@ -88,9 +91,6 @@ import org.osgi.service.component.Compon
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.model.programs.Program;
-
 /**
  * 
  * @author anil.sinaci
@@ -102,10 +102,16 @@ public class SolrStoreImpl implements So
 
     private static final Logger log = LoggerFactory.getLogger(SolrStoreImpl.class);
 
+    private static final Set<String> SUPPORTED_MIMETYPES = Collections.unmodifiableSet(new HashSet<String>(
+            Arrays.asList(MediaType.TEXT_HTML, MediaType.TEXT_PLAIN, MediaType.TEXT_XML)));
+
     @Reference
     private ManagedSolrServer managedSolrServer;
 
     @Reference
+    private ContentItemFactory ciFactory;
+
+    @Reference
     private TcManager tcManager;
 
     @Reference
@@ -114,6 +120,9 @@ public class SolrStoreImpl implements So
     @Reference
     private SemanticIndexManager semanticIndexManager;
 
+    @Reference
+    private ChainManager chainManager;
+
     private BundleContext bundleContext;
 
     private ServiceRegistration enhancementGraphRegistry;
@@ -137,8 +146,8 @@ public class SolrStoreImpl implements So
     }
 
     @Override
-    public SolrContentItem create(String id, byte[] content, String contentType) {
-        return create(content, id, "", contentType, null);
+    public ContentItem create(String id, byte[] content, String contentType) throws StoreException {
+        return create(content, id, "", contentType);
     }
 
     @Override
@@ -188,71 +197,48 @@ public class SolrStoreImpl implements So
     }
 
     @Override
-    public SolrContentItem create(byte[] content,
-                                  String id,
-                                  String title,
-                                  String contentType,
-                                  Map<String,List<Object>> constraints) {
+    public ContentItem create(byte[] content, String id, String title, String contentType) throws StoreException {
         UriRef uri;
         if (id == null || id.isEmpty()) {
-            uri = ContentItemHelper.makeDefaultUri(ContentItemIDOrganizer.CONTENT_ITEM_URI_PREFIX, content);
+            uri = ContentItemHelper.makeDefaultUrn(content);
         } else {
-            uri = new UriRef(ContentItemIDOrganizer.attachBaseURI(id));
+            uri = new UriRef(id);
         }
         log.debug("Created ContentItem with id:{} and uri:{}", id, uri);
         final MGraph g = new IndexedMGraph();
-        return new SolrContentItemImpl(uri.getUnicodeString(), title, content, contentType, g, constraints);
-    }
-
-    private Object inferObjectType(Object val) {
-        Object ret = null;
+        ContentItem ci = null;
         try {
-            ret = DateFormat.getInstance().parse(val.toString());
-        } catch (Exception e) {
-            try {
-                ret = Long.valueOf(val.toString());
-            } catch (Exception e1) {
-                try {
-                    ret = Double.valueOf(val.toString());
-                } catch (Exception e2) {
-                    try {
-                        ret = String.valueOf(val.toString());
-                    } catch (Exception e3) {}
-                }
-            }
-        }
-
-        if (ret == null) ret = val;
-        return ret;
-    }
-
-    private String addSolrDynamicFieldExtension(String fieldName, Object[] values) {
-        for (int i = 0; i < values.length; i++) {
-            values[i] = inferObjectType(values[i]);
+            ci = ciFactory.createContentItem(uri, new ByteArraySource(content, contentType), g);
+        } catch (IOException e) {
+            log.error("Failed to create contentitem with uri: {}", uri.getUnicodeString());
+            throw new StoreException(String.format("Failed to create contentitem with uri: %s",
+                uri.getUnicodeString()));
         }
-        Object typed = values[0];
-        String dynamicFieldName = fieldName;
-        if (typed instanceof String) {
-            dynamicFieldName += SolrVocabulary.SOLR_DYNAMIC_FIELD_TEXT;
-        } else if (typed instanceof Long) {
-            dynamicFieldName += SolrVocabulary.SOLR_DYNAMIC_FIELD_LONG;
-        } else if (typed instanceof Double) {
-            dynamicFieldName += SolrVocabulary.SOLR_DYNAMIC_FIELD_DOUBLE;
-        } else if (typed instanceof Date) {
-            dynamicFieldName += SolrVocabulary.SOLR_DYNAMIC_FIELD_DATE;
+        if (title != null && !title.trim().isEmpty()) {
+            ci.addPart(TITLE_URI, title.trim());
         }
-        return dynamicFieldName;
+        return ci;
     }
 
-    private void enhance(SolrContentItem sci) throws StoreException {
+    private void enhance(ContentItem ci, String chainName) throws StoreException {
         try {
-            jobManager.enhanceContent(sci);
+            if (chainName == null || chainName.trim().isEmpty()) {
+                jobManager.enhanceContent(ci);
+            } else {
+                Chain chain = chainManager.getChain(chainName.trim());
+                if (chain == null) {
+                    String msg = String.format("Failed to get chain with name: %s", chainName);
+                    log.error(msg);
+                    throw new StoreException(msg);
+                }
+                jobManager.enhanceContent(ci, chain);
+            }
         } catch (EnhancementException e) {
-            String msg = String.format("Cannot enhance content with id: {}", sci.getUri().getUnicodeString());
+            String msg = String.format("Cannot enhance content with id: %s", ci.getUri().getUnicodeString());
             log.error(msg, e);
             throw new StoreException(msg, e);
         }
-        updateEnhancementGraph(sci);
+        updateEnhancementGraph(ci);
     }
 
     private void removeEnhancements(String id) throws StoreException {
@@ -282,14 +268,14 @@ public class SolrStoreImpl implements So
         enhancementGraph.removeAll(willBeRemoved);
     }
 
-    private void updateEnhancementGraph(SolrContentItem sci) throws StoreException {
+    private void updateEnhancementGraph(ContentItem ci) throws StoreException {
         MGraph enhancementGraph = getEnhancementGraph();
         // Delete old enhancements which belong to this content item from the
         // global enhancements graph.
-        removeEnhancements(sci.getUri().getUnicodeString());
+        removeEnhancements(ci.getUri().getUnicodeString());
         // Add new enhancements of this content item to the global enhancements
         // graph.
-        Iterator<Triple> it = sci.getMetadata().iterator();
+        Iterator<Triple> it = ci.getMetadata().iterator();
         while (it.hasNext()) {
             Triple triple = null;
             try {
@@ -303,25 +289,23 @@ public class SolrStoreImpl implements So
     }
 
     @Override
-    public String enhanceAndPut(SolrContentItem sci) throws StoreException {
-        enhance(sci);
-        return put(sci);
+    public String enhanceAndPut(ContentItem ci, String chainName) throws StoreException {
+        enhance(ci, chainName);
+        return put(ci);
     }
 
     @Override
-    public String enhanceAndPut(SolrContentItem sci, String ldProgramName) throws StoreException {
-        enhance(sci);
-        return put(sci, ldProgramName);
+    public String enhanceAndPut(ContentItem ci, String ldProgramName, String chain) throws StoreException {
+        enhance(ci, chain);
+        return put(ci, ldProgramName);
     }
 
     @Override
     public String put(ContentItem ci) throws StoreException {
         SolrInputDocument doc = new SolrInputDocument();
         addDefaultFields(ci, doc);
-        if (ci instanceof SolrContentItem) {
-            SolrContentItem sci = (SolrContentItem) ci;
-            addSolrSpecificFields(sci, doc);
-        }
+        addSolrSpecificFields(ci, doc);
+
         SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer();
         try {
             solrServer.add(doc);
@@ -329,21 +313,23 @@ public class SolrStoreImpl implements So
             log.debug("Documents are committed to Solr Server successfully.");
         } catch (SolrServerException e) {
             log.error("Solr Server Exception", e);
+            throw new StoreException("Solr Server Exception", e);
         } catch (IOException e) {
             log.error("IOException", e);
+            throw new StoreException("IOException", e);
         }
         return ci.getUri().getUnicodeString();
     }
 
     @Override
-    public String put(SolrContentItem sci, String ldProgramName) throws StoreException {
+    public String put(ContentItem ci, String ldProgramName) throws StoreException {
         if (ldProgramName == null || ldProgramName.isEmpty()
             || ldProgramName.equals(SolrCoreManager.CONTENTHUB_DEFAULT_INDEX_NAME)) {
-            return put(sci);
+            return put(ci);
         }
         SolrInputDocument doc = new SolrInputDocument();
-        addDefaultFields(sci, doc);
-        addSolrSpecificFields(sci, doc, ldProgramName);
+        addDefaultFields(ci, doc);
+        addSolrSpecificFields(ci, doc, ldProgramName);
         SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(
             ldProgramName);
         try {
@@ -357,7 +343,7 @@ public class SolrStoreImpl implements So
             log.error("IOException", e);
             throw new StoreException(e.getMessage(), e);
         }
-        return sci.getUri().getUnicodeString();
+        return ci.getUri().getUnicodeString();
     }
 
     private void addDefaultFields(ContentItem ci, SolrInputDocument doc) throws StoreException {
@@ -368,25 +354,23 @@ public class SolrStoreImpl implements So
         }
 
         String content = null;
-        try {
-            Entry<UriRef,Blob> contentPart = ContentItemHelper.getBlob(ci,
-                Collections.singleton("text/plain"));
-            if (contentPart == null) {
-                throw new StoreException("There is no textual for the content item");
+        Entry<UriRef,Blob> contentPart = ContentItemHelper.getBlob(ci, SUPPORTED_MIMETYPES);
+        if (contentPart != null) {
+            try {
+                content = ContentItemHelper.getText(contentPart.getValue());
+            } catch (IOException ex) {
+                String msg = "Cannot read the stream of the ContentItem.";
+                log.error(msg, ex);
+                throw new StoreException(msg, ex);
             }
-            content = ContentItemHelper.getText(contentPart.getValue());
-        } catch (IOException ex) {
-            String msg = "Cannot read the stream of the ContentItem.";
-            log.error(msg, ex);
-            throw new StoreException(msg, ex);
-        }
+            doc.addField(SolrFieldName.CONTENT.toString(), content);
+        } 
 
         Calendar cal = Calendar.getInstance();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
         String creationDate = sdf.format(cal.getTime());
 
         doc.addField(SolrFieldName.ID.toString(), ci.getUri().getUnicodeString());
-        doc.addField(SolrFieldName.CONTENT.toString(), content);
         try {
             doc.addField(SolrFieldName.BINARYCONTENT.toString(), IOUtils.toByteArray(ci.getStream()));
         } catch (IOException e) {
@@ -406,40 +390,16 @@ public class SolrStoreImpl implements So
         doc.addField(SolrFieldName.ENHANCEMENTCOUNT.toString(), enhancementCount);
     }
 
-    private boolean fieldAlreadyIndexedInProgram(String programName, String fieldName) {
-        Program<Object> program = semanticIndexManager.getParsedProgramByName(programName);
-        Iterator<FieldMapping<?,Object>> it = program.getFields().iterator();
-        while (it.hasNext()) {
-            FieldMapping<?,Object> fm = it.next();
-            if (fm.getFieldName().equals(fieldName)) return true;
-        }
-        return false;
-    }
-
-    private void addConstraints(SolrContentItem sci, SolrInputDocument doc, String programName) {
-        if (sci.getConstraints() != null) {
-            for (Entry<String,List<Object>> constraint : sci.getConstraints().entrySet()) {
-                Object[] values = constraint.getValue().toArray();
-                if (values == null || values.length == 0) continue;
-                String fieldName = constraint.getKey();
-                if (programName != null && fieldAlreadyIndexedInProgram(programName, fieldName)) {
-                    continue;
-                }
-                if (!SolrFieldName.isNameReserved(fieldName)) {
-                    fieldName = addSolrDynamicFieldExtension(constraint.getKey(), values);
-                }
-                doc.addField(fieldName, values);
-                // Now add for the text indexing dynamic field
-                addIndexedTextDynamicField(doc, fieldName, values);
-            }
+    private void addSolrSpecificFields(ContentItem ci, SolrInputDocument doc, String ldProgramName) {
+        String title = null;
+        try {
+            title = ci.getPart(TITLE_URI, String.class);
+        } catch (NoSuchPartException e) {
+            title = ci.getUri().getUnicodeString();
         }
-    }
-
-    private void addSolrSpecificFields(SolrContentItem sci, SolrInputDocument doc, String ldProgramName) {
-        doc.addField(SolrFieldName.TITLE.toString(), sci.getTitle());
-        addConstraints(sci, doc, ldProgramName);
+        doc.addField(SolrFieldName.TITLE.toString(), title);
         try {
-            Iterator<Triple> it = sci.getMetadata().filter(null, Properties.ENHANCER_ENTITY_REFERENCE, null);
+            Iterator<Triple> it = ci.getMetadata().filter(null, Properties.ENHANCER_ENTITY_REFERENCE, null);
             Set<String> contexts = new HashSet<String>();
             while (it.hasNext()) {
                 Resource r = it.next().getObject();
@@ -447,39 +407,45 @@ public class SolrStoreImpl implements So
                     contexts.add(((UriRef) r).getUnicodeString());
                 }
             }
-            Map<String,Collection<?>> results = semanticIndexManager.executeProgram(ldProgramName, contexts);
+            Map<String,Collection<?>> results = semanticIndexManager.executeProgram(ldProgramName, contexts,
+                ci);
             for (Entry<String,Collection<?>> entry : results.entrySet()) {
                 doc.addField(entry.getKey(), entry.getValue());
             }
         } catch (LDPathException e) {
-            log.error("Cannot execute the ldPathProgram on SolrContentItem's metadata", e);
+            log.error("Cannot execute the ldPathProgram on ContentItem's metadata", e);
         }
     }
 
-    private void addSolrSpecificFields(SolrContentItem sci, SolrInputDocument doc) {
-        doc.addField(SolrFieldName.TITLE.toString(), sci.getTitle());
-        addConstraints(sci, doc, null);
-        if (sci.getMetadata() != null) {
-            addSemanticFields(sci, doc);
-            addAnnotatedEntityFieldNames(sci, doc);
+    private void addSolrSpecificFields(ContentItem ci, SolrInputDocument doc) {
+        String title = null;
+        try {
+            title = ci.getPart(TITLE_URI, String.class);
+        } catch (NoSuchPartException e) {
+            title = ci.getUri().getUnicodeString();
+        }
+        doc.addField(SolrFieldName.TITLE.toString(), title);
+        if (ci.getMetadata() != null) {
+            addSemanticFields(ci, doc);
+            addAnnotatedEntityFieldNames(ci, doc);
         } else {
-            log.debug("There are no enhancements for the content item {}", sci.getUri().getUnicodeString());
+            log.debug("There are no enhancements for the content item {}", ci.getUri().getUnicodeString());
         }
     }
 
-    private void addSemanticFields(SolrContentItem sci, SolrInputDocument doc) {
+    private void addSemanticFields(ContentItem ci, SolrInputDocument doc) {
         for (SolrFieldName fn : SolrFieldName.getSemanticFieldNames()) {
-            addField(sci, doc, fn);
+            addField(ci, doc, fn);
         }
     }
 
-    private void addAnnotatedEntityFieldNames(SolrContentItem sci, SolrInputDocument doc) {
+    private void addAnnotatedEntityFieldNames(ContentItem ci, SolrInputDocument doc) {
         for (SolrFieldName fn : SolrFieldName.getAnnotatedEntityFieldNames()) {
-            addField(sci, doc, fn);
+            addField(ci, doc, fn);
         }
     }
 
-    private void addField(SolrContentItem sci, SolrInputDocument doc, SolrFieldName fieldName) {
+    private void addField(ContentItem ci, SolrInputDocument doc, SolrFieldName fieldName) {
         SelectQuery query = null;
         try {
             query = (SelectQuery) QueryParser.getInstance().parse(QueryGenerator.getFieldQuery(fieldName));
@@ -490,8 +456,7 @@ public class SolrStoreImpl implements So
             return;
         }
 
-        sci.getMetadata();
-        ResultSet result = tcManager.executeSparqlQuery(query, sci.getMetadata());
+        ResultSet result = tcManager.executeSparqlQuery(query, ci.getMetadata());
         List<String> values = new ArrayList<String>();
         while (result.hasNext()) {
             SolutionMapping sol = result.next();
@@ -530,14 +495,14 @@ public class SolrStoreImpl implements So
 
     // TODO: we can use cache for "Recently uploaded Content Items"..
     @Override
-    public SolrContentItem get(String id, String ldProgramName) throws StoreException {
-        id = ContentItemIDOrganizer.attachBaseURI(id);
+    public ContentItem get(String id, String ldProgramName) throws StoreException {
+        if (id == null) {
+            throw new IllegalArgumentException("Id of the requested ContentItem cannot be null");
+        }
         SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(
             ldProgramName);
         byte[] content = null;
         String mimeType = null;
-        String title = null;
-        Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
 
         SolrQuery query = new SolrQuery();
         StringBuilder queryString = new StringBuilder();
@@ -554,17 +519,6 @@ public class SolrStoreImpl implements So
                 SolrDocument result = results.get(0);
                 content = (byte[]) result.getFieldValue(SolrFieldName.BINARYCONTENT.toString());
                 mimeType = (String) result.getFieldValue(SolrFieldName.MIMETYPE.toString());
-                title = (String) result.getFieldValue(SolrFieldName.TITLE.toString());
-
-                Iterator<Entry<String,Object>> itr = result.iterator();
-                while (itr.hasNext()) {
-                    Entry<String,Object> entry = itr.next();
-                    String key = entry.getKey();
-                    if (!SolrFieldName.isNameReserved(key)) {
-                        List<Object> values = (List<Object>) result.getFieldValues(key);
-                        constraints.put(key, values);
-                    }
-                }
             } else {
                 log.warn("No matching item in Solr for the given id {}.", id);
                 return null;
@@ -595,8 +549,15 @@ public class SolrStoreImpl implements So
                 metadata.add(triple);
             }
         }
-
-        return new SolrContentItemImpl(id, title, content, mimeType, metadata, constraints);
+        ContentItem ci = null;
+        try {
+            ci = ciFactory
+                    .createContentItem(new UriRef(id), new ByteArraySource(content, mimeType), metadata);
+        } catch (IOException e) {
+            log.error("Failed to create contentitem with uri: {}", id);
+            throw new StoreException(String.format("Failed to create contentitem with uri: %s", id));
+        }
+        return ci;
     }
 
     @Override
@@ -604,7 +565,6 @@ public class SolrStoreImpl implements So
         if (id == null || id.isEmpty()) return;
         SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(
             ldProgramName);
-        id = ContentItemIDOrganizer.attachBaseURI(id);
         removeEnhancements(id);
         try {
             solrServer.deleteById(id);
@@ -628,7 +588,7 @@ public class SolrStoreImpl implements So
         SolrServer solrServer = SolrCoreManager.getInstance(bundleContext, managedSolrServer).getServer(
             ldProgramName);
         for (int i = 0; i < idList.size(); i++) {
-            String id = ContentItemIDOrganizer.attachBaseURI(idList.get(i));
+            String id = idList.get(i);
             idList.remove(i);
             idList.add(i, id);
         }