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 2011/10/27 17:29:18 UTC

svn commit: r1189807 [1/2] - in /incubator/stanbol/trunk/cmsadapter: cmis/ cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/ cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/ cmis/src/main/java/org/apache/stanbol/cmsadapter...

Author: suat
Date: Thu Oct 27 15:29:17 2011
New Revision: 1189807

URL: http://svn.apache.org/viewvc?rev=1189807&view=rev
Log:
STANBOL-364:
Added implementation for the CMS Adapter feature that provides submission of content repository objects to Contenthub. The main interface offering the functionality is ContenthubFeeder. There are two implementations of it for JCR and CMIS content repositories.

These implementations basically create SolrContentItems from JCR nodes or CMIS documents and submit them to the Contenthub. Properties of these content repository objects are also indexed in Solr as external metadata together with the actual content. Indexed properties are used to provide faceted search over the submitted documents.

It is also possible to delete content items from Contenthub based on the content repository IDs or paths of nodes/documents.

Added:
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISContenthubFeeder.java
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISRDFMapper.java
      - copied, changed from r1170391, incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/CMISRDFMapper.java
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/CMISUtils.java
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRContenthubFeeder.java
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRRDFMapper.java
      - copied, changed from r1170391, incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRDFMapper.java
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/JCRUtils.java
    incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContentItemFilter.java
    incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeeder.java
    incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeederException.java
    incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/repository/ConnectionInfo.java
    incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/
    incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/index.ftl
Removed:
    incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/CMISRDFMapper.java
    incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRDFMapper.java
Modified:
    incubator/stanbol/trunk/cmsadapter/cmis/pom.xml
    incubator/stanbol/trunk/cmsadapter/jcr/pom.xml
    incubator/stanbol/trunk/cmsadapter/parent/pom.xml
    incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource/index.ftl
    incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RootResource/index.ftl

Modified: incubator/stanbol/trunk/cmsadapter/cmis/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/cmis/pom.xml?rev=1189807&r1=1189806&r2=1189807&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/cmis/pom.xml (original)
+++ incubator/stanbol/trunk/cmsadapter/cmis/pom.xml Thu Oct 27 15:29:17 2011
@@ -50,6 +50,18 @@
 			<artifactId>org.apache.stanbol.cmsadapter.core</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
+		</dependency>
+		
+		<!-- Enhancer -->
+		<!-- This dependency is needed only for implicit Store interface -->
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
+		</dependency>
+		
+		<dependency>
 			<groupId>org.apache.felix</groupId>
 			<artifactId>org.apache.felix.scr.annotations</artifactId>
 		</dependency>
@@ -77,6 +89,11 @@
 			<groupId>org.apache.clerezza</groupId>
 			<artifactId>rdf.core</artifactId>
 		</dependency>
+		
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+		</dependency>
 	</dependencies>
 
 </project>

