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/12/16 13:14:41 UTC

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

Modified: incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource.java?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource.java (original)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource.java Fri Dec 16 12:14:40 2011
@@ -38,13 +38,10 @@ import javax.ws.rs.core.Response.Status;
 import org.apache.stanbol.cmsadapter.core.mapping.ContenthubFeederManager;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContenthubFeeder;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.ContenthubFeederException;
-import org.apache.stanbol.cmsadapter.servicesapi.repository.ConnectionInfo;
 import org.apache.stanbol.cmsadapter.servicesapi.repository.RepositoryAccessException;
 import org.apache.stanbol.cmsadapter.web.utils.RestUtil;
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.sun.jersey.api.view.Viewable;
 
@@ -60,8 +57,6 @@ import com.sun.jersey.api.view.Viewable;
  */
 @Path("/cmsadapter/contenthubfeed")
 public class ContenthubFeedResource extends BaseStanbolResource {
-    private static final Logger logger = LoggerFactory.getLogger(ContenthubFeedResource.class);
-
     ContenthubFeederManager feederManager;
 
     public ContenthubFeedResource(@Context ServletContext context) {
@@ -76,9 +71,10 @@ public class ContenthubFeedResource exte
 
     /**
      * This service enables submission of content repository objects to Contenthub. Connection to the content
-     * repository is established by the provided connection information. This service makes possible to submit
-     * content items through either their IDs or paths in the content repository. Enhancements of content
-     * items are obtained through <b>Stanbol Enhancer</b> before submitting them to Contenthub.
+     * repository is established by the previously created session object. This object is specified by the
+     * <code>sessionKey</code>. This service makes possible to submit content items through either their IDs
+     * or paths in the content repository. Enhancements of content items are obtained through <b>Stanbol
+     * Enhancer</b> before submitting them to Contenthub.
      * 
      * <p>
      * If <code>id</code> parameter is set, the target object is obtained from the content repository
@@ -93,11 +89,9 @@ public class ContenthubFeedResource exte
      * properties are specified within the <code>contentProperties</code> parameter.
      * 
      * 
-     * @param repositoryURL
-     * @param workspaceName
-     * @param username
-     * @param password
-     * @param connectionType
+     * @param sessionKey
+     *            session key to obtain a previously created session to be used to connect a content
+     *            repository
      * @param id
      *            content repository ID of the content item to be submitted
      * @param path
@@ -117,40 +111,25 @@ public class ContenthubFeedResource exte
      */
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
-    public Response submitObjectsToContenthub(@FormParam("repositoryURL") String repositoryURL,
-                                              @FormParam("workspaceName") String workspaceName,
-                                              @FormParam("username") String username,
-                                              @FormParam("password") String password,
-                                              @FormParam("connectionType") String connectionType,
+    public Response submitObjectsToContenthub(@FormParam("sessionKey") String sessionKey,
                                               @FormParam("id") String id,
                                               @FormParam("path") String path,
                                               @FormParam("recursive") @DefaultValue("false") boolean recursive,
                                               @FormParam("contentProperties") @DefaultValue("skos:definition,content") String contentProperties) throws RepositoryAccessException,
                                                                                                                                                 ContenthubFeederException {
 
-        repositoryURL = RestUtil.nullify(repositoryURL);
-        workspaceName = RestUtil.nullify(workspaceName);
-        username = RestUtil.nullify(username);
-        password = RestUtil.nullify(password);
-        connectionType = RestUtil.nullify(connectionType);
+        sessionKey = RestUtil.nullify(sessionKey);
         id = RestUtil.nullify(id);
         path = RestUtil.nullify(path);
         contentProperties = RestUtil.nullify(contentProperties);
 
-        if (repositoryURL == null || username == null || password == null || connectionType == null) {
-            logger.warn("Repository URL, username, password and connection type parameters should not be null");
-            return Response
-                    .status(Status.BAD_REQUEST)
-                    .entity(
-                        "Repository URL, username, password and connection type parameters should not be null")
-                    .build();
+        if (sessionKey == null) {
+            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
         }
 
         List<String> contentFieldList = parseContentProperties(contentProperties);
 
-        ContenthubFeeder feeder = feederManager.getContenthubFeeder(
-            formConnectionInfo(repositoryURL, workspaceName, username, password, connectionType),
-            contentFieldList);
+        ContenthubFeeder feeder = feederManager.getContenthubFeeder(sessionKey, contentFieldList);
 
         if (id != null) {
             feeder.submitContentItemByID(id);
@@ -170,8 +149,9 @@ public class ContenthubFeedResource exte
 
     /**
      * This service enables deletion of content items from Contenthub. Connection to the content repository is
-     * established by the provided connection information. This service makes possible to delete content items
-     * through either their IDs or paths in the content repository.
+     * established by the previously created session object. This object is specified by the
+     * <code>sessionKey</code>. This service makes possible to delete content items through either their IDs
+     * or paths in the content repository.
      * 
      * <p>
      * If <code>id</code> parameter is set, the content item is directly tried to be deleted from Contenthub.
@@ -179,11 +159,9 @@ public class ContenthubFeedResource exte
      * repository according to its path. Then retrieved ID is used to delete related content item from
      * Contenthub.
      * 
-     * @param repositoryURL
-     * @param workspaceName
-     * @param username
-     * @param password
-     * @param connectionType
+     * @param sessionKey
+     *            session key to obtain a previously created session to be used to connect a content
+     *            repository
      * @param id
      *            content repository ID of the content item to be submitted
      * @param path
@@ -198,35 +176,21 @@ public class ContenthubFeedResource exte
      */
     @DELETE
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
-    public Response deleteObjectsFromContenthub(@FormParam("repositoryURL") String repositoryURL,
-                                                @FormParam("workspaceName") String workspaceName,
-                                                @FormParam("username") String username,
-                                                @FormParam("password") String password,
-                                                @FormParam("connectionType") String connectionType,
+    public Response deleteObjectsFromContenthub(@FormParam("sessionKey") String sessionKey,
                                                 @FormParam("id") String id,
                                                 @FormParam("path") String path,
                                                 @FormParam("recursive") @DefaultValue("false") boolean recursive) throws RepositoryAccessException,
                                                                                                                  ContenthubFeederException {
 
-        repositoryURL = RestUtil.nullify(repositoryURL);
-        workspaceName = RestUtil.nullify(workspaceName);
-        username = RestUtil.nullify(username);
-        password = RestUtil.nullify(password);
-        connectionType = RestUtil.nullify(connectionType);
+        sessionKey = RestUtil.nullify(sessionKey);
         id = RestUtil.nullify(id);
         path = RestUtil.nullify(path);
 
-        if (repositoryURL == null || username == null || password == null || connectionType == null) {
-            logger.warn("Repository URL, username, password and connection type parameters should not be null");
-            return Response
-                    .status(Status.BAD_REQUEST)
-                    .entity(
-                        "Repository URL, username, password and connection type parameters should not be null")
-                    .build();
+        if (sessionKey == null) {
+            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
         }
 
-        ContenthubFeeder feeder = feederManager.getContenthubFeeder(formConnectionInfo(repositoryURL,
-            workspaceName, username, password, connectionType));
+        ContenthubFeeder feeder = feederManager.getContenthubFeeder(sessionKey, null);
 
         if (id != null) {
             feeder.deleteContentItemByID(id);
@@ -244,16 +208,6 @@ public class ContenthubFeedResource exte
         return Response.ok().build();
     }
 
-    private ConnectionInfo formConnectionInfo(String repositoryURL,
-                                              String workspaceName,
-                                              String username,
-                                              String password,
-                                              String connectionType) {
-        ConnectionInfo cInfo = new org.apache.stanbol.cmsadapter.servicesapi.repository.ConnectionInfo(
-                repositoryURL, workspaceName, username, password, connectionType);
-        return cInfo;
-    }
-
     private List<String> parseContentProperties(String contentProperties) {
         List<String> fieldsList = new ArrayList<String>();
         if (contentProperties != null) {
@@ -267,4 +221,4 @@ public class ContenthubFeedResource exte
         }
         return fieldsList;
     }
-}
+}
\ No newline at end of file

Modified: incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource.java?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource.java (original)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource.java Fri Dec 16 12:14:40 2011
@@ -28,6 +28,7 @@ import java.net.URLConnection;
 
 import javax.servlet.ServletContext;
 import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
@@ -41,18 +42,16 @@ import javax.ws.rs.core.Response.Status;
 
 import org.apache.clerezza.rdf.core.Graph;
 import org.apache.clerezza.rdf.core.MGraph;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.TcManager;
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.commons.io.FileUtils;
-import org.apache.stanbol.cmsadapter.core.helper.TcManagerClient;
+import org.apache.stanbol.cmsadapter.core.mapping.DefaultRDFBridgeImpl;
 import org.apache.stanbol.cmsadapter.core.mapping.RDFBridgeManager;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.RDFBridge;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.RDFBridgeException;
 import org.apache.stanbol.cmsadapter.servicesapi.mapping.RDFMapper;
-import org.apache.stanbol.cmsadapter.servicesapi.model.web.ConnectionInfo;
 import org.apache.stanbol.cmsadapter.servicesapi.repository.RepositoryAccessException;
+import org.apache.stanbol.cmsadapter.web.utils.RestUtil;
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
 import org.slf4j.Logger;
@@ -63,22 +62,20 @@ import com.sun.jersey.core.header.FormDa
 import com.sun.jersey.multipart.FormDataParam;
 
 /**
- * This resource is currently used to pass RDF data to CMS Adapter so that RDF data will be annotated with
- * "CMS vocabulary" annotations according to {@link RDFBridge}s. Afterwards, this annotated RDF is transformed
- * into nodes/object in the content repository.
+ * This resource provides functionalities for bidirectional mapping between external RDF data and JCR/CMIS
+ * content repositories. In other words, it is possible to populate content repository based on an external
+ * RDF. On the other direction, it enables generation of RDF using the structure of content repository. The
+ * mapping operation is done by {@link RDFBridge}s.
  */
-
 @Path("/cmsadapter/map")
 public class RDFMapperResource extends BaseStanbolResource {
     private static final Logger logger = LoggerFactory.getLogger(RDFMapperResource.class);
     private Parser clerezzaParser;
     private RDFBridgeManager bridgeManager;
-    private TcManager tcManager;
 
     public RDFMapperResource(@Context ServletContext context) {
         clerezzaParser = ContextHelper.getServiceFromContext(Parser.class, context);
         bridgeManager = ContextHelper.getServiceFromContext(RDFBridgeManager.class, context);
-        tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
     }
 
     @GET
@@ -91,26 +88,17 @@ public class RDFMapperResource extends B
      * Allows clients to map specified RDF to the content repository. In the first step the RDF data is
      * annotated according to RDF Bridges loaded in the OSGI environment. Additional annotations provide
      * selection of certain resources from RDF data and creation/update of related content repository object.
-     * Either a raw RDF can be given in <code>serializedGraph</code> parameter or URL of an external RDF data
-     * can given in <code>url</code> parameter. However, <code>serializedGraph</code> has a higher priority.
+     * See Javadoc of {@link DefaultRDFBridgeImpl} for possible configuration options of default
+     * {@link RDFBridge} implementation. Either a raw RDF can be given in <code>serializedGraph</code>
+     * parameter or URL of an external RDF data can given in <code>url</code> parameter. However,
+     * <code>serializedGraph</code> has a higher priority.
      * 
-     * @param repositoryURL
-     *            URL of the content repository. For JCR repositories <b>RMI protocol</b>, for CMIS
-     *            repositories <b>AtomPub Binding</b> is used. This parameter should be set according to these
-     *            connection methods.
-     * @param workspaceName
-     *            For JCR repositories this parameter determines the workspace to be connected. On the other
-     *            hand for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of
-     *            not setting this parameter, for JCR <b>default workspace</b> is selected, for CMIS the
-     *            <b>first repository</b> obtained through the session object is selected.
-     * @param username
-     *            Username to connect to content repository
-     * @param password
-     *            Password to connect to content repository
-     * @param connectionType
-     *            Connection type; either <b>JCR</b> or <b>CMIS</b>
+     * @param sessionKey
+     *            session key to obtain a previously created session to be used to connect a content
+     *            repository
      * @param serializedGraph
-     *            is the serialized RDF graph that is desired to be transformed into repository objects
+     *            is the serialized RDF graph in <b>application/rdf+xml" format that is desired to be
+     *            transformed into repository objects
      * @param url
      *            URL of the external RDF data.
      * @return
@@ -120,24 +108,16 @@ public class RDFMapperResource extends B
     @Path("/rdf")
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
-    public Response mapRawRDF(@FormParam("repositoryURL") String repositoryURL,
-                              @FormParam("workspaceName") String workspaceName,
-                              @FormParam("username") String username,
-                              @FormParam("password") String password,
-                              @FormParam("connectionType") String connectionType,
-                              @FormParam("serializedGraph") String serializedGraph,
-                              @FormParam("url") String url) throws MalformedURLException, IOException {
-
-        if (repositoryURL == null || username == null || password == null || connectionType == null) {
-            logger.warn("Repository URL, username, password and connection type parameters should not be null");
-            return Response
-                    .status(Status.BAD_REQUEST)
-                    .entity(
-                        "Repository URL, username, password and connection type parameters should not be null")
-                    .build();
+    public Response mapRawRDFToRepository(@FormParam("sessionKey") String sessionKey,
+                                          @FormParam("serializedGraph") String serializedGraph,
+                                          @FormParam("url") String url) throws MalformedURLException,
+                                                                       IOException {
+
+        sessionKey = RestUtil.nullify(sessionKey);
+        if (sessionKey == null) {
+            logger.warn("Sessin key should not be null");
+            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
         }
-        ConnectionInfo connectionInfo = formConnectionInfo(repositoryURL, workspaceName, username, password,
-            connectionType);
 
         long start = System.currentTimeMillis();
         Graph g;
@@ -153,31 +133,18 @@ public class RDFMapperResource extends B
                     .build();
         }
 
-        Response r = mapRDF(g, connectionInfo);
+        Response r = mapRDF(g, sessionKey);
         logger.info("RDF mapping finished in: {} seconds", ((System.currentTimeMillis() - start) / 1000));
         return r;
     }
 
     /**
-     * Same with {@link #mapRawRDF(String, String, String, String, String, String, String)}. But this service
-     * allows clients to submit external RDF data through a {@link File} specified in <code>rdfFile</code>
-     * parameter.
+     * Same with {@link #mapRawRDFToRepository(String, String, String)}. But this service allows clients to
+     * submit external RDF data through a {@link File} specified in <code>rdfFile</code> parameter.
      * 
-     * @param repositoryURL
-     *            URL of the content repository. For JCR repositories <b>RMI protocol</b>, for CMIS
-     *            repositories <b>AtomPub Binding</b> is used. This parameter should be set according to these
-     *            connection methods.
-     * @param workspaceName
-     *            For JCR repositories this parameter determines the workspace to be connected. On the other
-     *            hand for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of
-     *            not setting this parameter, for JCR <b>default workspace</b> is selected, for CMIS the
-     *            <b>first repository</b> obtained through the session object is selected.
-     * @param username
-     *            Username to connect to content repository
-     * @param password
-     *            Password to connect to content repository
-     * @param connectionType
-     *            Connection type; either <b>JCR</b> or <b>CMIS</b>
+     * @param sessionKey
+     *            session key to obtain a previously created session to be used to connect a content
+     *            repository
      * @param rdfFile
      *            {@link File} containing the RDF to be mapped to the content repository
      * @param rdfFileInfo
@@ -188,24 +155,16 @@ public class RDFMapperResource extends B
     @Path("/rdf")
     @POST
     @Consumes(MediaType.MULTIPART_FORM_DATA)
-    public Response mapRDFFromFile(@QueryParam("repositoryURL") String repositoryURL,
-                                   @QueryParam("workspaceName") String workspaceName,
-                                   @QueryParam("username") String username,
-                                   @QueryParam("password") String password,
-                                   @QueryParam("connectionType") String connectionType,
+    public Response mapRDFToRepositoryFromFile(@QueryParam("sessionKey") String sessionKey,
                                    @FormDataParam("rdfFile") File rdfFile,
                                    @FormDataParam("rdfFile") FormDataContentDisposition rdfFileInfo) throws IOException {
 
-        if (repositoryURL == null || username == null || password == null || connectionType == null) {
-            logger.warn("Repository URL, username, password and connection type parameters should not be null");
-            return Response
-                    .status(Status.BAD_REQUEST)
-                    .entity(
-                        "Repository URL, username, password and connection type parameters should not be null")
-                    .build();
+        sessionKey = RestUtil.nullify(sessionKey);
+        if (sessionKey == null) {
+            logger.warn("Sessin key should not be null");
+            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
         }
-        ConnectionInfo connectionInfo = formConnectionInfo(repositoryURL, workspaceName, username, password,
-            connectionType);
+
         long start = System.currentTimeMillis();
         Graph g;
         if (rdfFile != null) {
@@ -216,18 +175,14 @@ public class RDFMapperResource extends B
             return Response.status(Status.BAD_REQUEST).entity("There is no RDF file specified").build();
         }
 
-        Response r = mapRDF(g, connectionInfo);
-        logger.info("RDF mapping finished in: {} miliseconds", ((System.currentTimeMillis() - start) / 1000));
-        if (r.getStatus() == Response.Status.OK.getStatusCode()) {
-            return get();
-        } else {
-            return r;
-        }
+        Response r = mapRDF(g, sessionKey);
+        logger.info("RDF mapping finished in: {} seconds", ((System.currentTimeMillis() - start) / 1000));
+        return r;
     }
 
-    private Response mapRDF(Graph g, ConnectionInfo connectionInfo) {
+    private Response mapRDF(Graph g, String sessionKey) {
         try {
-            bridgeManager.storeRDFToRepository(connectionInfo, g);
+            bridgeManager.storeRDFToRepository(sessionKey, g);
         } catch (RepositoryAccessException e) {
             logger.warn("Failed to obtain a session from repository", e);
             return Response.status(Status.INTERNAL_SERVER_ERROR)
@@ -242,13 +197,27 @@ public class RDFMapperResource extends B
 
     /**
      * This service provides obtaining an RDF from the content repository based on the {@link RDFBridge}
-     * instances in the environment. Target content content repository objects are determined according to
-     * path configurations of RDF Bridges. In the first step, content repository objects are converted into an
-     * RDF. This process is realized by {@link RDFMapper}. For JCR and CMIS repositories there are two
+     * instances in the environment. Target content repository objects are determined according to path
+     * configurations of RDF Bridges. In the first step, content repository objects are converted into an RDF.
+     * This process is realized by {@link RDFMapper}. For JCR and CMIS repositories there are two
      * implementations of this interface namely, <code>JCRRDFMapper</code> and <code>CMISRDFMapper</code>. At
      * the end of first step, generated RDF contains only <b>CMS Vocabulary</b> annotations. Afterwards,
      * additional assertions are added based on RDF Bridges.
      * 
+     * @param sessionKey
+     *            session key to obtain a previously created session to be used to connect a content
+     *            repository
+     * @param baseURI
+     *            base URI for the RDF to be generated
+     * @param store
+     *            if this boolean parameter is set as <code>true</code>, generated RDF is stored persistently
+     *            in Stanbol environment
+     * @param update
+     *            precondition to consider this parameter is setting <code>true</code> for <code>store</code>
+     *            parameter. If so; if this parameter is set as <code>true</code> previously store RDF having
+     *            the identified by the URI passed in <code>baseURI</code> parameter is updated. However, if
+     *            there is no stored RDF a new one is created. If it is not set explicitly, its default value
+     *            is <code>true</code>
      * 
      * @return generated {@link MGraph} wrapped in a {@link Response} in "application/rdf+xml" format
      */
@@ -256,64 +225,31 @@ public class RDFMapperResource extends B
     @POST
     @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
     @Produces(SupportedFormat.RDF_XML)
-    public Response mapCMS(@FormParam("repositoryURL") String repositoryURL,
-                           @FormParam("workspaceName") String workspaceName,
-                           @FormParam("username") String username,
-                           @FormParam("password") String password,
-                           @FormParam("connectionType") String connectionType,
+    public Response mapRepositoryToRDF(@FormParam("sessionKey") String sessionKey,
                            @FormParam("baseURI") String baseURI,
-                           @FormParam("store") boolean store) {
+                           @FormParam("store") boolean store,
+                           @FormParam("update") @DefaultValue("true") boolean update) {
 
-        if (repositoryURL == null || username == null || password == null || connectionType == null) {
-            logger.warn("Repository URL, username, password and connection type parameters should not be null");
-            return Response
-                    .status(Status.BAD_REQUEST)
-                    .entity(
-                        "Repository URL, username, password and connection type parameters should not be null")
-                    .build();
+        sessionKey = RestUtil.nullify(sessionKey);
+        if (sessionKey == null) {
+            logger.warn("Sessin key should not be null");
+            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
         }
-        ConnectionInfo connectionInfo = formConnectionInfo(repositoryURL, workspaceName, username, password,
-            connectionType);
 
         try {
             long start = System.currentTimeMillis();
-            MGraph generatedGraph = bridgeManager.generateRDFFromRepository(baseURI, connectionInfo);
+            MGraph generatedGraph = bridgeManager.generateRDFFromRepository(baseURI, sessionKey, store,
+                update);
             logger.info("CMS mapping finished in: {} seconds", ((System.currentTimeMillis() - start) / 1000));
-
-            TcManagerClient tcManagerClient = new TcManagerClient(tcManager);
-            if (store) {
-                if (tcManagerClient.modelExists(baseURI)) {
-                    logger.info("Deleting the triple collection having base URI: {}", baseURI);
-                    tcManager.deleteTripleCollection(new UriRef(baseURI));
-                }
-                logger.info("Saving the triple collection having base URI: {}", baseURI);
-                MGraph persistentGraph = tcManager.createMGraph(new UriRef(baseURI));
-                persistentGraph.addAll(generatedGraph);
-            }
-
             return Response.ok(generatedGraph, SupportedFormat.RDF_XML).build();
         } catch (RepositoryAccessException e) {
-            logger.warn("Failed to obtain a session from repository", e);
-            return Response.status(Status.INTERNAL_SERVER_ERROR)
-                    .entity("Failed to obtain a session from repository").build();
+            String message = e.getMessage();
+            logger.warn(message, e);
+            return Response.status(Status.INTERNAL_SERVER_ERROR).entity(message).build();
         } catch (RDFBridgeException e) {
             logger.warn("Error while generating RDF from repository", e);
             return Response.status(Status.INTERNAL_SERVER_ERROR)
                     .entity("Error while generating RDF from repository").build();
         }
     }
-
-    private ConnectionInfo formConnectionInfo(String repositoryURL,
-                                              String workspaceName,
-                                              String username,
-                                              String password,
-                                              String connectionType) {
-        ConnectionInfo cInfo = new ConnectionInfo();
-        cInfo.setConnectionType(connectionType);
-        cInfo.setPassword(password);
-        cInfo.setRepositoryURL(repositoryURL);
-        cInfo.setUsername(username);
-        cInfo.setWorkspaceName(workspaceName);
-        return cInfo;
-    }
-}
+}
\ No newline at end of file

Added: incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/SessionResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/SessionResource.java?rev=1215106&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/SessionResource.java (added)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/java/org/apache/stanbol/cmsadapter/web/resources/SessionResource.java Fri Dec 16 12:14:40 2011
@@ -0,0 +1,105 @@
+/*
+ * 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.web.resources;
+
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+import static javax.ws.rs.core.MediaType.TEXT_PLAIN;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.stanbol.cmsadapter.core.repository.SessionManager;
+import org.apache.stanbol.cmsadapter.servicesapi.repository.RepositoryAccessException;
+import org.apache.stanbol.cmsadapter.web.utils.RestUtil;
+import org.apache.stanbol.commons.web.base.ContextHelper;
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+
+import com.sun.jersey.api.view.Viewable;
+
+/**
+ * Resource providing services for session management
+ */
+@Path("/cmsadapter/session")
+public class SessionResource extends BaseStanbolResource {
+
+    private SessionManager sessionManager;
+
+    public SessionResource(@Context ServletContext context) {
+        sessionManager = ContextHelper.getServiceFromContext(SessionManager.class, context);
+    }
+
+    @GET
+    @Produces(TEXT_HTML)
+    public Response get() {
+        return Response.ok(new Viewable("index", this), TEXT_HTML).build();
+    }
+
+    /**
+     * Returns a session key based on the given connection information. Returned key can be used in subsequent
+     * operations which requires a connection to content repository
+     * 
+     * @param repositoryURL
+     *            URL of the content repository. For <i>JCR</i> repositories <b>RMI</b> protocol, for
+     *            <i>CMIS</i> repositories <b>AtomPub Binding</b> is used. This parameter should be set
+     *            according to these connection methods.
+     * @param workspaceName
+     *            For JCR repositories this parameter determines the workspace to be connected. On the other
+     *            hand for CMIS repositories repository ID should be set to this parameter. In case of not
+     *            setting this parameter, for JCR default workspace is selected, for CMIS the first repository
+     *            obtained through the session object is selected.
+     * @param username
+     *            Username to connect to content repository
+     * @param password
+     *            Password to connect to content repository
+     * @param connectionType
+     *            Connection type; either <b>JCR</b> or <b>CMIS</b>
+     * @return a UUID representing matching with the session object obtained using the provided parameters
+     * @throws RepositoryAccessException
+     */
+    @GET
+    @Produces(TEXT_PLAIN)
+    public Response createSessionByInfo(@QueryParam("repositoryURL") String repositoryURL,
+                                        @QueryParam("workspaceName") String workspaceName,
+                                        @QueryParam("username") String username,
+                                        @QueryParam("password") String password,
+                                        @QueryParam("connectionType") String connectionType) throws RepositoryAccessException {
+
+        repositoryURL = RestUtil.nullify(repositoryURL);
+        workspaceName = RestUtil.nullify(workspaceName);
+        username = RestUtil.nullify(username);
+        password = RestUtil.nullify(password);
+        connectionType = RestUtil.nullify(connectionType);
+
+        if (repositoryURL == null || username == null || password == null || connectionType == null) {
+            return Response
+                    .status(Status.BAD_REQUEST)
+                    .entity(
+                        "Repository URL, username, password and connection type parameters should be set\n")
+                    .build();
+        }
+
+        String sessionKey = sessionManager.createSessionKey(repositoryURL, workspaceName, username, password,
+            connectionType);
+        return Response.status(Status.CREATED).entity(sessionKey).build();
+    }
+}

Modified: incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/index.ftl?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/index.ftl (original)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/ContenthubFeedResource/index.ftl Fri Dec 16 12:14:40 2011
@@ -32,37 +32,15 @@
 			<li><a href="#Submit_content_items">Submit content items</a></li>
 			<li><a href="#Delete_content_items">Delete content items</a></li>
 		</ul>
-		Interaction with the content repository is provided through the following properties. They are required all services provided by this endpoint.
-		Please note that while connecting JCR repositories <b>RMI protocol</b> is used, on the other hand for CMIS repositories <b>AtomPub Binding</b> 
-		is used. So, it is necessary to set <b>repositoryURL</b> parameter based on these connection methods. 
+		Interaction with the content repository will be obtained through the <b>Session Key</b> property. To be able to use the services below a session key
+		should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.  
 		<fieldset>
 			<legend>Connection parameters</legend>
 			<table>
 				<tbody>
 					<tr>
-						<th>Repository URL</th>
-						<td><input type="text" id="repositoryURL" value=""></td>
-					</tr>
-					<tr>
-						<th>Workspace Name</th>
-						<td><input type="text" id="workspaceName" value=""></td>
-					</tr>
-					<tr>
-						<th>Username</th>
-						<td><input type="text" id="username" value=""></td>
-					</tr>
-					<tr>
-						<th>Password</th>
-						<td><input type="password" id="password" value=""></td>
-					</tr>
-					<tr>
-						<th>Connection type</th>
-						<td>
-							<select id="connectionType">
-							  <option value="JCR">JCR</option>
-							  <option value="CMIS">CMIS</option>
-							</select>
-						</td>
+						<th>Session key</th>
+						<td><input type="text" id="sessionKey" value=""></td>
 					</tr>
 				</tbody>
 			</table>
@@ -157,7 +135,7 @@
 				<td><p>This service enables submission of content repository objects to Contenthub. Connection to the content repository is 
 				established by the provided connection information. This service makes possible to submit content items through either their IDs or 
 				paths in the content repository. Enhancements of content items are obtained through <b>Stanbol Enhancer</b> before submitting them to 
-				Contenthub.</p><br><br> 
+				Contenthub.<br><br> 
 				
 				If <code>id</code> parameter is set, the target object is obtained from the content repository according to its ID. If 
 				<code>path</code> parameter is set, first the ID of target object is obtained from the content repository and then the retrieved 
@@ -177,15 +155,8 @@
 				<th valign="top">Parameters</th>
 				<td>
 					<ul>
-						<li>@FormParam repositoryURL: URL of the content repository. For JCR repositories <b>RMI protocol</b>, for CMIS repositories
-							<b>AtomPub Binding</b> is used. This parameter should be set according to these connection methods.</li>
-			            <li>@FormParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
-			            	for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
-			            	for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
-			            	is selected.</li>
-			    		<li>@FormParam username: Username to connect to content repository</li>
-			    		<li>@FormParam password: Password to connect to content repository</li>
-			    		<li>@FormParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
+						<li>@FormParam sessionKey: Interaction with the content repository is provided through the <b>Session Key</b> property. To be able to use the services below a session key
+						should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.</li>
 			    		<li>@FormParam id: Content repository ID of the content item to be submitted</li>
 			    		<li>@FormParam path: Content repository path of the content item to be submitted</li>
 			    		<li>@FormParam recursive: This parameter is used together with <code>path</code> parameter. Its default value is 
@@ -198,13 +169,11 @@
 			<tr>
 				<th valign="top">Produces</th>
 				<td>HTTP 200 in case of successful execution.<br>
-					HTTP 400 when both <code>id</code> and <code>path</code> parameters are not set or one of the <code>username</code>, 
-					<code>password</code>, <code>connectionType</code>, <code>repositoryURL</code> parameters are not set</td>
-				
+					HTTP 400 when both <code>id</code> and <code>path</code> parameters or <code>sessionKey</code> parameter is not set</td>
 			</tr>
 			<tr>
 				<th valign="top">Example</th>
-				<td><pre>curl -i -X POST --data "repositoryURL=http://127.0.0.1:8084/alfresco/service/cmis&username=admin&password=admin&connectionType=CMIS&path=/contenthubfeedtest&recursive=true" http://localhost:8080/cmsadapter/contenthubfeed</pre></td>
+				<td><pre>curl -i -X POST --data "sessionKey=eec8ff46-aaf9-485f-a7b5-452c1d7197d0&path=/contenthubfeedtest&recursive=true" http://localhost:8080/cmsadapter/contenthubfeed</pre></td>
 			</tr>
 		</tbody>
 	</table></p>
@@ -232,14 +201,8 @@
 				<th valign="top">Parameters</th>
 				<td>
 					<ul>
-						<li>@FormParam repositoryURL: URL of the content repository</li>
-			            <li>@FormParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
-			            	for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
-			            	for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
-			            	is selected.</li>
-			    		<li>@FormParam username: Username to connect to content repository</li>
-			    		<li>@FormParam password: Password to connect to content repository</li>
-			    		<li>@FormParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
+						<li>@FormParam sessionKey: Interaction with the content repository is provided through the <b>Session Key</b> property. To be able to use the services below a session key
+						should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.</li>
 			    		<li>@FormParam id: Content repository ID of the content item to be submitted</li>
 			    		<li>@FormParam path: Content repository path of the content item to be submitted</li>
 			    		<li>@FormParam recursive: This parameter is used together with <code>path</code> parameter. Its default value is 
@@ -250,12 +213,11 @@
 			<tr>
 				<th valign="top">Produces</th>
 				<td>HTTP 200 in case of successful execution.<br>
-					HTTP 400 when both <code>id</code> and <code>path</code> parameters are not set or one of the <code>username</code>, 
-					<code>password</code>, <code>connectionType</code>, <code>repositoryURL</code> parameters are not set</td>
+					HTTP 400 when both <code>id</code> and <code>path</code> parameters or <code>sessionKey</code> parameter is not set</td>
 			</tr>
 			<tr>
 				<th valign="top">Example</th>
-				<td><pre>curl -i -X DELETE --data "repositoryURL=http://127.0.0.1:8084/alfresco/service/cmis&username=admin&password=admin&connectionType=CMIS&path=/contenthubfeedtest&recursive=true" http://localhost:8080/cmsadapter/contenthubfeed</pre></td>
+				<td><pre>curl -i -X DELETE --data "sessionKey=eec8ff46-aaf9-485f-a7b5-452c1d7197d0&path=/contenthubfeedtest&recursive=true" http://localhost:8080/cmsadapter/contenthubfeed</pre></td>
 			</tr>
 		</tbody>
 	</table>
@@ -283,11 +245,7 @@ $(function() {
 
 function submitContentItemsToContenthub() {
 	var data = new Object();
-	data.repositoryURL = $("#repositoryURL").val();
-	data.workspaceName = $("#workspaceName").val();
-	data.username = $("#username").val();
-	data.password = $("#password").val();
-	data.connectionType = $("#connectionType").val();
+	data.sessionKey = $("#sessionKey").val();
 	data.id = $("#contentID").val();
 	data.path = $("#contentPath").val();
 	data.recursive = $("#recursiveCheck").is(':checked') ? "true" : "false";
@@ -311,11 +269,7 @@ function submitContentItemsToContenthub(
 
 function deleteContentItemsFromContenthub(){
 	var data = new Object();
-	data.repositoryURL = $("#repositoryURL").val();
-	data.workspaceName = $("#workspaceName").val();
-	data.username = $("#username").val();
-	data.password = $("#password").val();
-	data.connectionType = $("#connectionType").val();
+	data.sessionKey = $("#sessionKey").val();
 	data.id = $("#contentID").val();
 	data.path = $("#contentPath").val();
 	data.recursive = $("#recursiveCheck").is(':checked') ? "true" : "false";
@@ -335,4 +289,4 @@ function deleteContentItemsFromContenthu
    		}
 	});
 }
-</script>
+</script>
\ No newline at end of file

Modified: incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource/index.ftl?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource/index.ftl (original)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RDFMapperResource/index.ftl Fri Dec 16 12:14:40 2011
@@ -31,37 +31,15 @@
 			<li><a href="#Map_RDF_to_repository">Map RDF to repository</a></li>
 			<li><a href="#Map_repository_to_RDF">Map repository to RDF</a></li>
 		</ul>
-		Interaction with the content repository is provided through the following properties. They are required all services provided by this endpoint.
-		Please note that while connecting JCR repositories <b>RMI protocol</b> is used, on the other hand for CMIS repositories <b>AtomPub Binding</b> 
-		is used. So, it is necessary to set <b>repositoryURL</b> parameter based on these connection methods. 
+		Interaction with the content repository will be obtained through the <b>Session Key</b> property. To be able to use the services below a session key
+		should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.  
 		<fieldset>
 			<legend>Connection parameters</legend>
 			<table>
 				<tbody>
 					<tr>
-						<th>Repository URL</th>
-						<td><input type="text" id="repositoryURL" value=""></td>
-					</tr>
-					<tr>
-						<th>Workspace Name</th>
-						<td><input type="text" id="workspaceName" value=""></td>
-					</tr>
-					<tr>
-						<th>Username</th>
-						<td><input type="text" id="username" value=""></td>
-					</tr>
-					<tr>
-						<th>Password</th>
-						<td><input type="password" id="password" value=""></td>
-					</tr>
-					<tr>
-						<th>Connection type</th>
-						<td>
-							<select id="connectionType">
-							  <option value="JCR">JCR</option>
-							  <option value="CMIS">CMIS</option>
-							</select>
-						</td>
+						<th>Session key</th>
+						<td><input type="text" id="sessionKey" value=""></td>
 					</tr>
 				</tbody>
 			</table>
@@ -116,7 +94,8 @@
 	<a onclick="javascript:postMapRepositoryToRDF()" href="javascript:void(0);">Map content repository to RDF</a>
 	<p>Base URI:
 		<input id="baseURIText" type="text" value="http://www.apache.org/stanbol/cms" class="url"/><br>
-		Store generated RDF persistently: <input id="storeCheck" type="checkbox"/>
+		Store generated RDF persistently: <input id="storeCheck" type="checkbox"/><br>
+		Update existing RDF with the generated one: <input id="updateCheck" type="checkbox" checked="yes"/>
 	</p>
 	<div id="postMapRepositoryToRDFResult" style="display: none; ">
 		<p><a href="#" onclick="$('#postMapRepositoryToRDFResult').hide(); return false;">Hide results</a>
@@ -128,11 +107,11 @@
 	<h3>Service Endpoint <a href="${it.publicBaseUri}cmsadapter/map">/cmsadapter/map</a></h3>
 	<p>Following services are available for this endpoint:<br>
 	<ul>
-		<li><a href="#Map_RDF_to_repository">Map RDF to repository</a></li>
-		<li><a href="#Map_repository_to_RDF">Map repository to RDF</a></li>
+		<li><a href="#Map_RDF_to_repository_rest">Map RDF to repository</a></li>
+		<li><a href="#Map_repository_to_RDF_rest">Map repository to RDF</a></li>
 	</ul>
 		
-	<a name="Map_RDF_to_repository" id="Map_RDF_to_repository"></a>
+	<a name="Map_RDF_to_repository_rest" id="Map_RDF_to_repository_rest"></a>
 	<h4>Map RDF to repository</h4>
 	<table>
 		<tbody>
@@ -153,15 +132,8 @@
 				<th valign="top">Parameters</th>
 				<td>
 					<ul>
-						<li>@FormParam repositoryURL: URL of the content repository. For JCR repositories <b>RMI protocol</b>, for CMIS repositories
-							<b>AtomPub Binding</b> is used. This parameter should be set according to these connection methods.</li>
-			            <li>@FormParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
-			            	for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
-			            	for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
-			            	is selected.</li>
-			    		<li>@FormParam username: Username to connect to content repository</li>
-			    		<li>@FormParam password: Password to connect to content repository</li>
-			    		<li>@FormParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
+						<li>@FormParam sessionKey: Interaction with the content repository is provided through the <b>Session Key</b> property. To be able to use the services below a session key
+						should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.</li>
 			    		<li>@FormParam serializedGraph: External RDF in <b>application/rdf+xml</b> format</li>
 			    		<li>@FormParam url: URL of the external RDF data.</li>
 			    	</ul>
@@ -169,11 +141,13 @@
 			</tr>
 			<tr>
 				<th valign="top">Produces</th>
-				<td>HTTP 200 in case of successful execution.</td>
+				<td>HTTP 200 in case of successful execution.<br>
+					HTTP 400 in case of <code>sessionKey</code> parameter or none of the <code>serializedGraph</code> and <code>url</code> parameters is not set<br>
+					HTTP 500 in case of an expected exception occurs</td>
 			</tr>
 			<tr>
 				<th valign="top">Example</th>
-				<td><pre>curl -i -X POST -d "repositoryURL=rmi://localhost:1099/crx&workspaceName=test&username=admin&password=admin&connectionType=JCR&url=http://www.externalrdf.data" http://localhost:8080/cmsadapter/map/rdf</pre></td>
+				<td><pre>curl -i -X POST -d "sessionKey=eec8ff46-aaf9-485f-a7b5-452c1d7197d0&url=http://www.externalrdf.data" http://localhost:8080/cmsadapter/map/rdf</pre></td>
 			</tr>
 		</tbody>
 	</table>
@@ -194,14 +168,8 @@
 				<th valign="top">Parameters</th>
 				<td>
 					<ul>
-						<li>@QueryParam repositoryURL: URL of the content repository</li>
-			            <li>@QueryParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
-			            	for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
-			            	for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
-			            	is selected.</li>
-			    		<li>@QueryParam username: Username to connect to content repository</li>
-			    		<li>@QueryParam password: Password to connect to content repository</li>
-			    		<li>@QueryParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
+						<li>@FormParam sessionKey: Interaction with the content repository is provided through the <b>Session Key</b> property. To be able to use the services below a session key
+						should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.</li>
 			    		<li>@FormDataParam rdfFile: Local RDF file to be submitted</li>
 			    		<li>@FormDataParam rdfFileInfo: Information about submitted RDF file</li>
 			    	</ul>
@@ -209,16 +177,18 @@
 			</tr>
 			<tr>
 				<th valign="top">Produces</th>
-				<td>HTTP 200 together with entry page of <b>/cmsadapter/map</b> endpoint, in case of successful execution.</td>
+				<td>HTTP 200 in case of successful execution.<br>
+					HTTP 400 when <code>sessionKey</code> parameter or an RDF file is not set<br>
+					HTTP 500 in case of an expected exception occurs</td>
 			</tr>
 			<tr>
 				<th valign="top">Example</th>
-				<td><pre>curl -i -X POST -F "rdfFile=@localRDFFile" "http://localhost:8080/cmsadapter/map/rdf?repositoryURL=http://localhost:8083/nuxeo/atom/cmis&workspaceName=test&username=admin&password=admin&connectionType=CMIS"</pre></td>
+				<td><pre>curl -i -X POST -F "rdfFile=@localRDFFile" "http://localhost:8080/cmsadapter/map/rdf?sessionKey=eec8ff46-aaf9-485f-a7b5-452c1d7197d0"</pre></td>
 			</tr>
 		</tbody>
 	</table>
 	
-	<a name="Map_repository_to_RDF" id="Map_repository_to_RDF"></a>
+	<a name="Map_repository_to_RDF_rest" id="Map_repository_to_RDF_rest"></a>
 	<h4>Map repository to RDF</h4>
 	<table>
 		<tbody>
@@ -241,26 +211,26 @@
 				<th valign="top">Parameters</th>
 				<td>
 					<ul>
-						<li>@FormParam repositoryURL: URL of the content repository</li>
-			            <li>@FormParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
-			            	for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
-			            	for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
-			            	is selected.</li>
-			    		<li>@FormParam username: Username to connect to content repository</li>
-			    		<li>@FormParam password: Password to connect to content repository</li>
-			    		<li>@FormParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
-			    		<li>@FormParam store: A boolean value indicating whether the generated will be stored persistently or not.</li>
+						<li>@FormParam sessionKey: Interaction with the content repository is provided through the <b>Session Key</b> property. To be able to use the services below a session key
+						should be through the <b><a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></b> resource.</li>
 			    		<li>@FormParam baseURI: Base URI for the RDF to be generated.</li>
+			    		<li>@FormParam store: A boolean value indicating whether the generated will be stored persistently or not.</li>
+			    		<li>@FormParam update: A boolean value indicating whether the generated will be added into an existing RDF having the
+			    		specified <code>baseURI</code>. If there is no existing RDF a new one is created. Note that, this parameter is 
+			    		considered only if <code>store</code> is set as <code>true</code>. If it is not set explicitly, its default value is
+			    		<code>true</code>.</li>
 			    	</ul>
 			    </td>
 			</tr>
 			<tr>
 				<th valign="top">Produces</th>
-				<td>Mapped RDF from content repository in <b>application/rdf+xml</b> format</td>.
+				<td>HTTP 200 together with the mapped RDF from content repository in <b>application/rdf+xml</b> format in case of successful execution<br>
+					HTTP 400 when session key parameter is not set<br>
+					HTTP 500 in case of an expected exception occurs</td>.
 			</tr>
 			<tr>
 				<th valign="top">Example</th>
-				<td><pre>curl -i -X POST -d "repositoryURL=rmi://localhost:1099/crx&workspaceName=test&username=admin&password=admin&connectionType=JCR&baseURI=http://www.apache.org/stanbol/cms&store=true" http://localhost:8080/cmsadapter/map/cms</pre></td>
+				<td><pre>curl -i -X POST -d "sessionKey=eec8ff46-aaf9-485f-a7b5-452c1d7197d0&baseURI=http://www.apache.org/stanbol/cms&store=true" http://localhost:8080/cmsadapter/map/cms</pre></td>
 			</tr>
 		</tbody>
 	</table>
@@ -272,12 +242,10 @@
 <script language="javascript">
 function postRawRDF() {
 	var data = new Object();
-	data.repositoryURL = $("#repositoryURL").val();
-	data.workspaceName = $("#workspaceName").val();
-	data.username = $("#username").val();
-	data.password = $("#password").val();
-	data.connectionType = $("#connectionType").val();
+	data.sessionKey = $("#sessionKey").val();
 	data.serializedGraph = $("#rawRDF").val();
+	$("#rawRDFpostResultText").text("RDF is being mapped to the content repository...");
+    $("#rawRDFpostResult").show();
 	$.ajax({
 	  	type: 'POST',
 	  	url: '${it.publicBaseUri}cmsadapter/map/rdf',
@@ -287,7 +255,7 @@ function postRawRDF() {
      		$("#rawRDFpostResult").show();
    		},
    		error: function(jqXHR, textStatus, errorThrown) {
-     		$("#rawRDFpostResultText").text(jqXHR.statusText + " - " + jqXHR.responseText);
+     		$("#rawRDFpostResultText").text(jqXHR.statusText + " - " + errorThrown + " - " + jqXHR.responseText);
      		$("#rawRDFpostResult").show();
    		}
 	});
@@ -295,12 +263,10 @@ function postRawRDF() {
 
 function postRDFFromURL() {
 	var data = new Object();
-	data.repositoryURL = $("#repositoryURL").val();
-	data.workspaceName = $("#workspaceName").val();
-	data.username = $("#username").val();
-	data.password = $("#password").val();
-	data.connectionType = $("#connectionType").val();
+	data.sessionKey = $("#sessionKey").val();
 	data.url = $("#urlInput").val();
+	$("#postRDFFromURLResultText").text("RDF from external URL is being mapped to the content repository...");
+    $("#postRDFFromURLResult").show();
 	$.ajax({
 	  	type: 'POST',
 	  	url: '${it.publicBaseUri}cmsadapter/map/rdf',
@@ -310,18 +276,14 @@ function postRDFFromURL() {
      		$("#postRDFFromURLResult").show();
    		},
    		error: function(jqXHR, textStatus, errorThrown) {
-     		$("#postRDFFromURLResultText").text(jqXHR.statusText + " - " + jqXHR.responseText);
+     		$("#postRDFFromURLResultText").text(jqXHR.statusText + " - " + errorThrown + " - " + jqXHR.responseText);
      		$("#postRDFFromURLResult").show();
    		}
 	});
 }
 
 function postLocalRDFFileMapping() {
-	var url = "?repositoryURL=" + $("#repositoryURL").val() + 
-				"&workspaceName=" + $("#workspaceName").val() + 
-				"&username=" + $("#username").val() +
-				"&password=" + $("#password").val() +
-				"&connectionType=" + $("#connectionType").val();
+	var url = "?sessionKey=" + $("#sessionKey").val();
 	url = "${it.publicBaseUri}cmsadapter/map/rdf" + url;
 	$('#localRDFFileForm').attr('action', url);
 	$('#localRDFFileForm').submit();
@@ -329,12 +291,9 @@ function postLocalRDFFileMapping() {
 
 function postMapRepositoryToRDF(){
 	var data = new Object();
-	data.repositoryURL = $("#repositoryURL").val();
-	data.workspaceName = $("#workspaceName").val();
-	data.username = $("#username").val();
-	data.password = $("#password").val();
-	data.connectionType = $("#connectionType").val();
+	data.sessionKey = $("#sessionKey").val();
 	data.store = $("#storeCheck").is(':checked') ? "true" : "false";
+	data.update = $("#updateCheck").is(':checked') ? "true" : "false";
 	data.baseURI = $("#baseURIText").val();
 	$("#postMapRepositoryToRDFResultText").text("Mapping CMS to RDF...");
 	$("#postMapRepositoryToRDFResult").show();
@@ -347,9 +306,9 @@ function postMapRepositoryToRDF(){
      		$("#postMapRepositoryToRDFResult").show();
    		},
    		error: function(jqXHR, textStatus, errorThrown) {
-     		$("#postMapRepositoryToRDFResultText").text(jqXHR.statusText + " - " + jqXHR.responseText);
+     		$("#postMapRepositoryToRDFResultText").text(jqXHR.statusText + " - " + errorThrown + " - " + jqXHR.responseText);
      		$("#postMapRepositoryToRDFResult").show();
    		}
 	});	
 }
-</script>
+</script>
\ No newline at end of file

Modified: incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RootResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RootResource/index.ftl?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RootResource/index.ftl (original)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/RootResource/index.ftl Fri Dec 16 12:14:40 2011
@@ -29,8 +29,9 @@
 <ul>
 	<li>RDF Map @ <a href="${it.publicBaseUri}cmsadapter/map">/cmsadapter/map</a></li>
 	<li>Contenthub Feed @ <a href="${it.publicBaseUri}cmsadapter/contenthubfeed">/cmsadapter/contenthubfeed</a></li>
+	<li>Session @ <a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session<a/></li>
 </ul>
 </div>
 
 </...@common.page>
-</#escape>
+</#escape>
\ No newline at end of file

Added: incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/SessionResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/SessionResource/index.ftl?rev=1215106&view=auto
==============================================================================
--- incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/SessionResource/index.ftl (added)
+++ incubator/stanbol/trunk/cmsadapter/web/src/main/resources/org/apache/stanbol/cmsadapter/web/templates/org/apache/stanbol/cmsadapter/web/resources/SessionResource/index.ftl Fri Dec 16 12:14:40 2011
@@ -0,0 +1,80 @@
+<#--
+  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.
+-->
+<#import "/imports/common.ftl" as common>
+<#escape x as x?html>
+<@common.page title="CMS Adapter" hasrestapi=true> 
+
+<div class="panel" id="webview">
+	<h3>Service Endpoint <a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></h3>
+	<p>
+		This endpoint provides services to generate a <b>session key</b> to be used in later usages of CMS Adapter
+		to access content repository. 
+	</p>
+</div>
+
+<div class="panel" id="restapi" style="display: none;">
+	<h3>Service Endpoint <a href="${it.publicBaseUri}cmsadapter/session">/cmsadapter/session</a></h3>
+	<p>Following services are available for this endpoint:<br>
+	<ul>
+		<li><a href="#Create_session">Create session</a></li>
+	</ul>
+		
+	<a name="Create_session" id="Create_session"></a>
+	<h4>Create session</h4>
+	<p><table>
+		<tbody>
+			<tr>
+				<th valign="top">Description</th>
+				<td><p>This services enables users to create session for later usage in the CMS Adapter. Created session is obtained by a generated
+				session key.</p>
+				</td>
+			</tr>
+			<tr>
+				<th valign="top">Request</th>
+				<td>GET /cmsadapter/session</td>
+			</tr>
+			<tr>
+				<th valign="top">Parameters</th>
+				<td>
+					<ul>
+						<li>@FormParam repositoryURL: URL of the content repository. For JCR repositories <b>RMI protocol</b>, for CMIS repositories
+							<b>AtomPub Binding</b> is used. This parameter should be set according to these connection methods.</li>
+						<li>@FormParam workspaceName: For JCR repositories this parameter determines the workspace to be connected. On the other hand
+							for CMIS repositories <b>repository ID</b> should be set to this parameter. In case of not setting this parameter,
+							for JCR <b>default workspace</b> is selected, for CMIS the <b>first repository</b> obtained through the session object 
+							is selected.</li>
+						<li>@FormParam username: Username to connect to content repository</li>
+						<li>@FormParam password: Password to connect to content repository</li>
+						<li>@FormParam connectionType: Connection type; either <b>JCR</b> or <b>CMIS</b></li>
+			    	</ul>
+			    </td>
+			</tr>
+			<tr>
+				<th valign="top">Produces</th>
+				<td>HTTP 201 together with the <b>session key</b> corresponding to created session in case of successful execution.<br>
+					HTTP 400 when one of the <code>repositoryURL</code>, <code>username</code>, <code>password</code> or <code>connectionType</code> parameters are not set</td>
+			</tr>
+			<tr>
+				<th valign="top">Example</th>
+				<td><pre>curl -X GET -H "Accept: text/plain" "http://localhost:8080/cmsadapter/session?repositoryURL=http://localhost:8083/nuxeo/atom/cmis&username=Administrator&password=Administrator&connectionType=CMIS"</pre></td>
+			</tr>
+		</tbody>
+	</table></p>
+</div>
+
+</...@common.page>
+</#escape>
\ No newline at end of file

Modified: incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/utils/ContentItemIDOrganizer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/utils/ContentItemIDOrganizer.java?rev=1215106&r1=1215105&r2=1215106&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/utils/ContentItemIDOrganizer.java (original)
+++ incubator/stanbol/trunk/contenthub/core/src/main/java/org/apache/stanbol/contenthub/core/utils/ContentItemIDOrganizer.java Fri Dec 16 12:14:40 2011
@@ -28,7 +28,7 @@ public class ContentItemIDOrganizer {
     public static final String CONTENT_ITEM_URI_PREFIX = "urn:content-item-";
 
     public static String attachBaseURI(String id) {
-        if (!id.startsWith(CONTENT_ITEM_URI_PREFIX)) {
+        if (!id.startsWith("urn:")) {
             id = CONTENT_ITEM_URI_PREFIX + id;
         }
         return id;