Added: incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISContenthubFeeder.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISContenthubFeeder.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISContenthubFeeder.java (added)
+++ incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISContenthubFeeder.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,328 @@
+/*
+ * 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.cmsadapter.cmis.mapping;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.chemistry.opencmis.client.api.CmisObject;
+import org.apache.chemistry.opencmis.client.api.Document;
+import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.clerezza.rdf.core.Literal;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+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.Reference;
+import org.apache.stanbol.cmsadapter.cmis.repository.CMISObjectId;
+import org.apache.stanbol.cmsadapter.cmis.utils.CMISUtils;
+import org.apache.stanbol.cmsadapter.core.mapping.RDFBridgeHelper;
+import org.apache.stanbol.cmsadapter.servicesapi.helper.NamespaceEnum;
+import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContentItemFilter;
+import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContenthubFeeder;
+import org.apache.stanbol.cmsadapter.servicesapi.repository.ConnectionInfo;
+import org.apache.stanbol.contenthub.servicesapi.store.SolrContentItem;
+import org.apache.stanbol.contenthub.servicesapi.store.SolrStore;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This an implementation of {@link ContenthubFeeder} interface for CMIS repositories. It basically transforms
+ * {@link Document}s in the CMIS content repository into content items in Contenthub based on the paths or IDs
+ * of documents. Properties (e.g <i>cmis:createdBy</i>) of the documents that are not included in the
+ * <code>excludedProperties</code> list below, are indexed as metadata of the content item. Furthermore,
+ * triples extracted from the metadata documents whose names are formed by <b>"actual_document_name" +
+ * "_metadata"</b> are also considered as metadata of the actual document in a similar way as default CMIS
+ * properties. Metadata of the the content items provides faceted search feature in the Contenthub.
+ * 
+ * @author suat
+ * 
+ */
+@Component(factory = ContenthubFeeder.CMIS_CONTENTUB_FEEDER_FACTORY)
+public class CMISContenthubFeeder implements ContenthubFeeder {
+
+    private static final Logger log = LoggerFactory.getLogger(CMISContenthubFeeder.class);
+
+    @Reference
+    private SolrStore solrStore;
+
+    @Reference
+    Parser parser;
+
+    private Session session = null;
+
+    /*
+     * These properties will not be indexed
+     */
+    private static List<String> excludedProperties;
+    static {
+        excludedProperties = new ArrayList<String>();
+        excludedProperties.add("cmis:objectId");
+        excludedProperties.add("cmis:changeToken");
+        excludedProperties.add("cmis:versionSeriesId");
+        excludedProperties.add("cmis:versionSeriesCheckedOutId");
+        excludedProperties.add("cmis:versionSeriesCheckedOutBy");
+        excludedProperties.add("cmis:contentStreamId");
+        excludedProperties.add("cmis:contentStreamLength");
+        excludedProperties.add("cmis:isImmutable");
+        excludedProperties.add("cmis:isMajorVersion");
+        excludedProperties.add("cmis:isLatestMajorVersion");
+        excludedProperties.add("cmis:isVersionSeriesCheckedOut");
+        excludedProperties.add("cmis:contentStreamFileName");
+    }
+
+    @SuppressWarnings("unchecked")
+    @Activate
+    protected void activate(ComponentContext context) throws ConfigurationException {
+        Dictionary<String,Object> properties = (Dictionary<String,Object>) context.getProperties();
+        checkSession(properties);
+    }
+
+    @Override
+    public void submitContentItemByID(String contentItemID) {
+        CmisObject o;
+        try {
+            o = session.getObject(CMISObjectId.getObjectId(contentItemID));
+        } catch (CmisBaseException e) {
+            log.warn("Failed to retrieve document having id: {}", contentItemID);
+            return;
+        }
+
+        if (hasType(o, BaseTypeId.CMIS_DOCUMENT)) {
+            processDocumentAndSubmitToContenthub((Document) o);
+        }
+    }
+
+    @Override
+    public void submitContentItemByPath(String contentItemPath) {
+        CmisObject o;
+        try {
+            o = session.getObjectByPath(contentItemPath);
+        } catch (CmisBaseException e) {
+            log.warn("Failed to retrieve document having path: {}", contentItemPath);
+            return;
+        }
+
+        if (hasType(o, BaseTypeId.CMIS_DOCUMENT)) {
+            processDocumentAndSubmitToContenthub((Document) o);
+        }
+    }
+
+    @Override
+    public void submitContentItemsUnderPath(String rootPath) {
+        CmisObject o;
+        try {
+            o = session.getObjectByPath(rootPath);
+        } catch (CmisBaseException e) {
+            log.warn("Failed to retrieve object having path: {}", rootPath);
+            return;
+        }
+
+        if (hasType(o, BaseTypeId.CMIS_DOCUMENT)) {
+            processDocumentAndSubmitToContenthub((Document) o);
+        } else {
+            List<Document> documents = new ArrayList<Document>();
+            getDocumentsUnderFolder((Folder) o, documents);
+            for (Document d : documents) {
+                processDocumentAndSubmitToContenthub(d);
+            }
+        }
+    }
+
+    @Override
+    public void submitContentItemsByCustomFilter(ContentItemFilter customContentItemFilter) {
+        throw new UnsupportedOperationException("This operation is not supported in this implementation");
+    }
+
+    @Override
+    public void deleteContentItemByID(String contentItemID) {
+        solrStore.deleteById(contentItemID);
+    }
+
+    @Override
+    public void deleteContentItemByPath(String contentItemPath) {
+        CmisObject o;
+        try {
+            o = session.getObjectByPath(contentItemPath);
+        } catch (CmisBaseException e) {
+            log.warn("Failed to retrieve document having path: {}", contentItemPath);
+            return;
+        }
+
+        solrStore.deleteById(o.getId());
+    }
+
+    @Override
+    public void deleteContentItemsUnderPath(String rootPath) {
+        CmisObject o;
+        try {
+            o = session.getObjectByPath(rootPath);
+        } catch (CmisBaseException e) {
+            log.warn("Failed to retrieve document having path: {}", rootPath);
+            return;
+        }
+
+        List<Document> documents = new ArrayList<Document>();
+        if (hasType(o, BaseTypeId.CMIS_DOCUMENT)) {
+            documents.add((Document) o);
+        } else {
+            getDocumentsUnderFolder((Folder) o, documents);
+        }
+        for (Document d : documents) {
+            solrStore.deleteById(d.getId());
+        }
+    }
+
+    @Override
+    public void deleteContentItemsByCustomFilter(ContentItemFilter customContentItemFilter) {
+        throw new UnsupportedOperationException("This operation is not supported in this implementation");
+    }
+
+    @Override
+    public boolean canFeed(String connectionType) {
+        return connectionType.contentEquals(ConnectionInfo.CMIS_CONNECTION_STRING);
+    }
+
+    private void checkSession(Dictionary<String,Object> properties) throws ConfigurationException {
+        Object value = properties.get(ContenthubFeeder.PROP_SESSION);
+        if (value == null) {
+            throw new ConfigurationException(PROP_SESSION,
+                    "A CMIS Session should be provided to activate this component.");
+        }
+        this.session = (Session) value;
+    }
+
+    private void processDocumentAndSubmitToContenthub(Document d) {
+        byte[] content;
+        try {
+            content = IOUtils.toByteArray(d.getContentStream().getStream());
+            if (content == null || content.length == 0) {
+                log.warn("Failed to retrieve content for node: {}", d.getName());
+                return;
+            }
+        } catch (IOException e) {
+            log.warn("Failed to get bytes from binary content of document: {}", d.getName(), e);
+            return;
+        }
+        String mimeType = d.getContentStreamMimeType();
+        Map<String,List<Object>> constraints = getConstraintsFromDocument(d);
+        SolrContentItem sci = solrStore.create(d.getId(), content, mimeType, constraints);
+        solrStore.enhanceAndPut(sci);
+        log.info("Document submitted to Contenthub.");
+        log.info("Id: {}", sci.getId());
+        log.info("Mime type: {}", sci.getMimeType());
+        log.info("Constraints: {}", sci.getConstraints().toString());
+    }
+
+    private Map<String,List<Object>> getConstraintsFromDocument(Document d) {
+        Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
+        List<org.apache.chemistry.opencmis.client.api.Property<?>> docProps = d.getProperties();
+        for (org.apache.chemistry.opencmis.client.api.Property<?> p : docProps) {
+            if (!excludedProperties.contains(p.getQueryName())) {
+                PropertyType t = p.getType();
+                List<Object> values = new ArrayList<Object>();
+                if (p.isMultiValued()) {
+                    values.addAll(CMISUtils.getTypedPropertyValues(t, p.getValues()));
+                } else {
+                    values.add(CMISUtils.getTypedPropertyValue(t, p.getValue()));
+                }
+                constraints.put(p.getQueryName(), values);
+            }
+        }
+        checkMetadataDocument(d, constraints);
+        return constraints;
+    }
+
+    private void checkMetadataDocument(Document d, Map<String,List<Object>> constraints) {
+        List<Folder> parents = d.getParents();
+        for (Folder parent : parents) {
+            Iterator<CmisObject> children = parent.getChildren().iterator();
+            while (children.hasNext()) {
+                CmisObject child = children.next();
+                if (hasType(child, BaseTypeId.CMIS_DOCUMENT)
+                    && child.getName().equals(d.getName() + CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION)) {
+
+                    MGraph metadata = new SimpleMGraph();
+                    ContentStream cs = ((Document) child).getContentStream();
+                    parser.parse(metadata, cs.getStream(), SupportedFormat.RDF_XML);
+
+                    Iterator<Triple> triples = metadata.filter(null, null, null);
+                    while (triples.hasNext()) {
+                        Triple t = triples.next();
+                        String predicate = t.getPredicate().getUnicodeString();
+                        String shortPredicate = NamespaceEnum.getShortName(predicate);
+                        Resource resource = t.getObject();
+
+                        String propValue = "";
+                        if (resource instanceof Literal) {
+                            propValue = RDFBridgeHelper.getResourceStringValue(resource);
+                        } else if (resource instanceof UriRef) {
+                            propValue = ((UriRef) resource).getUnicodeString();
+                        } else {
+                            propValue = resource.toString();
+                        }
+
+                        if (constraints.containsKey(shortPredicate)) {
+                            constraints.get(shortPredicate).add(propValue);
+                        } else {
+                            List<Object> valueList = new ArrayList<Object>();
+                            valueList.add(propValue);
+                            constraints.put(shortPredicate, valueList);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private void getDocumentsUnderFolder(Folder f, List<Document> documentList) {
+        Iterator<CmisObject> childs = f.getChildren().iterator();
+        while (childs.hasNext()) {
+            CmisObject child = childs.next();
+            if (hasType(child, BaseTypeId.CMIS_FOLDER)) {
+                getDocumentsUnderFolder((Folder) child, documentList);
+            } else if (hasType(child, BaseTypeId.CMIS_DOCUMENT)) {
+                String documentName = child.getName();
+                if (!documentName.endsWith(CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION)) {
+                    documentList.add((Document) child);
+                }
+            }
+        }
+    }
+
+    private boolean hasType(CmisObject o, BaseTypeId type) {
+        return o.getBaseTypeId().equals(type);
+    }
+}

Copied: incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISRDFMapper.java (from r1170391, incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/CMISRDFMapper.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISRDFMapper.java?p2=incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISRDFMapper.java&p1=incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/CMISRDFMapper.java&r1=1170391&r2=1189807&rev=1189807&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/repository/CMISRDFMapper.java (original)
+++ incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/mapping/CMISRDFMapper.java Thu Oct 27 15:29:17 2011
@@ -14,14 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.stanbol.cmsadapter.cmis.repository;
+package org.apache.stanbol.cmsadapter.cmis.mapping;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.util.ArrayList;
-import java.util.Calendar;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -52,6 +51,7 @@ import org.apache.clerezza.rdf.core.seri
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.cmsadapter.cmis.utils.CMISUtils;
 import org.apache.stanbol.cmsadapter.core.mapping.BaseRDFMapper;
 import org.apache.stanbol.cmsadapter.core.mapping.RDFBridgeHelper;
 import org.apache.stanbol.cmsadapter.servicesapi.helper.CMSAdapterVocabulary;
@@ -82,8 +82,6 @@ import org.slf4j.LoggerFactory;
 public class CMISRDFMapper extends BaseRDFMapper implements RDFMapper {
     private static final Logger log = LoggerFactory.getLogger(CMISRDFMapper.class);
 
-    private static final String DOCUMENT_RDF = "_metadata";
-
     private static final String DOCUMENT_RDF_MIME_TYPE = "text/plain";
 
     @Reference
@@ -144,14 +142,16 @@ public class CMISRDFMapper extends BaseR
                 CMSAdapterVocabulary.CMS_OBJECT_NAME, graph);
             createObject(containerFolder, childSubject, documentURI, childName, graph, session);
         }
+        // Log level may be set as 'debug'
+        log.info(String.format("Created object: %s,  Object parent: %s", documentName, parent.getPath()));
     }
 
     /**
      * This method creates the actual object in the content repository. The type of the object to be created
      * is determined by following conditions:
      * <p>
-     * First if its base type is set by {@link CMSAdapterVocabulary#CMIS_BASE_TYPE_ID} predicate and it is set as
-     * <b>cmis:folder</b> or <b>cmis:document</b>.
+     * First if its base type is set by {@link CMSAdapterVocabulary#CMIS_BASE_TYPE_ID} predicate and it is set
+     * as <b>cmis:folder</b> or <b>cmis:document</b>.
      * <p>
      * If the base type of the object is not set, its parent assertion is checked. If it has a parent
      * assertion through {@link CMSAdapterVocabulary#CMS_OBJECT_PARENT_REF}, is rdf:type assertion is checked.
@@ -166,9 +166,9 @@ public class CMISRDFMapper extends BaseR
      * {@link Document}.
      * <p>
      * For any object created an additional metadata document is created. This document has the name <b>
-     * <code>objectName + {@link #DOCUMENT_RDF}</code></b>. This document is created so that content
-     * management systems would manage semantic information content repository object within their own
-     * systems.
+     * <code>objectName + {@link #RDF_METADATA_DOCUMENT_EXTENSION}</code></b>. This document is created so
+     * that content management systems would manage semantic information content repository object within
+     * their own systems.
      * 
      * @param objectName
      * @param documentURI
@@ -223,11 +223,11 @@ public class CMISRDFMapper extends BaseR
             createdObject = createDocumentByPath(parentFolder, objectName, objectPath, null, session);
         }
 
-        String rdfDocumentName = objectName + DOCUMENT_RDF;
-        String rdfDocumentPath = objectPath + DOCUMENT_RDF;
+        String rdfDocumentName = objectName + CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION;
+        String rdfDocumentPath = objectPath + CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION;
 
         createDocumentByPath(parentFolder, rdfDocumentName, rdfDocumentPath,
-            getDocumentContentStream(createdObject, rdfDocumentName, documentURI, graph), session);
+            createDocumentContentStream(createdObject, rdfDocumentName, documentURI, graph), session);
         return createdFolder;
     }
 
@@ -259,11 +259,11 @@ public class CMISRDFMapper extends BaseR
         return it.hasNext();
     }
 
-    private ContentStream getDocumentContentStream(CmisObject createdObject,
-                                                   String documentName,
-                                                   NonLiteral documentURI,
-                                                   MGraph graph) {
-        MGraph documentMGraph = collectedDocumentResources(createdObject, documentURI, graph);
+    private ContentStream createDocumentContentStream(CmisObject createdObject,
+                                                      String documentName,
+                                                      NonLiteral documentURI,
+                                                      MGraph graph) {
+        MGraph documentMGraph = collectDocumentResources(createdObject, documentURI, graph);
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
         serializer.serialize(baos, documentMGraph, SupportedFormat.RDF_XML);
         byte[] serializedGraph = baos.toByteArray();
@@ -274,7 +274,7 @@ public class CMISRDFMapper extends BaseR
         return contentStream;
     }
 
-    private MGraph collectedDocumentResources(CmisObject createdObject, NonLiteral subject, MGraph graph) {
+    private MGraph collectDocumentResources(CmisObject createdObject, NonLiteral subject, MGraph graph) {
         boolean sameObject = true;
         if (createdObject.getId().contentEquals(RDFBridgeHelper.removeEndCharacters(subject.toString()))) {
             sameObject = false;
@@ -407,7 +407,7 @@ public class CMISRDFMapper extends BaseR
     private MGraph getGraphForObject(CmisObject o, Folder parentFolder, NonLiteral parentURI) {
         MGraph graph = new SimpleMGraph();
         // check metadata
-        if (o.getName().endsWith(DOCUMENT_RDF)) {
+        if (o.getName().endsWith(CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION)) {
             return graph;
         }
 
@@ -456,9 +456,9 @@ public class CMISRDFMapper extends BaseR
 
             List<Object> values = new ArrayList<Object>();
             if (p.isMultiValued()) {
-                values.addAll(getTypedPropertyValues(t, p.getValues()));
+                values.addAll(CMISUtils.getTypedPropertyValues(t, p.getValues()));
             } else {
-                values.add(getTypedPropertyValue(t, p.getValue()));
+                values.add(CMISUtils.getTypedPropertyValue(t, p.getValue()));
             }
 
             for (Object val : values) {
@@ -484,44 +484,6 @@ public class CMISRDFMapper extends BaseR
         RDFBridgeHelper.createDefaultPropertiesForRDF(subject, g, path, o.getName());
     }
 
-    private List<Object> getTypedPropertyValues(PropertyType property, List<?> values) {
-        List<Object> typedValues = new ArrayList<Object>();
-        if (values != null) {
-            for (Object v : values) {
-                typedValues.add(getTypedPropertyValue(property, v));
-            }
-        }
-        return typedValues;
-    }
-
-    private Object getTypedPropertyValue(PropertyType propertyType, Object value) {
-        if (value == null) {
-            return value;
-        }
-        switch (propertyType) {
-            case BOOLEAN:
-                return (Boolean) value;
-            case DECIMAL:
-                return (Integer) value;
-            case DATETIME:
-                return ((Calendar) value).getTime();
-            case HTML:
-                // not meet with this property
-                return null;
-            case ID:
-                return value.toString();
-            case INTEGER:
-                return ((BigInteger) value).intValue();
-            case STRING:
-                return value;
-            case URI:
-                // not meet with this property
-                return new UriRef(value.toString());
-            default:
-                return value.toString();
-        }
-    }
-
     private NonLiteral getObjectURI(CmisObject o, MGraph metadata) {
         Iterator<Triple> it = metadata.filter(null, null, null);
         if (it.hasNext()) {
@@ -551,7 +513,7 @@ public class CMISRDFMapper extends BaseR
         while (it.hasNext()) {
             CmisObject o = it.next();
             if (o instanceof Document) {
-                if (o.getName().contentEquals(object.getName() + DOCUMENT_RDF)) {
+                if (o.getName().contentEquals(object.getName() + CMISUtils.RDF_METADATA_DOCUMENT_EXTENSION)) {
                     ContentStream cs = ((Document) o).getContentStream();
                     parser.parse(metadata, cs.getStream(), SupportedFormat.RDF_XML);
                 }

Added: incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/CMISUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/CMISUtils.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/CMISUtils.java (added)
+++ incubator/stanbol/trunk/cmsadapter/cmis/src/main/java/org/apache/stanbol/cmsadapter/cmis/utils/CMISUtils.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,86 @@
+/*
+ * 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.cmsadapter.cmis.utils;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+import org.apache.chemistry.opencmis.client.api.Property;
+import org.apache.chemistry.opencmis.commons.enums.PropertyType;
+import org.apache.clerezza.rdf.core.UriRef;
+
+public class CMISUtils {
+    public static final String RDF_METADATA_DOCUMENT_EXTENSION = "_metadata";
+
+    /**
+     * This method converts the raw values of a property based on the specified {@link PropertyType}.
+     * 
+     * @param property
+     *            type of a {@link Property}
+     * @param values
+     *            values of a {@link Property}
+     * @return typed values
+     */
+    public static List<Object> getTypedPropertyValues(PropertyType property, List<?> values) {
+        List<Object> typedValues = new ArrayList<Object>();
+        if (values != null) {
+            for (Object v : values) {
+                typedValues.add(getTypedPropertyValue(property, v));
+            }
+        }
+        return typedValues;
+    }
+
+    /**
+     * This method converts raw value of a property based on the specified {@link PropertyType}.
+     * 
+     * @param propertyType
+     *            property type of a {@link Property}
+     * @param value
+     *            value of a {@link Property}
+     * @return typed value
+     */
+    public static Object getTypedPropertyValue(PropertyType propertyType, Object value) {
+        if (value == null) {
+            return value;
+        }
+        switch (propertyType) {
+            case BOOLEAN:
+                return (Boolean) value;
+            case DECIMAL:
+                return (Integer) value;
+            case DATETIME:
+                return ((Calendar) value).getTime();
+            case HTML:
+                // not meet with this property
+                return null;
+            case ID:
+                return value.toString();
+            case INTEGER:
+                return ((BigInteger) value).intValue();
+            case STRING:
+                return value;
+            case URI:
+                // not meet with this property
+                return new UriRef(value.toString());
+            default:
+                return value.toString();
+        }
+    }
+}

Modified: incubator/stanbol/trunk/cmsadapter/jcr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/jcr/pom.xml?rev=1189807&r1=1189806&r2=1189807&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/jcr/pom.xml (original)
+++ incubator/stanbol/trunk/cmsadapter/jcr/pom.xml Thu Oct 27 15:29:17 2011
@@ -50,11 +50,6 @@
 			<groupId>org.apache.stanbol</groupId>
 			<artifactId>org.apache.stanbol.cmsadapter.core</artifactId>
 		</dependency>
-
-		<dependency>
-			<groupId>org.apache.felix</groupId>
-			<artifactId>org.apache.felix.scr.annotations</artifactId>
-		</dependency>
 		<dependency>
 			<groupId>org.apache.jackrabbit</groupId>
 			<artifactId>jackrabbit-jcr-rmi</artifactId>
@@ -63,6 +58,20 @@
 			<groupId>javax.jcr</groupId>
 			<artifactId>jcr</artifactId>
 		</dependency>
+
+		<!-- Contenthub -->
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
+		</dependency>
+
+		<!-- Enhancer -->
+		<!-- This dependency is needed only for implicit Store interface -->
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
+		</dependency>
+
 		<dependency>
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-api</artifactId>
@@ -71,14 +80,26 @@
 			<groupId>org.slf4j</groupId>
 			<artifactId>slf4j-simple</artifactId>
 		</dependency>
+
 		<dependency>
 			<groupId>com.hp.hpl.jena</groupId>
 			<artifactId>jena</artifactId>
 		</dependency>
+
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr.annotations</artifactId>
+		</dependency>
+
 		<dependency>
 			<groupId>org.apache.clerezza</groupId>
 			<artifactId>rdf.core</artifactId>
 		</dependency>
+
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+		</dependency>
 	</dependencies>
 
 </project>

Added: incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRContenthubFeeder.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRContenthubFeeder.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRContenthubFeeder.java (added)
+++ incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRContenthubFeeder.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,478 @@
+/*
+ * 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.cmsadapter.jcr.mapping;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.jcr.Binary;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.query.Query;
+import javax.jcr.query.QueryManager;
+import javax.jcr.query.QueryResult;
+
+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.Reference;
+import org.apache.stanbol.cmsadapter.jcr.utils.JCRUtils;
+import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContentItemFilter;
+import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContenthubFeeder;
+import org.apache.stanbol.cmsadapter.servicesapi.repository.ConnectionInfo;
+import org.apache.stanbol.contenthub.servicesapi.store.SolrContentItem;
+import org.apache.stanbol.contenthub.servicesapi.store.SolrStore;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class is default implementation of {@link ContenthubFeeder} interface for JCR content repositories. It
+ * basically transforms the {@link Node}s in the content repository to content items in the Contenthub based
+ * on the paths or IDs of the nodes.
+ * 
+ * <p>
+ * Unless the node type of the processed node is <b>nt:file</b> or <b>nt:resource</b>, the content of the node
+ * is obtained by checking the properties specified in <code>contentProperties</code> list below.
+ * 
+ * <p>
+ * If the node type of the processed node is <i>nt:resource</i>, the content of the node is obtained from the
+ * <b>jcr:data</b> property of the node. Also, if the mime type of the content is specified through the
+ * <b>jcr:mimeType</b> property, it is set as the mime type of the content item, otherwise
+ * <i>application/octet-stream</i> is set.
+ * 
+ * <p>
+ * If the node type of processed node is <i>nt:file</i>, the content of the node is obtained from the
+ * <i>nt:resource</i> property of the processed content. Mime type of the the content item is set in the same
+ * manner explained for <i>nt:resource</i> nodes in previous paragraph.
+ * 
+ * @author suat
+ * 
+ */
+@Component(factory = ContenthubFeeder.JCR_CONTENTHUB_FEEDER_FACTORY)
+public class JCRContenthubFeeder implements ContenthubFeeder {
+    private static final String JCR_NT_FILE = "nt:file";
+
+    private static final String JCR_NT_RESOURCE = "nt:resource";
+
+    private static final String JCR_CONTENT = "jcr:content";
+
+    private static final String JCR_DATA = "jcr:data";
+
+    private static final String JCR_MIME_TYPE = "jcr:mimeType";
+
+    private static final String JCR_ITEM_BY_PATH = "SELECT * from nt:base WHERE jcr:path = '%s'";
+
+    private static final Logger log = LoggerFactory.getLogger(JCRContenthubFeeder.class);
+
+    /*
+     * These properties will not be indexed
+     */
+    private static List<String> excludedProperties;
+    static {
+        excludedProperties = new ArrayList<String>();
+        excludedProperties.add("jcr:data");
+        excludedProperties.add("jcr:uuid");
+    }
+
+    @Reference
+    private SolrStore solrStore;
+
+    private Session session = null;
+
+    private List<String> contentProperties;
+
+    @SuppressWarnings("unchecked")
+    @Activate
+    protected void activate(ComponentContext context) throws ConfigurationException {
+        Dictionary<String,Object> properties = (Dictionary<String,Object>) context.getProperties();
+        checkSession(properties);
+        checkContentProp(properties);
+    }
+
+    @Override
+    public void submitContentItemByID(String contentItemID) {
+        Node n;
+        try {
+            n = getNodeByID(contentItemID);
+        } catch (RepositoryException e) {
+            log.warn("Failed to obtain the item specified by the id: {}", contentItemID, e);
+            return;
+        }
+
+        try {
+            ContentContext contentContext = getContentContextWithBasicInfo(n);
+            processContextAndSubmitToContenthub(contentContext);
+        } catch (RepositoryException e) {
+            log.warn("Failed to get basic information of node having id: {}", contentItemID);
+        }
+    }
+
+    @Override
+    public void submitContentItemByPath(String contentItemPath) {
+        Node n;
+        try {
+            n = getNodeByPath(contentItemPath);
+        } catch (RepositoryException e) {
+            log.warn("Failed to obtain the item specified by the path: {}", contentItemPath, e);
+            return;
+        }
+
+        try {
+            ContentContext contentContext = getContentContextWithBasicInfo(n);
+            processContextAndSubmitToContenthub(contentContext);
+        } catch (RepositoryException e) {
+            log.warn("Failed to get basic information of node having path: {}", contentItemPath);
+        }
+    }
+
+    @Override
+    public void submitContentItemsUnderPath(String rootPath) {
+        List<Node> nodes;
+        try {
+            nodes = getNodesUnderPath(rootPath);
+        } catch (RepositoryException e) {
+            log.warn("Failed to obtain the item specified by the path: {}", rootPath, e);
+            return;
+        }
+
+        for (Node n : nodes) {
+            String path;
+            try {
+                path = n.getPath();
+            } catch (RepositoryException e) {
+                log.warn("Failed to obtain path of node", e);
+                continue;
+            }
+
+            try {
+                ContentContext contentContext = getContentContextWithBasicInfo(n);
+                processContextAndSubmitToContenthub(contentContext);
+            } catch (RepositoryException e) {
+                log.warn("Failed to get basic information of node having path: {}", path);
+            }
+        }
+    }
+
+    @Override
+    public void submitContentItemsByCustomFilter(ContentItemFilter customContentItemFilter) {
+        throw new UnsupportedOperationException("This operation is not supported in this implementation");
+    }
+
+    @Override
+    public void deleteContentItemByID(String contentItemID) {
+        solrStore.deleteById(contentItemID);
+    }
+
+    @Override
+    public void deleteContentItemByPath(String contentItemPath) {
+        Node n;
+        try {
+            n = getNodeByPath(contentItemPath);
+            solrStore.deleteById(n.getIdentifier());
+        } catch (RepositoryException e) {
+            log.warn("Failed to obtain the item specified by the path: {}", contentItemPath, e);
+        }
+    }
+
+    @Override
+    public void deleteContentItemsUnderPath(String rootPath) {
+        List<Node> nodes;
+        try {
+            nodes = getNodesUnderPath(rootPath);
+            for (Node n : nodes) {
+                solrStore.deleteById(n.getIdentifier());
+            }
+        } catch (RepositoryException e) {
+            log.warn("Failed to obtain the item specified by the path: {}", rootPath, e);
+            return;
+        }
+    }
+
+    @Override
+    public void deleteContentItemsByCustomFilter(ContentItemFilter customContentItemFilter) {
+        throw new UnsupportedOperationException("This operation is not supported in this implementation");
+    }
+
+    @Override
+    public boolean canFeed(String connectionType) {
+        return connectionType.contentEquals(ConnectionInfo.JCR_CONNECTION_STRING);
+    }
+
+    private void processContextAndSubmitToContenthub(ContentContext contentContext) {
+        String id = contentContext.getIdentifier();
+        populateContentContext(contentContext);
+        if (contentContext.getContent() == null || contentContext.getContent().length == 0) {
+            log.warn("Failed to get content for node having id: {}", id);
+            return;
+        }
+
+        Map<String,List<Object>> constraints = getConstraintsFromNode(contentContext);
+        if (constraints.isEmpty()) {
+            log.debug("There is no constraint for the node having id: {}", id);
+        }
+
+        SolrContentItem sci = solrStore.create(id, contentContext.getContent(),
+            contentContext.getContentType(), constraints);
+        solrStore.enhanceAndPut(sci);
+        log.info("Document submitted to Contenthub.");
+        log.info("Id: {}", sci.getId());
+        log.info("Mime type: {}", sci.getMimeType());
+        log.info("Constraints: {}", sci.getConstraints().toString());
+    }
+
+    private Map<String,List<Object>> getConstraintsFromNode(ContentContext contentContext) {
+        Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
+        try {
+            PropertyIterator it = contentContext.getNode().getProperties();
+            while (it.hasNext()) {
+                javax.jcr.Property p = it.nextProperty();
+                List<Object> propertyVals = new ArrayList<Object>();
+
+                if (!skipProperty(p)) {
+                    if (!p.isMultiple()) {
+                        propertyVals.add(JCRUtils.getTypedPropertyValue(p.getType(), p.getValue()));
+                    } else {
+                        propertyVals.addAll(JCRUtils.getTypedPropertyValues(p.getType(), p.getValues()));
+                    }
+                    constraints.put(p.getName(), propertyVals);
+                }
+            }
+        } catch (RepositoryException e) {
+            log.warn("Failed to process properties of node having: {}", contentContext.getIdentifier());
+        }
+        return constraints;
+    }
+
+    private boolean skipProperty(javax.jcr.Property p) throws RepositoryException {
+        if (excludedProperties.contains(p.getName())) {
+            return true;
+        }
+        if (contentProperties != null) {
+            for (String cProp : contentProperties) {
+                if (p.getName().equals(cProp)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private void populateContentContext(ContentContext contentContext) {
+        String nodeName = contentContext.getNodeName();
+        try {
+            String nt = contentContext.getNodeType();
+            if (nt.equals(JCR_NT_FILE)) {
+                Node content = contentContext.getNode().getNode(JCR_CONTENT);
+                if (content.getPrimaryNodeType().getName().equals(JCR_NT_RESOURCE)) {
+                    getContentInfoFromNTResource(contentContext, content);
+                } else {
+                    getContentInfoFromCustomProperty(contentContext, content);
+                }
+
+            } else if (nt.equals(JCR_NT_RESOURCE)) {
+                getContentInfoFromNTResource(contentContext, contentContext.getNode());
+
+            } else {
+                getContentInfoFromCustomProperty(contentContext, contentContext.getNode());
+            }
+        } catch (RepositoryException e) {
+            log.warn("Failed to retrieve content for node: {}", nodeName, e);
+        } catch (IOException e) {
+            log.warn("Failed to get bytes from binary content of node: {}", nodeName, e);
+        }
+    }
+
+    private void getContentInfoFromNTResource(ContentContext contentContext, Node dataNode) throws RepositoryException,
+                                                                                           IOException {
+        if (dataNode.hasProperty(JCR_DATA)) {
+            javax.jcr.Property jcrData = dataNode.getProperty(JCR_DATA);
+            Binary val = jcrData.getBinary();
+            String encoding = ContentContext.MEDIA_TYPE_APPLICAION_OCTET_STREAM;
+            if (dataNode.hasProperty(JCR_MIME_TYPE)) {
+                encoding = dataNode.getProperty(JCR_MIME_TYPE).getString();
+            }
+            contentContext.setContentType(encoding);
+            contentContext.setContent(IOUtils.toByteArray(val.getStream()));
+        }
+    }
+
+    private void getContentInfoFromCustomProperty(ContentContext contentContext, Node dataNode) throws RepositoryException,
+                                                                                               IOException {
+
+        Node n = contentContext.getNode();
+        if (contentProperties != null) {
+            for (String prop : contentProperties) {
+                if (n.hasProperty(prop)) {
+                    javax.jcr.Property p = n.getProperty(prop);
+                    if (p.getType() == PropertyType.STRING) {
+                        String val = p.getString();
+                        contentContext.setContent(val.getBytes());
+                        contentContext.setContentType(ContentContext.MEDIA_TYPE_TEXT_PLAIN);
+
+                    } else {
+                        Binary val = p.getBinary();
+                        contentContext.setContent(IOUtils.toByteArray(val.getStream()));
+                        contentContext.setContentType(ContentContext.MEDIA_TYPE_APPLICAION_OCTET_STREAM);
+                    }
+                }
+            }
+        } else {
+            log.warn("There is no content property specified for node:{}", contentContext.getNodeName());
+        }
+    }
+
+    private ContentContext getContentContextWithBasicInfo(Node n) throws RepositoryException {
+        ContentContext contentContext = new ContentContext();
+        contentContext.setIdentifier(n.getIdentifier());
+        contentContext.setNode(n);
+        contentContext.setNodeType(n.getPrimaryNodeType().getName());
+        contentContext.setNodeName(n.getName());
+        return contentContext;
+    }
+
+    private Node getNodeByID(String id) throws ItemNotFoundException, RepositoryException {
+        return session.getNodeByIdentifier(id);
+    }
+
+    private Node getNodeByPath(String path) throws PathNotFoundException, RepositoryException {
+        return session.getNode(path);
+    }
+
+    private List<Node> getNodesUnderPath(String path) throws RepositoryException {
+        List<Node> results = new ArrayList<Node>();
+        // get root node
+        Node root = getNodeByPath(path);
+        results.add(root);
+
+        // get child nodes
+        // TODO use JCR-JOQM or JCR-SQL2 instead of deprecated SQL query type
+        if (!path.endsWith("/")) {
+            path += "/";
+        }
+        path += "%";
+
+        QueryManager qm = session.getWorkspace().getQueryManager();
+        Query query = qm.createQuery(String.format(JCR_ITEM_BY_PATH, path), Query.SQL);
+        QueryResult queryResult = query.execute();
+        NodeIterator nodes = queryResult.getNodes();
+        while (nodes.hasNext()) {
+            Node n = nodes.nextNode();
+            if (n.getName().equals(JCR_CONTENT)
+                && n.getParent().getPrimaryNodeType().getName().equals(JCR_NT_FILE)) {
+                // skip the jcr:content child of nt:file nodes
+                continue;
+            }
+            results.add(n);
+        }
+        return results;
+    }
+
+    private void checkSession(Dictionary<String,Object> properties) throws ConfigurationException {
+        Object value = properties.get(PROP_SESSION);
+        if (value == null) {
+            throw new ConfigurationException(PROP_SESSION,
+                    "A JCR Session should be provided to activate this component.");
+        }
+        this.session = (Session) value;
+    }
+
+    @SuppressWarnings("unchecked")
+    private void checkContentProp(Dictionary<String,Object> properties) throws ConfigurationException {
+        Object cProps = properties.get(PROP_CONTENT_PROPERTIES);
+        if (cProps == null) {
+            throw new ConfigurationException(PROP_CONTENT_PROPERTIES,
+                    "A JCR Session should be provided to activate this component.");
+        }
+        this.contentProperties = (List<String>) cProps;
+    }
+
+    /**
+     * This context class holding the node itself and information related it exists to prevent repetitive
+     * request for name, identifier, node type of actual node
+     */
+    private class ContentContext {
+        public static final String MEDIA_TYPE_TEXT_PLAIN = "text/plain";
+        public static final String MEDIA_TYPE_APPLICAION_OCTET_STREAM = "application/octet-stream";
+
+        private Node node;
+        private String nodeName;
+        private String nodeType;
+        private String identifier;
+        private String contentType;
+        private byte[] content;
+
+        public Node getNode() {
+            return node;
+        }
+
+        public void setNode(Node node) {
+            this.node = node;
+        }
+
+        public String getNodeName() {
+            return nodeName;
+        }
+
+        public void setNodeName(String nodeName) {
+            this.nodeName = nodeName;
+        }
+
+        public String getNodeType() {
+            return nodeType;
+        }
+
+        public void setNodeType(String nodeType) {
+            this.nodeType = nodeType;
+        }
+
+        public String getIdentifier() {
+            return identifier;
+        }
+
+        public void setIdentifier(String identifier) {
+            this.identifier = identifier;
+        }
+
+        public String getContentType() {
+            return contentType;
+        }
+
+        public void setContentType(String contentType) {
+            this.contentType = contentType;
+        }
+
+        public byte[] getContent() {
+            return content;
+        }
+
+        public void setContent(byte[] content) {
+            this.content = content;
+        }
+    }
+}

Copied: incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRRDFMapper.java (from r1170391, incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRDFMapper.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRRDFMapper.java?p2=incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRRDFMapper.java&p1=incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRDFMapper.java&r1=1170391&r2=1189807&rev=1189807&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/repository/JCRRDFMapper.java (original)
+++ incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/mapping/JCRRDFMapper.java Thu Oct 27 15:29:17 2011
@@ -1,4 +1,20 @@
-package org.apache.stanbol.cmsadapter.jcr.repository;
+/*
+ * 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.cmsadapter.jcr.mapping;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -11,7 +27,6 @@ import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.Value;
@@ -22,7 +37,6 @@ import org.apache.clerezza.rdf.core.MGra
 import org.apache.clerezza.rdf.core.NonLiteral;
 import org.apache.clerezza.rdf.core.Resource;
 import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TypedLiteral;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.impl.TripleImpl;
@@ -30,6 +44,7 @@ import org.apache.felix.scr.annotations.
 import org.apache.felix.scr.annotations.Service;
 import org.apache.stanbol.cmsadapter.core.mapping.BaseRDFMapper;
 import org.apache.stanbol.cmsadapter.core.mapping.RDFBridgeHelper;
+import org.apache.stanbol.cmsadapter.jcr.utils.JCRUtils;
 import org.apache.stanbol.cmsadapter.servicesapi.helper.CMSAdapterVocabulary;
 import org.apache.stanbol.cmsadapter.servicesapi.helper.NamespaceEnum;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.RDFBridgeException;
@@ -396,9 +411,9 @@ public class JCRRDFMapper extends BaseRD
                 }
                 List<Object> values = new ArrayList<Object>();
                 if (p.isMultiple()) {
-                    values.addAll(getTypedPropertyValues(p.getType(), p.getValues()));
+                    values.addAll(JCRUtils.getTypedPropertyValues(p.getType(), p.getValues()));
                 } else {
-                    values.add(getTypedPropertyValue(p.getType(), p.getValue()));
+                    values.add(JCRUtils.getTypedPropertyValue(p.getType(), p.getValue()));
                 }
                 for (Object val : values) {
                     /*
@@ -480,89 +495,6 @@ public class JCRRDFMapper extends BaseRD
         }
     }
 
-    private static List<Object> getTypedPropertyValues(int propertyType, Value[] values) throws RepositoryException {
-        List<Object> typedValues = new ArrayList<Object>();
-        for (Value val : values) {
-            typedValues.add(getTypedPropertyValue(propertyType, val));
-        }
-        return typedValues;
-    }
-
-    private static Object getTypedPropertyValue(int propertyType, Value value) throws RepositoryException {
-        switch (propertyType) {
-            case PropertyType.STRING:
-                return value.getString();
-            case PropertyType.BINARY:
-                return value.getString();
-            case PropertyType.BOOLEAN:
-                return value.getBoolean();
-            case PropertyType.DATE:
-                return value.getDate().getTime();
-            case PropertyType.URI:
-                return value.getString();
-            case PropertyType.DOUBLE:
-                return value.getDouble();
-            case PropertyType.DECIMAL:
-                return value.getDecimal().toBigInteger();
-            case PropertyType.LONG:
-                return value.getLong();
-            case PropertyType.PATH:
-                return value.getString();
-            default:
-                return value.getString();
-        }
-    }
-
-    /**
-     * Return related {@link PropertyType} according to data type of a {@link Resource} if it is an instance
-     * of {@link TypedLiteral} ot {@link UriRef}, otherwise it return {@code PropertyType#STRING} as default
-     * type.
-     * 
-     * @param r
-     * @link {@link Resource} instance of which property type is demanded
-     * @return related {@link PropertyType}
-     */
-    public static int getPropertyTypeByResource(Resource r) {
-        if (r instanceof TypedLiteral) {
-            UriRef type = ((TypedLiteral) r).getDataType();
-            if (type.equals(RDFBridgeHelper.stringUri)) {
-                return PropertyType.STRING;
-            } else if (type.equals(RDFBridgeHelper.base64Uri)) {
-                return PropertyType.BINARY;
-            } else if (type.equals(RDFBridgeHelper.booleanUri)) {
-                return PropertyType.BOOLEAN;
-            } else if (type.equals(RDFBridgeHelper.dateTimeUri)) {
-                return PropertyType.DATE;
-            } else if (type.equals(RDFBridgeHelper.xsdAnyURI)) {
-                /*
-                 * Normally this case should return PropertyType.URI, but JCR API seems to fail when
-                 * retrieving values of URI typed properties.
-                 */
-                return PropertyType.STRING;
-            } else if (type.equals(RDFBridgeHelper.xsdDouble)) {
-                return PropertyType.DOUBLE;
-            } else if (type.equals(RDFBridgeHelper.xsdInt)) {
-                return PropertyType.DECIMAL;
-            } else if (type.equals(RDFBridgeHelper.xsdInteger)) {
-                return PropertyType.DECIMAL;
-            } else if (type.equals(RDFBridgeHelper.xsdLong)) {
-                return PropertyType.LONG;
-            } else if (type.equals(RDFBridgeHelper.xsdShort)) {
-                return PropertyType.DECIMAL;
-            } else {
-                return PropertyType.STRING;
-            }
-        } else if (r instanceof UriRef) {
-            /*
-             * Normally this case should return PropertyType.URI, but JCR API seems to fail when retrieving
-             * values of URI typed properties.
-             */
-            return PropertyType.STRING;
-        } else {
-            return PropertyType.STRING;
-        }
-    }
-
     private void checkNamespaceForShortURI(Session session, String shortURI) throws NamespaceException,
                                                                             RepositoryException {
         String prefix = shortURI.split(":")[0];
@@ -595,7 +527,7 @@ public class JCRRDFMapper extends BaseRD
         }
 
         public void setPropertyType(Resource r) {
-            type = getPropertyTypeByResource(r);
+            type = JCRUtils.getPropertyTypeByResource(r);
         }
 
         public int getPropertyType() {

Added: incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/JCRUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/JCRUtils.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/JCRUtils.java (added)
+++ incubator/stanbol/trunk/cmsadapter/jcr/src/main/java/org/apache/stanbol/cmsadapter/jcr/utils/JCRUtils.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,148 @@
+/*
+ * 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.cmsadapter.jcr.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.TypedLiteral;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.cmsadapter.servicesapi.helper.NamespaceEnum;
+
+public class JCRUtils {
+    private static final UriRef base64Uri = dataTypeURI("base64Binary");
+    private static final UriRef dateTimeUri = dataTypeURI("dateTime");
+    private static final UriRef booleanUri = dataTypeURI("boolean");
+    private static final UriRef stringUri = dataTypeURI("string");
+    private static final UriRef xsdInteger = dataTypeURI("integer");
+    private static final UriRef xsdInt = dataTypeURI("int");
+    private static final UriRef xsdShort = dataTypeURI("short");
+    private static final UriRef xsdLong = dataTypeURI("long");
+    private static final UriRef xsdDouble = dataTypeURI("double");
+    private static final UriRef xsdAnyURI = dataTypeURI("anyURI");
+
+    /**
+     * This method converts the raw values of a property based on the specified property type.
+     * 
+     * @param propertyType
+     *            type of a {@link Property}
+     * @param values
+     *            values of a {@link Property}
+     * @return typed values
+     */
+    public static List<Object> getTypedPropertyValues(int propertyType, Value[] values) throws RepositoryException {
+        List<Object> typedValues = new ArrayList<Object>();
+        for (Value val : values) {
+            typedValues.add(getTypedPropertyValue(propertyType, val));
+        }
+        return typedValues;
+    }
+
+    /**
+     * This method converts the raw value of a property based on the specified property type.
+     * 
+     * @param propertyType
+     *            type of a {@link Property}
+     * @param value
+     *            values of a {@link Property}
+     * @return typed value
+     */
+    public static Object getTypedPropertyValue(int propertyType, Value value) throws RepositoryException {
+        switch (propertyType) {
+            case PropertyType.STRING:
+                return value.getString();
+            case PropertyType.BINARY:
+                return value.getString();
+            case PropertyType.BOOLEAN:
+                return value.getBoolean();
+            case PropertyType.DATE:
+                return value.getDate().getTime();
+            case PropertyType.URI:
+                return value.getString();
+            case PropertyType.DOUBLE:
+                return value.getDouble();
+            case PropertyType.DECIMAL:
+                return value.getDecimal().toBigInteger();
+            case PropertyType.LONG:
+                return value.getLong();
+            case PropertyType.PATH:
+                return value.getString();
+            default:
+                return value.getString();
+        }
+    }
+
+    /**
+     * Return related {@link PropertyType} according to data type of a {@link Resource} if it is an instance
+     * of {@link TypedLiteral} or {@link UriRef}, otherwise it return {@code PropertyType#STRING} as default
+     * type.
+     * 
+     * @param r
+     * @link {@link Resource} instance of which property type is demanded
+     * @return related {@link PropertyType}
+     */
+    public static int getPropertyTypeByResource(Resource r) {
+        if (r instanceof TypedLiteral) {
+            UriRef type = ((TypedLiteral) r).getDataType();
+            if (type.equals(stringUri)) {
+                return PropertyType.STRING;
+            } else if (type.equals(base64Uri)) {
+                return PropertyType.BINARY;
+            } else if (type.equals(booleanUri)) {
+                return PropertyType.BOOLEAN;
+            } else if (type.equals(dateTimeUri)) {
+                return PropertyType.DATE;
+            } else if (type.equals(xsdAnyURI)) {
+                /*
+                 * Normally this case should return PropertyType.URI, but JCR API seems to fail when
+                 * retrieving values of URI typed properties.
+                 */
+                return PropertyType.STRING;
+            } else if (type.equals(xsdDouble)) {
+                return PropertyType.DOUBLE;
+            } else if (type.equals(xsdInt)) {
+                return PropertyType.DECIMAL;
+            } else if (type.equals(xsdInteger)) {
+                return PropertyType.DECIMAL;
+            } else if (type.equals(xsdLong)) {
+                return PropertyType.LONG;
+            } else if (type.equals(xsdShort)) {
+                return PropertyType.DECIMAL;
+            } else {
+                return PropertyType.STRING;
+            }
+        } else if (r instanceof UriRef) {
+            /*
+             * Normally this case should return PropertyType.URI, but JCR API seems to fail when retrieving
+             * values of URI typed properties.
+             */
+            return PropertyType.STRING;
+        } else {
+            return PropertyType.STRING;
+        }
+    }
+
+    private static UriRef dataTypeURI(String type) {
+        return new UriRef(NamespaceEnum.xsd + type);
+    }
+}

Modified: incubator/stanbol/trunk/cmsadapter/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/parent/pom.xml?rev=1189807&r1=1189806&r2=1189807&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/parent/pom.xml (original)
+++ incubator/stanbol/trunk/cmsadapter/parent/pom.xml Thu Oct 27 15:29:17 2011
@@ -108,6 +108,14 @@
 				<scope>provided</scope>
 			</dependency>
 
+			<!-- Contenthub -->
+			<dependency>
+				<groupId>org.apache.stanbol</groupId>
+				<artifactId>org.apache.stanbol.contenthub.servicesapi</artifactId>
+				<version>0.9.0-incubating-SNAPSHOT</version>
+				<scope>provided</scope>
+			</dependency>
+
 			<!-- Jersey -->
 			<dependency>
 				<groupId>com.sun.jersey</groupId>

Added: incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContentItemFilter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContentItemFilter.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContentItemFilter.java (added)
+++ incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContentItemFilter.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,35 @@
+/*
+ * 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.cmsadapter.servicesapi.mapping;
+
+import java.util.List;
+
+/**
+ * Simple filter interface that allows filtering of documents from content repositories
+ * 
+ * @author suat
+ * 
+ */
+public interface ContentItemFilter {
+    /**
+     * This method is designed to obtain custom content items from content repository through in its different
+     * implementations.
+     * 
+     * @return filtered content items in a {@link List} object.
+     */
+    List<Object> filterContentItems();
+}

Added: incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeeder.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeeder.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeeder.java (added)
+++ incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeeder.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,138 @@
+/*
+ * 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.cmsadapter.servicesapi.mapping;
+
+/**
+ * This interface provides methods to submit and delete content items to/from Contenthub.
+ * 
+ * Stanbol provides default implementations of this interface for JCR and CMIS content repositories. However,
+ * it is also possible to provide custom implementations based on the needs of content repository. It is still
+ * possible to provide new implementations for JCR or CMIS repositories. <code>ContenthubFeederManager</code>
+ * gives higher priority to custom implementations when selecting the appropriate {@link ContenthubFeeder}
+ * instance.
+ * 
+ * While submitting content items to Contenthub properties of content repository objects are provided as
+ * metadata of the content items. Supplied metadata is used to provide faceted search feature in the
+ * Contenthub.
+ * 
+ * @author suat
+ * 
+ */
+public interface ContenthubFeeder {
+    /**
+     * Name of the factory for JCR Contenthub Feeder
+     */
+    public static final String JCR_CONTENTHUB_FEEDER_FACTORY = "org.apache.stanbol.cmsadapter.jcr.mapping.JCRContenthubFeederFactory";
+
+    /**
+     * Name of the factory for CMIS Contenthub Feeder
+     */
+    public static final String CMIS_CONTENTUB_FEEDER_FACTORY = "org.apache.stanbol.cmsadapter.cmis.mapping.CMISContenthubFeederFactory";
+
+    /**
+     * Session property for default JCR and CMIS Contenthub Feeder implementations
+     */
+    public static final String PROP_SESSION = "org.apache.stanbol.cmsadapter.servicesapi.mapping.ContenthubFeeder.session";
+
+    /**
+     * Content properties property. It indicates the fields that holds the actual content in the content
+     * repository item.
+     */
+    public static final String PROP_CONTENT_PROPERTIES = "org.apache.stanbol.cmsadapter.servicesapi.mappingçContenthubFeeder.contentFields";
+
+    /**
+     * Submits content item by its ID to the Contenthub. If there is an already existing content item in the
+     * Contenthub with the same id, the existing content item should be deleted first.
+     * 
+     * @param contentItemID
+     *            ID of the content item in the repository
+     */
+    void submitContentItemByID(String contentItemID);
+
+    /**
+     * Submits content item by its path to the Contenthub. If there is an already existing content item in the
+     * Contenthub with the same id, the existing content item should be deleted first.
+     * 
+     * @param contentItemPath
+     *            path of the content item in the repository
+     */
+    void submitContentItemByPath(String contentItemPath);
+
+    /**
+     * Submits all of the content items under the specified path to the Contenthub. If there are already
+     * existing content items in the Contenthub with same ids of submitted content items, the existing content
+     * items should be deleted first.
+     * 
+     * @param rootPath
+     *            root path in the content repository
+     */
+    void submitContentItemsUnderPath(String rootPath);
+
+    /**
+     * Filters content items from content repository via the specific {@link ContentItemFilter} implementation
+     * passed as a parameter and submits the filtered content items to the Contenthub. If there are already
+     * existing content items in the Contenthub with same ids of submitted content items, the existing content
+     * items should be deleted first.
+     * 
+     * @param customContentItemFilter
+     *            custom {@link ContentItemFilter} implementation
+     */
+    void submitContentItemsByCustomFilter(ContentItemFilter customContentItemFilter);
+
+    /**
+     * Deletes content item by its ID from the Contenthub
+     * 
+     * @param contentItemID
+     *            ID of the content item in the repository
+     */
+    void deleteContentItemByID(String contentItemID);
+
+    /**
+     * Deletes content item by its path from the Contenthub
+     * 
+     * @param contentItemPath
+     *            path of the content item in the repository
+     */
+    void deleteContentItemByPath(String contentItemPath);
+
+    /**
+     * Deletes all of the content items under the specified path to Contenthub
+     * 
+     * @param rootPath
+     *            root path in the content repository
+     */
+    void deleteContentItemsUnderPath(String rootPath);
+
+    /**
+     * Filters content items from content repository via the specific {@link ContentItemFilter} implementation
+     * passed as a parameter and deletes the filtered content items from the Contenthub
+     * 
+     * @param customContentItemFilter
+     *            custom {@link ContentItemFilter} implementation
+     */
+    void deleteContentItemsByCustomFilter(ContentItemFilter customContentItemFilter);
+
+    /**
+     * Determines the specific implementation of {@link ContenthubFeeder} supports for the specified
+     * <connectionType>.
+     * 
+     * @param connectionType
+     *            connection type for which an {@link RDFMapper} is requested
+     * @return whether certain implementation can handle specified connection type
+     */
+    boolean canFeed(String connectionType);
+}

Added: incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeederException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeederException.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeederException.java (added)
+++ incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/mapping/ContenthubFeederException.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.cmsadapter.servicesapi.mapping;
+
+public class ContenthubFeederException extends Exception {
+
+    private static final long serialVersionUID = 4919541866010334898L;
+
+    public ContenthubFeederException(String message) {
+        super(message);
+    }
+
+    public ContenthubFeederException(String message, Throwable throwable) {
+        super(message, throwable);
+    }
+}

Added: incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/repository/ConnectionInfo.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/repository/ConnectionInfo.java?rev=1189807&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/repository/ConnectionInfo.java (added)
+++ incubator/stanbol/trunk/cmsadapter/servicesapi/src/main/java/org/apache/stanbol/cmsadapter/servicesapi/repository/ConnectionInfo.java Thu Oct 27 15:29:17 2011
@@ -0,0 +1,107 @@
+/*
+ * 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.cmsadapter.servicesapi.repository;
+
+/**
+ * This class contains the information that is required obtain a session from a content repository.
+ * 
+ * @author suat
+ * 
+ */
+public class ConnectionInfo {
+    public static final String JCR_CONNECTION_STRING = "JCR";
+
+    public static final String CMIS_CONNECTION_STRING = "CMIS";
+
+    private String repositoryURL;
+
+    private String workspaceIdentifier;
+
+    private String username;
+
+    private String password;
+
+    private String connectionType;
+
+    public ConnectionInfo(String repositoryURL,
+                          String workspaceIdentifier,
+                          String username,
+                          String password,
+                          String connectionType) {
+        this.repositoryURL = repositoryURL;
+        this.workspaceIdentifier = workspaceIdentifier;
+        this.username = username;
+        this.password = password;
+        this.connectionType = connectionType;
+    }
+
+    public String getRepositoryURL() {
+        return repositoryURL;
+    }
+
+    public String getWorkspaceIdentifier() {
+        return workspaceIdentifier;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public String getConnectionType() {
+        return connectionType;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((connectionType == null) ? 0 : connectionType.hashCode());
+        result = prime * result + ((password == null) ? 0 : password.hashCode());
+        result = prime * result + ((repositoryURL == null) ? 0 : repositoryURL.hashCode());
+        result = prime * result + ((username == null) ? 0 : username.hashCode());
+        result = prime * result + ((workspaceIdentifier == null) ? 0 : workspaceIdentifier.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) return true;
+        if (obj == null) return false;
+        if (getClass() != obj.getClass()) return false;
+        ConnectionInfo other = (ConnectionInfo) obj;
+        if (connectionType == null) {
+            if (other.connectionType != null) return false;
+        } else if (!connectionType.equals(other.connectionType)) return false;
+        if (password == null) {
+            if (other.password != null) return false;
+        } else if (!password.equals(other.password)) return false;
+        if (repositoryURL == null) {
+            if (other.repositoryURL != null) return false;
+        } else if (!repositoryURL.equals(other.repositoryURL)) return false;
+        if (username == null) {
+            if (other.username != null) return false;
+        } else if (!username.equals(other.username)) return false;
+        if (workspaceIdentifier == null) {
+            if (other.workspaceIdentifier != null) return false;
+        } else if (!workspaceIdentifier.equals(other.workspaceIdentifier)) return false;
+        return true;
+    }
+}