You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by su...@apache.org on 2012/11/27 10:32:01 UTC

svn commit: r1414032 - in /stanbol/trunk/contenthub/web/src/main: java/org/apache/stanbol/contenthub/web/resources/ java/org/apache/stanbol/contenthub/web/util/ resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/ resourc...

Author: suat
Date: Tue Nov 27 09:31:58 2012
New Revision: 1414032

URL: http://svn.apache.org/viewvc?rev=1414032&view=rev
Log:
Trying to commit the big patch prepared by Meric, in smaller chunks in accordance to the opened issues. In this commit, I am trying to commit changes to adapt multipart serialization of ContentItems. So, it mainly includes fixes for STANBOL-785, STANBOL-786 and STANBOL-788. 

As explained in the mentioned issues, adapting the multipart serialization of ContentItems, we do not need constraint parameter to be passed explicitly. Instead additional metadata comes as a certain part of the ContentItem. Based on this, the "constraint" parameters are removed from the RESTful services of StoreResource.

Based on these changes, documentation of the services and the HTML interface are also updated. 

There is also an additional RESTful service, taking a ContentItem parameter which was created by the ContentItemReader (i.e providing the multipart deserialization of ContentItems)

Modified:
    stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
    stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java
    stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/RestUtil.java
    stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl
    stanbol/trunk/contenthub/web/src/main/resources/templates/imports/searchrestapi.ftl
    stanbol/trunk/contenthub/web/src/main/resources/templates/imports/storerestapi.ftl

Modified: stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java (original)
+++ stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java Tue Nov 27 09:31:58 2012
@@ -17,6 +17,8 @@
 
 package org.apache.stanbol.contenthub.web.resources;
 
+import static javax.ws.rs.HttpMethod.DELETE;
+import static javax.ws.rs.HttpMethod.OPTIONS;
 import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
 import static javax.ws.rs.core.MediaType.MULTIPART_FORM_DATA;
 import static javax.ws.rs.core.MediaType.TEXT_HTML;
@@ -30,15 +32,11 @@ import static org.apache.clerezza.rdf.co
 import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.X_TURTLE;
 import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
 import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
-import static javax.ws.rs.HttpMethod.DELETE;
-import static javax.ws.rs.HttpMethod.OPTIONS;
-import static javax.ws.rs.HttpMethod.POST;
 
-import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -47,9 +45,7 @@ import java.net.URLConnection;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -78,7 +74,6 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
 import org.apache.clerezza.rdf.core.sparql.ParseException;
-import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocument;
@@ -86,28 +81,23 @@ import org.apache.solr.common.params.Mod
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
 import org.apache.stanbol.contenthub.search.featured.util.SolrContentItemConverter;
-import org.apache.stanbol.contenthub.search.solr.SolrSearchImpl;
 import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
 import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
 import org.apache.stanbol.contenthub.servicesapi.search.featured.DocumentResult;
 import org.apache.stanbol.contenthub.servicesapi.search.solr.SolrSearch;
 import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
-import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
 import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrStore;
 import org.apache.stanbol.contenthub.servicesapi.store.vocabulary.SolrVocabulary.SolrFieldName;
-import org.apache.stanbol.contenthub.web.util.JSONUtils;
+import org.apache.stanbol.contenthub.web.util.RestUtil;
+import org.apache.stanbol.enhancer.servicesapi.Chain;
 import org.apache.stanbol.enhancer.servicesapi.ContentItem;
 import org.apache.stanbol.enhancer.servicesapi.EngineException;
 import org.apache.stanbol.enhancer.servicesapi.helper.ContentItemHelper;
-import org.codehaus.jettison.json.JSONException;
 import org.osgi.framework.InvalidSyntaxException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.stanbol.commons.ldviewable.Viewable;
-import com.sun.jersey.core.header.FormDataContentDisposition;
-import com.sun.jersey.multipart.FormDataBodyPart;
-import com.sun.jersey.multipart.FormDataParam;
 
 /**
  * Resource to provide a CRU[D] REST API for content items and there related enhancements.
@@ -116,8 +106,6 @@ import com.sun.jersey.multipart.FormData
  * content item URI.
  * <p>
  * Retrieval is achieved using simple GET requests on the content item or enhancement public URIs.
- * <p>
- * Update is achieved by issue a PUT request on an existing content item public URI.
  */
 @Path("/contenthub/{index}/store")
 public class StoreResource extends BaseStanbolResource {
@@ -219,26 +207,10 @@ public class StoreResource extends BaseS
     }
 
     @OPTIONS
-    @Path("/edit/{uri:.+}")
-    public Response handleCorsPreflightEdit(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
-        return res.build();
-    }
-
-    @OPTIONS
     @Path("/{uri:.+}")
     public Response handleCorsPreflightURI(@Context HttpHeaders headers) {
         ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers, POST, DELETE, OPTIONS);
-        return res.build();
-    }
-
-    @OPTIONS
-    @Path("/update")
-    public Response handleCorsPreflightUpdate(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
+        enableCORS(servletContext, res, headers, DELETE, OPTIONS);
         return res.build();
     }
 
@@ -249,7 +221,7 @@ public class StoreResource extends BaseS
     /**
      * Cool URI handler for the uploaded resource.
      * 
-     * @param contentURI
+     * @param uri
      *            The URI of the resource in the Stanbol Contenthub store
      * @param headers
      *            HTTP headers
@@ -257,9 +229,9 @@ public class StoreResource extends BaseS
      */
     @GET
     @Path("/content/{uri:.+}")
-    public Response getContent(@PathParam(value = "uri") String contentURI, @Context HttpHeaders headers) throws StoreException {
-
-        ContentItem ci = solrStore.get(contentURI, indexName);
+    public Response getContent(@PathParam(value = "uri") String uri, @Context HttpHeaders headers) throws StoreException {
+        uri = RestUtil.nullify(uri);
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
@@ -268,7 +240,7 @@ public class StoreResource extends BaseS
         for (MediaType mt : headers.getAcceptableMediaTypes()) {
             if (mt.toString().startsWith(TEXT_HTML)) {
                 URI pageUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName)
-                        .path("store/page").path(contentURI).build();
+                        .path("store/page").path(uri).build();
                 ResponseBuilder rb = Response.temporaryRedirect(pageUri);
                 addCORSOrigin(servletContext, rb, headers);
                 return rb.build();
@@ -279,14 +251,14 @@ public class StoreResource extends BaseS
         for (MediaType mt : headers.getAcceptableMediaTypes()) {
             if (RDF_MEDIA_TYPES.contains(mt.toString())) {
                 URI metadataUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName)
-                        .path("store/metadata").path(contentURI).build();
+                        .path("store/metadata").path(uri).build();
                 ResponseBuilder rb = Response.temporaryRedirect(metadataUri);
                 addCORSOrigin(servletContext, rb, headers);
                 return rb.build();
             }
         }
         URI rawUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName).path("store/raw")
-                .path(contentURI).build();
+                .path(uri).build();
         ResponseBuilder rb = Response.temporaryRedirect(rawUri);
         addCORSOrigin(servletContext, rb, headers);
         return rb.build();
@@ -299,7 +271,7 @@ public class StoreResource extends BaseS
      * @param type
      *            Type can be {@code "metadata"} or {@code "raw"}. Based on the type, related parts of the
      *            content item will be prepared for download.
-     * @param contentURI
+     * @param uri
      *            URI of the resource in the Stanbol Contenthub store
      * @param format
      *            Rdf serialization format of metadata
@@ -310,51 +282,30 @@ public class StoreResource extends BaseS
     @GET
     @Path("/download/{type}/{uri:.+}")
     public Response downloadContentItem(@PathParam(value = "type") String type,
-                                        @PathParam(value = "uri") String contentURI,
+                                        @PathParam(value = "uri") String uri,
                                         @QueryParam(value = "format") String format,
                                         @Context HttpHeaders headers) throws IOException, StoreException {
-
-        ContentItem ci = solrStore.get(contentURI, indexName);
+        type = RestUtil.nullify(type);
+        uri = RestUtil.nullify(uri);
+        format = RestUtil.nullify(format);
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
         if (type.equals("metadata")) {
-            String fileName = URLEncoder.encode(contentURI, "utf-8") + "-metadata";
-            File file = new File(fileName);
-            if (file.exists()) {
-                file.delete();
-            }
-            boolean success = file.createNewFile();
-            if (success) {
-                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
-                serializer.serialize(bos, ci.getMetadata(), format);
-                bos.close();
-            } else {
-                log.error("Failed to create file: {}", fileName);
-            }
+            String fileName = URLEncoder.encode(uri, "utf-8") + "-metadata";
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            serializer.serialize(baos, ci.getMetadata(), format);
+            InputStream is = new ByteArrayInputStream(baos.toByteArray());
 
-            ResponseBuilder response = Response.ok((Object) file);
+            ResponseBuilder response = Response.ok((Object) is);
             response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
             response.type("text/plain");
             addCORSOrigin(servletContext, response, headers);
             return response.build();
         } else if (type.equals("raw")) {
-            // TODO we should return the content directly without the file indirection
-            String fileName = URLEncoder.encode(contentURI, "utf-8") + "-raw";
-            File file = new File(fileName);
-            if (file.exists()) {
-                file.delete();
-            }
-            boolean success = file.createNewFile();
-            if (success) {
-                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
-                bos.write(IOUtils.toByteArray(ci.getStream()));
-                bos.close();
-            } else {
-                log.error("Failed to create file: {}", fileName);
-            }
-
-            ResponseBuilder response = Response.ok((Object) file);
+            String fileName = URLEncoder.encode(uri, "utf-8") + "-raw";
+            ResponseBuilder response = Response.ok((Object) ci.getStream());
             response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
             response.type(ci.getMimeType());
             addCORSOrigin(servletContext, response, headers);
@@ -369,7 +320,7 @@ public class StoreResource extends BaseS
      * HTTP GET method to retrieve the metadata of the content item. Generally, metadata contains the
      * enhancements of the content item.
      * 
-     * @param contentURI
+     * @param uri
      *            URI id of the resource in the Stanbol Contenthub store
      * @return RDF representation of the metadata of the content item.
      * @throws IOException
@@ -377,9 +328,10 @@ public class StoreResource extends BaseS
      */
     @GET
     @Path("/metadata/{uri:.+}")
-    public Response getContentItemMetaData(@PathParam(value = "uri") String contentURI,
-                                           @Context HttpHeaders headers) throws IOException, StoreException {
-        ContentItem ci = solrStore.get(contentURI, indexName);
+    public Response getContentItemMetaData(@PathParam(value = "uri") String uri, @Context HttpHeaders headers) throws IOException,
+                                                                                                              StoreException {
+        uri = RestUtil.nullify(uri);
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
@@ -394,7 +346,7 @@ public class StoreResource extends BaseS
     /**
      * HTTP GET method to retrieve the raw content item.
      * 
-     * @param contentURI
+     * @param uri
      *            URI of the resource in the Stanbol Contenthub store
      * @return Raw data of the content item.
      * @throws IOException
@@ -402,9 +354,10 @@ public class StoreResource extends BaseS
      */
     @GET
     @Path("/raw/{uri:.+}")
-    public Response getRawContent(@PathParam(value = "uri") String contentURI, @Context HttpHeaders headers) throws IOException,
-                                                                                                            StoreException {
-        ContentItem ci = solrStore.get(contentURI, indexName);
+    public Response getRawContent(@PathParam(value = "uri") String uri, @Context HttpHeaders headers) throws IOException,
+                                                                                                     StoreException {
+        uri = RestUtil.nullify(uri);
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
@@ -413,70 +366,78 @@ public class StoreResource extends BaseS
         return rb.build();
     }
 
+    /*
+     * Services for content item creation
+     */
+
     /**
-     * This method creates the JSON string of a content item (to be edited) to display it in the HTML view.
+     * HTTP POST method to create a content item in Contenthub. This method takes a {@link ContentItem} object
+     * directly. This means that the values provided for this service will be parsed by the multipart mime
+     * serialization of Content Items. (see the following links: <a href=
+     * 
+     * "http://incubator.apache.org/stanbol/docs/trunk/components/enhancer/contentitem.html#multipart_mime_serialization"
+     * >Content Item Multipart Serialization</a> and <a
+     * href="http://incubator.apache.org/stanbol/docs/trunk/components/enhancer/enhancerrest.html">Using the
+     * multi-part content item RESTful API extensions</a>)
      * 
-     * @param contentURI
-     *            URI id of the resource in the Stanbol Contenthub store
-     * @return JSON representation of the {@link SolrContentItem}
+     * @param ci
+     *            {@link ContentItem} to be stored.
+     * @param title
+     *            The title for the content item. Titles can be used to present summary of the actual content.
+     *            For example, search results are presented by showing the titles of resultant content items.
+     * @param chain
+     *            name of a particular {@link Chain} in which the enhancement engines are ordered according to
+     *            a specific use case or need
+     * @param headers
+     *            HTTP Headers
+     * @return URI of the newly created contentitem
      * @throws StoreException
+     * @throws URISyntaxException
      */
-    @GET
-    @Path("/edit/{uri:.+}")
-    public Response editContentItem(@PathParam(value = "uri") String contentURI, @Context HttpHeaders headers) throws StoreException {
-        SolrContentItem sci = (SolrContentItem) solrStore.get(contentURI, indexName);
-        if (sci == null) {
-            throw new WebApplicationException(404);
+    @POST
+    @Consumes(MULTIPART_FORM_DATA)
+    public Response createContentItem(ContentItem ci,
+                                      @QueryParam(value = "title") String title,
+                                      @QueryParam(value = "chain") String chain,
+                                      @Context HttpHeaders headers) throws StoreException, URISyntaxException {
+        title = RestUtil.nullify(title);
+        chain = RestUtil.nullify(chain);
+        MediaType acceptedHeader = RestUtil.getAcceptedMediaType(headers, null);
+        if (title != null) {
+            ci.addPart(SolrStore.TITLE_URI, title);
+        }
+        if (ci.getMetadata() == null || ci.getMetadata().isEmpty()) {
+            solrStore.enhanceAndPut(ci, indexName, chain);
+        } else {
+            solrStore.put(ci, indexName);
         }
 
-        String jsonString;
-        try {
-            jsonString = JSONUtils.createJSONString(sci);
-        } catch (JSONException e) {
-            throw new StoreException(e.getMessage(), e);
+        ResponseBuilder rb = null;
+        if (acceptedHeader != null && acceptedHeader.isCompatible(MediaType.TEXT_HTML_TYPE)) {
+            // use a redirect to point browsers to newly created content
+            rb = Response.seeOther(makeRedirectionURI(ci.getUri().getUnicodeString()));
+        } else {
+            rb = Response.created(new URI(ci.getUri().getUnicodeString()));
         }
-        ResponseBuilder rb = Response.ok(jsonString);
         addCORSOrigin(servletContext, rb, headers);
         return rb.build();
     }
 
-    /*
-     * Services for content item creation
-     */
-    // TODO other parameters like title, ldprogram/index should be considered
-    // for this service
     /**
-     * HTTP POST method to create a content item in Contenthub. This is the very basic method to create the
-     * content item. The payload of the POST method should include the raw data of the content item to be
-     * created. This method stores the content in the default Solr index ("contenthub").
+     * HTTP POST method to create a content item in Contenthub.
      * 
      * @param data
      *            Raw data of the content item
-     * @param headers
-     *            HTTP Headers
-     * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
-     *         HTML view.
-     * @throws URISyntaxException
-     * @throws EngineException
-     * @throws StoreException
-     */
-    @POST
-    @Consumes(WILDCARD + ";qs=0.5")
-    public Response createContentItem(byte[] data, @Context HttpHeaders headers) throws URISyntaxException,
-                                                                                EngineException,
-                                                                                StoreException {
-        String contentURI = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
-        return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI, headers);
-    }
-
-    /**
-     * HTTP POST method to create a content item in Contenthub.
      * 
-     * @param contentURI
+     * @param uri
      *            URI for the content item. If not supplied, Contenthub automatically assigns a unique ID
      *            (uri) to the content item.
-     * @param data
-     *            Raw data of the content item
+     * @param title
+     *            The title for the content item. Titles can be used to present summary of the actual content.
+     *            For example, search results are presented by showing the titles of resultant content items.
+     * @param chain
+     *            name of a particular {@link Chain} in which the enhancement engines are ordered according to
+     *            a specific use case or need
      * @param headers
      *            HTTP headers
      * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
@@ -486,36 +447,40 @@ public class StoreResource extends BaseS
      * @throws StoreException
      */
     @POST
-    @Path("/{uri:.+}")
     @Consumes(WILDCARD)
-    public Response createContentItemWithId(@PathParam(value = "uri") String contentURI,
-                                            byte[] data,
-                                            @Context HttpHeaders headers) throws URISyntaxException,
-                                                                         EngineException,
-                                                                         StoreException {
-        return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI, headers);
+    public Response createContentItemWithURI(byte[] data,
+                                             @QueryParam(value = "uri") String uri,
+                                             @QueryParam(value = "title") String title,
+                                             @QueryParam(value = "chain") String chain,
+                                             @Context HttpHeaders headers) throws URISyntaxException,
+                                                                          EngineException,
+                                                                          StoreException {
+        uri = RestUtil.nullify(uri);
+        title = RestUtil.nullify(title);
+        chain = RestUtil.nullify(chain);
+        if (uri == null) {
+            uri = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
+        }
+        return createEnhanceAndRedirect(data, headers.getMediaType(), uri, false, title, chain, headers);
     }
 
     /**
      * HTTP POST method to create a content item in Contenthub. This method requires the content to be
      * text-based.
      * 
-     * @param id
-     *            Optinal id for the content item to be created.
+     * @param uri
+     *            Optional URI for the content item to be created.
      * @param content
      *            Actual content in text format. If this parameter is supplied, {@link url} is ommitted.
      * @param url
      *            URL where the actual content resides. If this parameter is supplied (and {@link content} is
      *            {@code null}, then the content is retrieved from this url.
-     * @param jsonCons
-     *            Constraints in JSON format. Constraints are used to add supplementary metadata to the
-     *            content item. For example, author of the content item may be supplied as {author:
-     *            "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the
-     *            corresponding Solr schema includes the author field. Solr indexed can be created/adjusted
-     *            through LDPath programs.
      * @param title
      *            The title for the content item. Titles can be used to present summary of the actual content.
      *            For example, search results are presented by showing the titles of resultant content items.
+     * @param chain
+     *            name of a particular {@link Chain} in which the enhancement engines are ordered according to
+     *            a specific use case or need
      * @param headers
      *            HTTP headers (optional)
      * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
@@ -528,78 +493,29 @@ public class StoreResource extends BaseS
      */
     @POST
     @Consumes(APPLICATION_FORM_URLENCODED)
-    public Response createContentItemFromForm(@FormParam("id") String id,
+    public Response createContentItemFromForm(@FormParam("uri") String uri,
                                               @FormParam("content") String content,
                                               @FormParam("url") String url,
-                                              @FormParam("constraints") String jsonCons,
                                               @FormParam("title") String title,
+                                              @FormParam("chain") String chain,
                                               @Context HttpHeaders headers) throws URISyntaxException,
                                                                            EngineException,
                                                                            MalformedURLException,
                                                                            IOException,
                                                                            StoreException {
-        Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
-        if (jsonCons != null) {
-            constraints = JSONUtils.convertToMap(jsonCons);
-        }
-        return createContentItemFromForm(id, content, url, null, null, null, headers, constraints, title);
+        uri = RestUtil.nullify(uri);
+        url = RestUtil.nullify(url);
+        title = RestUtil.nullify(title);
+        chain = RestUtil.nullify(chain);
+        return createContentItemFromForm(uri, content, url, headers, title, chain);
     }
 
-    /**
-     * HTTP POST method to create a content item from file. File is read and loaded as the actual content.
-     * 
-     * @param file
-     *            {@link File} which contains the content for the content item.
-     * @param disposition
-     *            Additional information about the {@link file} parameter
-     * @param jsonCons
-     *            Constraints in JSON format. Constraints are used to add supplementary metadata to the
-     *            content item. For example, author of the content item may be supplied as {author:
-     *            "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the
-     *            corresponding Solr schema includes the author field. Solr indexed can be created/adjusted
-     *            through LDPath programs.
-     * @param title
-     *            The title for the content item. Titles can be used to present summary of the actual content.
-     *            For example, search results are presented by showing the titles of resultant content items.
-     * @param headers
-     *            HTTP headers (optional)
-     * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
-     *         HTML view.
-     * @throws URISyntaxException
-     * @throws EngineException
-     * @throws MalformedURLException
-     * @throws IOException
-     * @throws StoreException
-     */
-    @POST
-    @Consumes(MULTIPART_FORM_DATA)
-    public Response createContentItemFromForm(@FormDataParam("file") File file,
-                                              @FormDataParam("file") FormDataContentDisposition disposition,
-                                              @FormDataParam("file") FormDataBodyPart body,
-                                              @FormDataParam("constraints") String jsonCons,
-                                              @FormDataParam("title") String title,
-                                              @Context HttpHeaders headers) throws URISyntaxException,
-                                                                           EngineException,
-                                                                           MalformedURLException,
-                                                                           IOException,
-                                                                           StoreException {
-        Map<String,List<Object>> constraints = new HashMap<String,List<Object>>();
-        if (jsonCons != null) {
-            constraints = JSONUtils.convertToMap(jsonCons);
-        }
-        return createContentItemFromForm(file.getName(), null, null, file, disposition, body, headers,
-            constraints, title);
-    }
-
-    private Response createContentItemFromForm(String id,
+    private Response createContentItemFromForm(String uri,
                                                String content,
                                                String url,
-                                               File file,
-                                               FormDataContentDisposition disposition,
-                                               FormDataBodyPart body,
                                                HttpHeaders headers,
-                                               Map<String,List<Object>> constraints,
-                                               String title) throws URISyntaxException,
+                                               String title,
+                                               String chain) throws URISyntaxException,
                                                             EngineException,
                                                             MalformedURLException,
                                                             IOException,
@@ -616,192 +532,82 @@ public class StoreResource extends BaseS
                 data = IOUtils.toByteArray(uc.getInputStream());
                 mt = MediaType.valueOf(uc.getContentType());
             } catch (IOException e) {
-                // TODO: collect remote resource error message for user friendly
-                // feedback
-            }
-        } else if (file != null) {
-            mt = body.getMediaType();
-            data = FileUtils.readFileToByteArray(file);
-            if (title == null || title.isEmpty()) {
-                title = disposition.getFileName();
+                log.error("Failed to obtain content from the remote URL: {}", url, e);
+                throw e;
             }
         }
-
         if (data != null && mt != null) {
-            if (id == null || id.trim().equals("")) {
-                id = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
+            if (uri == null || uri.trim().equals("")) {
+                uri = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
             }
-            return createEnhanceAndRedirect(data, mt, id, true, constraints, title, headers);
+            return createEnhanceAndRedirect(data, mt, uri, true, title, chain, headers);
         } else {
-            // TODO: add user-friendly feedback on empty requests from a form
-            ResponseBuilder rb = Response.seeOther(new URI("/contenthub/" + indexName + "/store"));
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
+            log.error(String
+                    .format(
+                        "There should be valid values for the media type and content. Media type: %s, content==null: %b",
+                        mt, content == null));
+            throw new IllegalStateException(
+                    String.format(
+                        "There should be valid values for the media type and content. Media type: %s, content==null: %b",
+                        mt, content == null));
         }
     }
 
     /*
-     * This method takes "title" argument as well as "constraints" so that it would be easy to specify title
-     * while calling RESTful services. If the title is specified explicitly it is set as the title otherwise,
-     * it is searched in the constraints.
+     * This method takes "title" argument so that it would be easy to specify title while calling RESTful
+     * services. If the title is specified explicitly it is set as the title otherwise, it is searched in the
+     * constraints.
      */
     private Response createEnhanceAndRedirect(byte[] content,
                                               MediaType mediaType,
-                                              String contentURI,
+                                              String uri,
                                               boolean useExplicitRedirect,
-                                              Map<String,List<Object>> constraints,
                                               String title,
+                                              String chain,
                                               HttpHeaders headers) throws EngineException,
                                                                   URISyntaxException,
                                                                   StoreException {
 
-        SolrContentItem sci = solrStore.create(content, contentURI, title, mediaType.toString(), constraints);
-        solrStore.enhanceAndPut(sci, indexName);
+        ContentItem ci = solrStore.create(content, uri, title, mediaType.toString());
+        solrStore.enhanceAndPut(ci, indexName, chain);
         if (useExplicitRedirect) {
             // use an redirect to point browsers to newly created content
-            ResponseBuilder rb = Response.seeOther(makeRedirectionURI(sci.getUri().getUnicodeString()));
+            ResponseBuilder rb = Response.seeOther(makeRedirectionURI(ci.getUri().getUnicodeString()));
             addCORSOrigin(servletContext, rb, headers);
             return rb.build();
         } else {
-            // use the correct way of notifying the RESTful client that the
-            // resource has been successfully created
-            ResponseBuilder rb = Response.created(makeRedirectionURI(sci.getUri().getUnicodeString()));
+            ResponseBuilder rb = Response.created(makeRedirectionURI(ci.getUri().getUnicodeString()));
             addCORSOrigin(servletContext, rb, headers);
             return rb.build();
         }
     }
 
-    private URI makeRedirectionURI(String contentURI) throws URISyntaxException {
-        return new URI(uriInfo.getBaseUri() + "contenthub/" + indexName + "/store/content/" + contentURI);
-    }
-
-    /**
-     * HTTP POST method to update an existing content item.
-     * 
-     * @param contentURI
-     *            URI of the content item to be updated.
-     * @param content
-     *            Actual content in text format. If this parameter is supplied, {@link url} is ommitted.
-     * @param url
-     *            URL where the actual content resides. If this parameter is supplied (and {@link content} is
-     *            {@code null}, then the content is retrieved from this url.
-     * @param jsonCons
-     *            Constraints in JSON format. Constraints are used to add supplementary metadata to the
-     *            content item. For example, author of the content item may be supplied as {author:
-     *            "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the
-     *            corresponding Solr schema includes the author field. Solr indexed can be created/adjusted
-     *            through LDPath programs.
-     * @param title
-     *            The title for the content item. Titles can be used to present summary of the actual content.
-     *            For example, search results are presented by showing the titles of resultant content items.
-     * @param headers
-     *            HTTP headers (optional)
-     * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
-     *         HTML view.
-     * @throws URISyntaxException
-     * @throws EngineException
-     * @throws MalformedURLException
-     * @throws IOException
-     * @throws StoreException
-     */
-    @POST
-    @Path("/update")
-    @Consumes(APPLICATION_FORM_URLENCODED)
-    public Response updateContentItemFromForm(@FormParam("uri") String contentURI,
-                                              @FormParam("content") String content,
-                                              @FormParam("url") String url,
-                                              @FormParam("constraints") String jsonCons,
-                                              @FormParam("title") String title,
-                                              @Context HttpHeaders headers) throws URISyntaxException,
-                                                                           EngineException,
-                                                                           MalformedURLException,
-                                                                           IOException,
-                                                                           StoreException {
-        if (contentURI != null && !contentURI.isEmpty()) {
-            deleteContentItem(contentURI, headers);
-        }
-        return createContentItemFromForm(null, content, url, jsonCons, title, headers);
-    }
-
-    /**
-     * HTTP POST method to update an existing content item.
-     * 
-     * @param contentURI
-     *            URI of the content item to be updated.
-     * @param file
-     *            {@link File} which contains the content for the content item.
-     * @param disposition
-     *            Additional information about the {@link file} parameter
-     * @param jsonCons
-     *            Constraints in JSON format. Constraints are used to add supplementary metadata to the
-     *            content item. For example, author of the content item may be supplied as {author:
-     *            "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the
-     *            corresponding Solr schema includes the author field. Solr indexed can be created/adjusted
-     *            through LDPath programs.
-     * @param title
-     *            The title for the content item. Titles can be used to present summary of the actual content.
-     *            For example, search results are presented by showing the titles of resultant content items.
-     * @param headers
-     *            HTTP headers (optional)
-     * @return Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the
-     *         HTML view.
-     * @throws URISyntaxException
-     * @throws EngineException
-     * @throws MalformedURLException
-     * @throws IOException
-     * @throws StoreException
-     */
-    @POST
-    @Path("/update")
-    @Consumes(MULTIPART_FORM_DATA)
-    public Response updateContentItemFromForm(@FormDataParam("uri") String contentURI,
-                                              @FormDataParam("file") File file,
-                                              @FormDataParam("file") FormDataContentDisposition disposition,
-                                              @FormDataParam("file") FormDataBodyPart body,
-                                              @FormDataParam("constraints") String jsonCons,
-                                              @FormDataParam("title") String title,
-                                              @Context HttpHeaders headers) throws URISyntaxException,
-                                                                           EngineException,
-                                                                           MalformedURLException,
-                                                                           IOException,
-                                                                           StoreException {
-        if (contentURI != null && !contentURI.isEmpty()) {
-            deleteContentItem(contentURI, headers);
-        }
-        return createContentItemFromForm(file, disposition, body, jsonCons, title, headers);
+    private URI makeRedirectionURI(String uri) throws URISyntaxException {
+        return new URI(uriInfo.getBaseUri() + "contenthub/" + indexName + "/store/content/" + uri);
     }
 
     /**
      * HTTP DELETE method to delete a content item from Contenhub.
      * 
-     * @param contentURI
+     * @param uri
      *            URI of the content item to be deleted.
      * @return HTTP OK
      * @throws StoreException
      */
     @DELETE
     @Path("/{uri:.+}")
-    public Response deleteContentItem(@PathParam(value = "uri") String contentURI,
-                                      @Context HttpHeaders headers) throws StoreException {
-        ContentItem ci = solrStore.get(contentURI, indexName);
+    public Response deleteContentItem(@PathParam(value = "uri") String uri, @Context HttpHeaders headers) throws StoreException {
+        uri = RestUtil.nullify(uri);
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
-        solrStore.deleteById(contentURI, indexName);
+        solrStore.deleteById(uri, indexName);
         ResponseBuilder rb = Response.ok();
         addCORSOrigin(servletContext, rb, headers);
         return rb.build();
     }
 
-    private Response createEnhanceAndRedirect(byte[] data,
-                                              MediaType mediaType,
-                                              String contentURI,
-                                              HttpHeaders headers) throws EngineException,
-                                                                  URISyntaxException,
-                                                                  StoreException {
-        return createEnhanceAndRedirect(data, mediaType, contentURI, false, null, null, headers);
-    }
-
     /*
      * Services to draw HTML view
      */
@@ -846,15 +652,14 @@ public class StoreResource extends BaseS
 
     @Path("/page/{uri:.+}")
     @Produces(TEXT_HTML)
-    public ContentItemResource getContentItemView(@PathParam(value = "uri") String contentURI) throws IOException,
-                                                                                              StoreException {
-        ContentItem ci = solrStore.get(contentURI, indexName);
+    public ContentItemResource getContentItemView(@PathParam(value = "uri") String uri) throws IOException,
+                                                                                       StoreException {
+        ContentItem ci = solrStore.get(uri, indexName);
         if (ci == null) {
             throw new WebApplicationException(404);
         }
-        return new ContentItemResource(contentURI, ci, uriInfo, "/contenthub/" + indexName
-                                                                + "/store/download", tcManager, serializer,
-                servletContext);
+        return new ContentItemResource(uri, ci, uriInfo, "/contenthub/" + indexName + "/store/download",
+                tcManager, serializer, servletContext);
     }
 
     // Helper methods for HTML view

Modified: stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java (original)
+++ stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java Tue Nov 27 09:31:58 2012
@@ -16,7 +16,6 @@
  */
 package org.apache.stanbol.contenthub.web.util;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -25,15 +24,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.commons.io.IOUtils;
 import org.apache.solr.client.solrj.response.FacetField;
-import org.apache.stanbol.contenthub.servicesapi.Constants;
 import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramCollection;
-import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
 import org.apache.stanbol.contenthub.servicesapi.search.featured.DocumentResult;
+import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
 import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeyword;
-import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
-import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -200,22 +195,6 @@ public class JSONUtils {
         }
         return jObj.toString(4);
     }
-    
-    public static String createJSONString(SolrContentItem sci) throws JSONException {
-        String content = null;
-        try {
-            content = IOUtils.toString(sci.getStream(), Constants.DEFAULT_ENCODING);
-        } catch (IOException ex) {
-            logger.error("Cannot read the content.", ex);
-        }
-
-        JSONObject jObj = new JSONObject(sci.getConstraints());
-        jObj.put("content", content);
-        jObj.put("mimeType", sci.getMimeType());
-        jObj.put("uri", ContentItemIDOrganizer.detachBaseURI(sci.getUri().getUnicodeString()));
-        jObj.put("title", sci.getTitle());
-        return jObj.toString(4);
-    }
 
     public static String createJSONString(LDProgramCollection ldpc) throws JSONException {
         JSONObject jObj = new JSONObject();

Modified: stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/RestUtil.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/RestUtil.java?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/RestUtil.java (original)
+++ stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/RestUtil.java Tue Nov 27 09:31:58 2012
@@ -27,14 +27,14 @@ import javax.ws.rs.core.MediaType;
  * Utility class for REST services
  */
 public class RestUtil {
-    
+
     public static final Set<String> supportedMediaTypes;
     static {
         Set<String> types = new HashSet<String>();
         types.add(MediaType.APPLICATION_JSON);
         supportedMediaTypes = Collections.unmodifiableSet(types);
     }
-    
+
     /**
      * @param parameter
      *            parameter to be checked
@@ -49,7 +49,7 @@ public class RestUtil {
         }
         return parameter;
     }
-    
+
     public static boolean isJSONaccepted(HttpHeaders headers) {
         if (!headers.getAcceptableMediaTypes().isEmpty()) {
             for (MediaType accepted : headers.getAcceptableMediaTypes()) {
@@ -62,7 +62,7 @@ public class RestUtil {
         }
         return false;
     }
-    
+
     public static boolean isHTMLaccepted(HttpHeaders headers) {
         if (!headers.getAcceptableMediaTypes().isEmpty()) {
             for (MediaType accepted : headers.getAcceptableMediaTypes()) {
@@ -75,9 +75,9 @@ public class RestUtil {
         }
         return false;
     }
-    
-    public static MediaType getAcceptedMediaType(HttpHeaders headers) {
-        MediaType acceptedMediaType = MediaType.APPLICATION_JSON_TYPE; // default
+
+    public static MediaType getAcceptedMediaType(HttpHeaders headers, MediaType defaultMediaType) {
+        MediaType acceptedMediaType = defaultMediaType;
         if (!headers.getAcceptableMediaTypes().isEmpty()) {
             for (MediaType accepted : headers.getAcceptableMediaTypes()) {
                 if (!accepted.isWildcardType()) {

Modified: stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl (original)
+++ stanbol/trunk/contenthub/web/src/main/resources/templates/html/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl Tue Nov 27 09:31:58 2012
@@ -58,7 +58,6 @@
           <#list it.recentlyEnhancedItems as item>
             <tr>
               <td>
-                <img src="${it.staticRootUrl}/contenthub/images/edit_icon_16.png" onClick="javascript:editContentItem('${item.localId}', '${item.title?js_string}');" title="Edit this item" />
                 <img src="${it.staticRootUrl}/contenthub/images/delete_icon_16.png" onClick="javascript:deleteContentItem('${item.localId}');" title="Delete this item" />
               </td>
               <td><a href="${item.dereferencableURI}" title="${item.dereferencableURI}"><#if item.title??>${item.title}<#else>${item.localId}</#if></a></td>
@@ -79,53 +78,57 @@
     </div>
   </div>
 
-  <div id="editingDiv"> </div>
-
-  <h3>Submit Constraints to Content Item for analysis</h3>
+  <h3>Submit Content Item </h3>
   <fieldset>
-    <legend>Give Field:Value for your content</legend>
-    <input type="text" id="fieldTitle" value="title" readonly="readonly"/> : <input type="text" id="valueTitle" />
-    <div id="constraintsDiv" style="max-height:190px;overflow:auto"></div>
-    <br/>
-    <label onClick="javascript:addConstraint();">
-      <img src="${it.staticRootUrl}/contenthub/images/add_icon_16.png" />  Add a new constraint
-    </label>
+    <legend>Optional parameters</legend>
+    <table>
+      <tr>
+      	<td>
+    	  Title : 
+    	</td>
+    	<td>
+    	  <input type="text" id="valueTitle" />
+    	</td>
+      </tr>
+      <tr>
+        <td>
+          Chain Name : 
+    	</td>
+    	<td>
+    	  <input type="text" id="valueChain" />
+    	</td>
+      </tr>
+    </table>
   </fieldset>
   <br/>
   
-  <h3>Submit a new Content Item for analysis</h3>
-  <form method="POST" id="contentForm" accept-charset="utf-8" onSubmit = "return setConstraints();">
+  <form method="POST" id="contentForm" accept-charset="utf-8" onSubmit = "return performSubmit(1);">
     <fieldset>
-      <input type="hidden" id="constraintsContent" name="constraints" value="" />
-      <input type="hidden" name="title" value="" />
-      <input type="hidden" id="uriContent" name="uri" value="" />
+      <input type="hidden" id="title1" name="title" value="" />
+      <input type="hidden" id="chain1" name="chain" value="" />
       <legend>Submit raw text content</legend>
       <p><textarea rows="15" id="contentTextArea" name="content"></textarea></p>
       <p><input type="submit" id="contentSubmit" value="Submit text" /></p>
     </fieldset>
   </form>
 
-  <form method="POST" id="urlForm" accept-charset="utf-8" onSubmit = "return setConstraints();">
+  <form method="POST" id="urlForm" accept-charset="utf-8" onSubmit = "return performSubmit(2);">
     <fieldset>
-      <input type="hidden" id="constraintsURL" name="constraints" value="" />
-      <input type="hidden" name="title" value="" />
-      <input type="hidden" id="uriURL" name="uri" value="" />
+      <input type="hidden" id="title2" name="title" value="" />
+      <input type="hidden" id="chain2" name="chain" value="" />
       <legend>Submit a remote public resource by URL</legend>
       <p>
-        <input name="url" type="text" class="url" />
+        <input name="url" id="url" type="text" class="url" />
         <input type="submit" id="urlSubmit" value="Submit URL" />
       </p>
     </fieldset>
   </form>
 
-  <form method="POST" id="fileForm" accept-charset="utf-8"  enctype="multipart/form-data" onSubmit = "return setConstraints();">
+  <form method="POST" id="fileForm" accept-charset="utf-8"  enctype="multipart/form-data" onSubmit = "return performSubmit(3);">
     <fieldset>
-      <input type="hidden" id="constraintsFile" name="constraints" value="" />
-      <input type="hidden" name="title" value="" />
-      <input type="hidden" id="uriFile" name="uri" value="" />
-      <legend>Upload a local file</legend>
+    <legend>Upload a local file</legend>
       <p>
-        <input id="file" name="file" type="file"/>
+        <input type="file" id="file" name="content"/>
         <input type="submit" id="fileSubmit" value="Submit file" />
       </p>
     </fieldset>
@@ -159,148 +162,46 @@
         window.location.replace("${it.publicBaseUri}contenthub/" + index + "/store/");
     }
     
-    function setConstraints() {
-        var titleStr = document.getElementById("valueTitle").value;
-        var fileStr = document.getElementById("file").value;
-        if((!fileStr || fileStr == "") && (!titleStr || titleStr == "")) {
-            // control for the title input... it must exist
-            alert('You should enter title for your content');
-            return false;
-        }
-        
-        var i;
-        var result = JSON.parse("{}");
-        for(i=0; i<=counter; i++) {
-            if (document.getElementById("textDiv" + i)) {
-                var field = jQuery.trim(document.getElementsByName("fieldText"+i)[0].value);
-                var value = jQuery.trim(document.getElementsByName("valueText"+i)[0].value);
-                if(!field || !value) {
-                    continue;
-                }
-                if(result[field] == null) {
-                    result[field] = new Array();
-                }
-                var values = value.split(",");
-                for(j=0; j<values.length; j++) {
-                    result[field].push(jQuery.trim(values[j]));
-                }
-            }
-        }
-    
-        var constraints = document.getElementsByName('constraints');
-        var title = document.getElementsByName('title');
-        for (var i in constraints) {
-            constraints[i].value = JSON.stringify(result);
-            title[i].value =  document.getElementById('valueTitle').value;
-        }
+    function performSubmit(submissionMethod) {
+    	if(submissionMethod == 1) {
+    		var content = document.getElementById("contentTextArea").value;
+    		if(!content || content == "") {
+    			alert('You should enter non-empty content');
+            	return false;
+    		}
+    		document.getElementById('title1').value = document.getElementById('valueTitle').value;
+    		document.getElementById('chain1').value = document.getElementById('valueChain').value;
+    	} else if(submissionMethod == 2) {
+    	
+    		var url = document.getElementById("url").value;
+    		if(!url || url == "") {
+    			alert('You should enter non-empty URL');
+            	return false;
+    		}
+    		document.getElementById('title2').value = document.getElementById('valueTitle').value;
+    		document.getElementById('chain2').value = document.getElementById('valueChain').value;
+    	} else if(submissionMethod == 3) {
+    		var file = document.getElementById("file").value;
+    		if(!file || file == "") {
+    			alert('You should specify a file to be submitted');
+            	return false;
+    		}
+    		var title = $.trim($("#valueTitle").val());
+    		var chain = $.trim($("#valueChain").val());
+    		var actionStr = "";
+    		if(title != null && title != ""){
+    			actionStr += "?title="+encodeURIComponent(title);
+    		}
+    		if(chain != null && chain != ""){
+    			actionStr += (actionStr != "") ? "&" : "?" 
+    			actionStr += "chain="+encodeURIComponent(chain);
+    		}
+    		document.getElementById('fileForm').action = actionStr;
+    	}
         return true;
     }
   
-    function addConstraint() {
-        var newCons = document.createElement('div');
-        newCons.setAttribute('id','textDiv' + counter);
-        var fieldName = "fieldText"+counter;
-        var valueName = "valueText"+counter;
-        var url = "javascript:removeConstraint(" + counter + ");";
-    
-        newCons.innerHTML = "<br/><input type='text' name=" + fieldName + " />" 
-                 + " : "
-                 + "<input type='text' name=" + valueName + " />"
-                 + "  <img src='${it.staticRootUrl}/contenthub/images/delete_icon_16.png' title='Remove' onClick=" + url + " />";
-           
-        document.getElementById("constraintsDiv").appendChild(newCons);
-        document.getElementsByName(fieldName)[0].focus();
-        counter++;
-    }
-  
-    function removeConstraint(divNo) {
-        var constraintsDiv = document.getElementById('constraintsDiv');
-        constraintsDiv.removeChild(document.getElementById('textDiv'+divNo));
-    }
-
-    function startEditing(set) {
-        if(set) {
-            $("#contentForm").attr("action", "/contenthub/${it.indexName}/store/update");
-            $("#contentSubmit").attr("value", "Update text");
-            $("#urlForm").attr("action", "/contenthub/${it.indexName}/store/update");
-            $("#urlSubmit").attr("value", "Update URL");
-            $("#fileForm").attr("action", "/contenthub/${it.indexName}/store/update");
-            $("#fileSubmit").attr("value", "Update file");
-        }
-        else {
-            $("#contentForm").attr("action", "");
-            $("#contentSubmit").attr("value", "Submit text");
-            $("#urlForm").attr("action", "");
-            $("#urlSubmit").attr("value", "Submit URL");
-            $("#fileForm").attr("action", "");
-            $("#fileSubmit").attr("value", "Submit file");
-        }
-    }
-  
-    function cancelEditing() {
-        var uris = document.getElementsByName('uri');
-        for (var i in uris) {
-            uris[i].value = "";
-        }
-        document.getElementById("editingDiv").innerHTML = "";
-        startEditing(false);
-    }
-
-    function editContentItem(vlocalid, vtitle) {
-        var lurl = "${it.publicBaseUri}contenthub/${it.indexName}/store/edit/" + vlocalid;
-        document.getElementById("constraintsDiv").innerHTML = "";
-        counter=0;
-        $.ajax({
-            url: lurl,
-            type: "GET",
-            async: true,
-            cache: false,
-            success: function(jsonCons) {
-                var contentItem = JSON.parse(jsonCons);
-                if(contentItem != null) {
-                    startEditing(true);
-                    //fill the text content item related components in the user interface
-                    // TODO: use more mimeType
-                    if(contentItem["mimeType"] == "text/plain") {
-                        document.getElementById("contentTextArea").value = contentItem["content"];
-                    } else {
-                        document.getElementById("contentTextArea").value = "";
-                    }
-                    var uris = document.getElementsByName('uri');
-                    for (var i in uris) {
-                        uris[i].value = contentItem["uri"];
-                    }
-                    document.getElementById("editingDiv").innerHTML =   '<img src="${it.staticRootUrl}/contenthub/images/delete_icon_16.png" title="Cancel Editing" onClick="javascript:cancelEditing()" />'
-                                        + " You are editing Content Item with title: <b>" + contentItem["title"] + "</b>";
-                    document.getElementById("valueTitle").value = contentItem["title"];
-              
-                    //delete already consumed values from json representation so that they will not be added to the constraints
-                    delete contentItem["content"];
-                    delete contentItem["uri"];
-                    delete contentItem["mimeType"];
-                    delete contentItem["title"];
-              
-                    for(var p in contentItem) {
-                        if(contentItem.hasOwnProperty(p)) {
-                            var fieldHtmlName = getHtmlName(p.toString());
-                            addConstraint();
-                            var createdConstraintIndex = counter - 1;
-                            document.getElementsByName("fieldText"+createdConstraintIndex)[0].value = fieldHtmlName;
-                            document.getElementsByName("valueText"+createdConstraintIndex)[0].value = contentItem[p].substring(1, contentItem[p].length-1);
-                        }
-                    }
-                }  
-            },
-            error: function(content) {
-                alert(result.status + ' ' + result.statusText);
-            }
-        });
-    }  
-  
     function deleteContentItem(vlocalid) {
-        if(vlocalid == document.getElementById("uriContent").value) {
-            cancelEditing();
-        }
         var lurl = "${it.publicBaseUri}contenthub/${it.indexName}/store/" + vlocalid;
         $.ajax({
             url: lurl,

Modified: stanbol/trunk/contenthub/web/src/main/resources/templates/imports/searchrestapi.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/resources/templates/imports/searchrestapi.ftl?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/resources/templates/imports/searchrestapi.ftl (original)
+++ stanbol/trunk/contenthub/web/src/main/resources/templates/imports/searchrestapi.ftl Tue Nov 27 09:31:58 2012
@@ -17,10 +17,6 @@
 
 <h3>The RESTful API of the Contenthub Search</h3>
 
-There are two endpoints you can reach from search
-<li>Featured Search</li>
-<li>Related Search</li>
-
 <h3>Featured Search</h3>  
 <table>
 <tbody>
@@ -66,7 +62,7 @@ There are two endpoints you can reach fr
 
 <hr>
 
-
+<!--
 <h3>Related Search</h3>
 
 Related Search provide three sub-endpoints
@@ -204,7 +200,7 @@ Related Search provide three sub-endpoin
 <pre>curl -i -X GET http://localhost:8080/contenthub/search/related/referencedsite?keyword=Paris -H "Accept:application/json"</pre>
 
 <hr>
-
+-->
 <script>
 function selectText(element) {
     var doc = document;

Modified: stanbol/trunk/contenthub/web/src/main/resources/templates/imports/storerestapi.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/contenthub/web/src/main/resources/templates/imports/storerestapi.ftl?rev=1414032&r1=1414031&r2=1414032&view=diff
==============================================================================
--- stanbol/trunk/contenthub/web/src/main/resources/templates/imports/storerestapi.ftl (original)
+++ stanbol/trunk/contenthub/web/src/main/resources/templates/imports/storerestapi.ftl Tue Nov 27 09:31:58 2012
@@ -25,65 +25,10 @@
   whose name is "contenthub". That is the reason for two consecutive "contenthub"s in the endpoint.
   Lastly, "store" page provides the storage related functionalities of Contenthub such as document submission.</p>
 
-  <p>You can upload content to the Contenthub for analysis with or without providing the content
-   id at your option:</p>
-  <ul>
-    <li><code>POST</code> content to <code>${it.publicBaseUri}contenthub/${it.indexName}/store/<strong>content-id</strong></code>
-     with <code>Content-Type: text/plain</code>.</li>
-    <li><code>GET</code> content with its enhancements from the same URL.</li>
-  </ul>
-  
-  <p><code><strong>content-id</strong></code> can be any valid URI and
-   will be used to fetch your item back later. <code><strong>content-id</strong></code>s are unique within Contenthub.</p>
-
-  <p>On a unix-ish box you can use run the following command from
-   the top-level source directory to populate the Stanbol Contenthub service with
-   sample content items:</p>
-
-<pre>
-for file in enhancer/data/text-examples/*.txt;
-do
-  curl -i -X POST -H "Content-Type:text/plain" -T $file ${it.publicBaseUri}contenthub/${it.indexName}/store/$(basename $file);
-done
-</pre> 
-
-  Alternatively you can let the Stanbol Contenthub automatically build an id base on the SHA1
-  hash of the content by posting it at the root of the Contenthub.
-  <ul>
-    <li><code>POST</code> content to <code>${it.publicBaseUri}contenthub/${it.indexName}/store</code>
-     with <code>Content-Type: text/plain</code>.</li>
-  </ul>
-  
-  <p>For instance:</p>
-<pre>
-curl -i -X POST -H "Content-Type:text/plain" \
-     --data "The Stanbol enhancer can detect famous cities such as Paris." \
-     ${it.publicBaseUri}contenthub/${it.indexName}/store
-    
-HTTP/1.1 201 Created
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/store/content/{<code><strong>content-id</strong><code>}
-Content-Length: 0
-Server: Jetty(6.1.x)
-</pre>
-
-<h3>Fetching back the original content item and the related enhancements from the Contenthub</h3>
-
-<p>Once the content is created in the Contenthub, you can fetch back either the original content, a HTML summary view or
-the extracted RDF metadata by dereferencing the URL:</p>
-
-<pre>
-curl -i <strong>-H "Accept: text/plain"</strong> ${it.publicBaseUri}contenthub/${it.indexName}/store/content/{<code><strong>content-id</strong><code>}
-
-HTTP/1.1 307 TEMPORARY_REDIRECT
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/store/raw/{<code><strong>content-id</strong><code>}
-Content-Length: 0
-Server: Jetty(6.1.x)
-</pre>
-
 <p>
 Tutorials on Stanbol Contenthub can be found in the following links:<br/>
-<a href="http://incubator.apache.org/stanbol/docs/trunk/contenthub/">Contenhub - One Minute Tutorial</a><br/>
-<a href="http://incubator.apache.org/stanbol/docs/trunk/contenthub/contenthub5min">Contenthub - Five Minutes Tutorial</a>
+<a href="http://stanbol.apache.org/docs/trunk/components/contenthub/">Contenhub - One Minute Tutorial</a><br/>
+<a href="http://stanbol.apache.org/docs/trunk/components/contenthub/contenthub5min">Contenthub - Five Minutes Tutorial</a>
 </p>
 
 <br>
@@ -91,12 +36,12 @@ Tutorials on Stanbol Contenthub can be f
 
 <h3>Create a Content Item</h3>
 
-<h4>Create with raw content</h4>  
+<h4>Create with multipart/form-data</h4>  
 <table>
 <tbody>
   <tr>
     <th>Description</th>
-    <td>HTTP POST method to create a content item in Contenthub. This is the very basic method to create the content item. The payload of the POST method should include the raw data of the content item to be created. This method stores the content in the default Solr index ("contenthub").</td>
+    <td>HTTP POST method to create a content item in Contenthub. This method takes a ContentItem object directly. This means that the values provided for this service will be parsed by the multipart mime serialization of Content Items. (see the following links: <a href="http://incubator.apache.org/stanbol/docs/trunk/components/enhancer/contentitem.html#multipart_mime_serialization">Content Item Multipart Serialization</a> and <a href="http://incubator.apache.org/stanbol/docs/trunk/components/enhancer/enhancerrest.html">Using the multi-part content item RESTful API extensions</a>)</td>
   </tr>
   <tr>
     <th>Request</th>
@@ -104,153 +49,67 @@ Tutorials on Stanbol Contenthub can be f
   </tr>
   <tr>
     <th>Parameter</th>
-    <td><b>data:</b> Raw data of the content item</td>
-  </tr>
-  <tr>
-    <th>Produces</th>
-    <td>Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the HTML view</td>
-  </tr>
-  <tr>
-    <th>Throws</th>
     <td>
-      URISyntaxException<br>
-      EngineException<br>
-      StoreException
-    </td>
-  </tr>
-</tbody>
-</table>
-<h4>Example</h4>
-<div class="preParent">
-  <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
-<pre>
-<div id="curl1" class="curlLine">curl -i -X POST -H "Content-Type:text/plain" --data @/home/user/Documents/test.txt http://localhost:8080/contenthub/contenthub/store<hr/></div>curl -i -X POST -H "Content-Type:text/plain" \
-     --data @/home/user/Documents/test.txt \
-     http://localhost:8080/contenthub/contenthub/store
-</pre>
-</div>
-
-<div class="preParent">
-  <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
-<pre>
-<div id="curl2" class="curlLine">curl -i -X POST -H "Content-Type:text/plain" --data "I live in Paris." http://localhost:8080/contenthub/contenthub/store<hr/></div>curl -i -X POST -H "Content-Type:text/plain" \ 
-     --data "I live in Paris." \
-     http://localhost:8080/contenthub/contenthub/store
-</pre>
-</div>
-
-<hr>
-
-<h4>Create with raw content and user specified uri</h4>
-<table>
-<tbody>
-  <tr>
-    <th>Description</th>
-    <td>HTTP POST method to create a content item in Contenthub. This is the very basic method to create the content item. The payload of the POST method should include the raw data of the content item to be created. This method stores the content in the default Solr index ("contenthub").</td>
-  </tr>
-  <tr>
-    <th>Request</th>
-    <td>POST /contenthub/{indexName}/store/{uri}</td>
-  </tr>
-  <tr>
-    <th>Parameter</th>
-    <td>
-      <b>data:</b> Raw data of the content item<br>
-      <b>uri:</b>  URI for the content item. If not supplied, Contenthub automatically assigns a unique ID (uri) to the content item.
+      <b>ci:</b> ContentItem to be stored.<br/>
+      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br/>
+      <b>chain:</b> name of a particular Chain in which the enhancement engines are ordered according to a specific use case or need
     </td>
   </tr>
   <tr>
     <th>Produces</th>
-    <td>Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the HTML view.</td>
+    <td>uri of the newly created contentitem</td>
   </tr>
   <tr>
     <th>Throws</th>
     <td>
       URISyntaxException<br>
-      EngineException<br>
       StoreException
     </td>
   </tr>
 </tbody>
 </table>
 <h4>Example</h4>
+In the examples below, specified parameters are processed by the multipart serialization feature and a ContentItem object is created as a result.</br> 
+With following curl command, a ContentItem is created using the data specified in the content parameter. 
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl3" class="curlLine">curl -i -X POST -H "Content-Type:text/plain" --data @/home/user/Documents/test.txt http://localhost:8080/contenthub/contenthub/store/example1234<hr/></div>curl -i -X POST -H "Content-Type:text/plain" \
-     --data @/home/user/Documents/test.txt \
-     http://localhost:8080/contenthub/contenthub/store/example1234
+<div id="curl1" class="curlLine">curl -i -F "content=I live in Paris.;type=text/plain" "http://localhost:8080/contenthub/contenthub/store?title=Paris"<hr/></div>curl -i -F "content=I live in Paris.;type=text/plain" \ 
+     "http://localhost:8080/contenthub/contenthub/store?title=Paris"
 </pre>
 </div>
 
+In the example below, metadata of the ContentItem is set with the <b>metadata</b> parameter. Note that the name of the metadata file is set as the URI of the ContentItem. So, it is suggested that the name of the file would start with <b>urn:</b> prefix by convention to provide valid URI for the ContentItem. 
+
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl4" class="curlLine">curl -i -X POST -H "Content-Type:text/plain" --data "I live in Paris." http://localhost:8080/contenthub/contenthub/store/example1234<hr/></div>curl -i -X POST -H "Content-Type:text/plain" \
-     --data "I live in Paris." \
-     http://localhost:8080/contenthub/contenthub/store/example1234
+<div id="curl2" class="curlLine">curl -i -F "metadata=@;/urn:my-content-item;type=application/rdf+xml" -F "content=I live in Paris.;type=text/plain" "http://localhost:8080/contenthub/contenthub/store"<hr/></div>curl -i -F "metadata=@urn:my-content-item;type=application/rdf+xml" \
+        -F "content=I live in Paris.;type=text/plain" \
+     "http://localhost:8080/contenthub/contenthub/store"
 </pre>
 </div>
 
-<hr>
-
-
-<h4>Create with form elements</h4>
-<table>
-<tbody>
-  <tr>
-    <th>Description</th>
-    <td>Creates a content item in Contenthub. This method requires the content to be text-based</td>
-  </tr>
-  <tr>
-    <th>Request</th>
-    <td>POST /contenthub/{indexName}/store</td>
-  </tr>
-  <tr>
-    <th>Parameter</th>
-    <td>
-      <b>content:</b> Actual content in text format. If this parameter is supplied, url is ommitted.<br>
-      <b>url:</b> URL where the actual content resides. If this parameter is supplied (and content is <code>null</code>, then the content is retrieved from this url.<br>
-      <b>constraints:</b> Constraints in JSON format. Constraints are used to add supplementary metadata to the content item. For example, author of the content item may be supplied as {author: "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the corresponding Solr schema includes the author field. Solr indexed can be created/adjusted through LDPath programs.<br>
-      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br>
-    </td>
-  </tr>
-  <tr>
-    <th>Produces</th>
-    <td>Redirects to "contenthub/{indexName}/store/content/{uri}" which shows the content item in the HTML view.</td>
-  </tr>
-  <tr>
-    <th>Throws</th>
-    <td>
-      URISyntaxException<br>
-      EngineException<br>
-      MalformedURLException<br>
-      IOException<br>
-      StoreException
-    </td>
-  </tr>
-</tbody>
-</table>
-<h4>Example</h4>
+It is also possible to specify a custom URI for the ContentItem as in the example below. A valid URI should start with a scheme name followed by a colon ":" . By convention you can use <b>urn:</b> prefix for your custom URIs.
 
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl5" class="curlLine">curl -i -X POST --data "content=Paris is the capital of France&constraints={type:city}&title=Paris" http://localhost:8080/contenthub/contenthub/store<hr/></div>curl -i -X POST --data \
-     "content=Paris is the capital of France&constraints={type:city}&title=Paris" \
-     http://localhost:8080/contenthub/contenthub/store
+<div id="curl2_1" class="curlLine">curl -i -F "metadata=@metadata_file;type=application/rdf+xml" -F "content=I live in London.;type=text/plain" "http://localhost:8080/contenthub/contenthub/store?uri=urn:my-content-item3"<hr/></div>curl -i -F "metadata=@metadata_file;type=application/rdf+xml" \
+        -F "content=I live in London.;type=text/plain" \
+     "http://localhost:8080/contenthub/contenthub/store?uri=urn:my-content-item3"
 </pre>
 </div>
 
 <hr>
 
 
-<h4>Create with file</h4>  
+<h4>Create with raw content</h4>
 <table>
 <tbody>
   <tr>
     <th>Description</th>
-    <td>HTTP POST method to create a content item from file. File is read and loaded as the actual content.</td>
+    <td>HTTP POST method to create a content item in Contenthub. This is the very basic method to create the content item. The payload of the POST method should include the raw data of the content item to be created. This method stores the content in the default Solr index ("contenthub").</td>
   </tr>
   <tr>
     <th>Request</th>
@@ -259,23 +118,21 @@ Tutorials on Stanbol Contenthub can be f
   <tr>
     <th>Parameter</th>
     <td>
-      <b>file:</b> File which contains the content for the content item.<br>
-      <b>disposition:</b> Additional information about the file parameter<br>
-      <b>jsonCons:</b> Constraints in JSON format. Constraints are used to add supplementary metadata to the content item. For example, author of the content item may be supplied as {author: "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the corresponding Solr schema includes the author field. Solr indexed can be created/adjusted through LDPath programs.<br>
-      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br>
+      <b>data:</b> Raw data of the content item<br>
+      <b>uri:</b>  URI for the content item. If not supplied, Contenthub automatically assigns a unique ID (uri) to the content item.<br/>
+      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br/>
+      <b>chain:</b> name of a particular Chain in which the enhancement engines are ordered according to a specific use case or need
     </td>
   </tr>
   <tr>
     <th>Produces</th>
-    <td>Redirects to "contenthub/{indexName}/store/content/{uri}" which shows the content item in the HTML view.</td>
+    <td>Redirects to "contenthub/{indexName}/store/content/uri" which shows the content item in the HTML view.</td>
   </tr>
   <tr>
     <th>Throws</th>
     <td>
       URISyntaxException<br>
       EngineException<br>
-      MalformedURLException<br>
-      IOException<br>
       StoreException
     </td>
   </tr>
@@ -285,37 +142,33 @@ Tutorials on Stanbol Contenthub can be f
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl6" class="curlLine">curl -i POST -F "file=@/home/mrc/Desktop/test.txt" -F "constraints={type:city}" -F "title=Paris" http://localhost:8080/contenthub/contenthub/store<hr/></div>curl -i POST -F "file=@/home/mrc/Desktop/test.txt" \
-             -F "constraints={type:city}" \ 
-             -F "title=Paris" \
-     http://localhost:8080/contenthub/contenthub/store
+<div id="curl3" class="curlLine">curl -i -X POST -H "Content-Type:text/plain" --data @content_file "http://localhost:8080/contenthub/contenthub/store?uri=urn:my-content-item4&title=contentitem4"<hr/></div>curl -i -X POST -H "Content-Type:text/plain" \
+     --data @contentfile \
+     "http://localhost:8080/contenthub/contenthub/store?uri=urn:my-content-item4&title=contentitem4"
 </pre>
 </div>
 
 <hr>
 
-
-<h3>Update a Content Item</h3>
-
-<h4>Update with form elements</h4>
+<h4>Create with form elements</h4>
 <table>
 <tbody>
   <tr>
     <th>Description</th>
-    <td>HTTP POST method to update an existing content item.</td>
+    <td>Creates a content item in Contenthub. This method requires the content to be text-based</td>
   </tr>
   <tr>
     <th>Request</th>
-    <td>POST /contenthub/{indexName}/store/update</td>
+    <td>POST /contenthub/{indexName}/store</td>
   </tr>
   <tr>
     <th>Parameter</th>
     <td>
-      <b>uri:</b> URI of the content item to be updated.<br>
+      <b>uri:</b> Optional uri for the content item to be created.<br>
       <b>content:</b> Actual content in text format. If this parameter is supplied, url is ommitted.<br>
       <b>url:</b> URL where the actual content resides. If this parameter is supplied (and content is <code>null</code>, then the content is retrieved from this url.<br>
-      <b>jsonCons:</b> Constraints in JSON format. Constraints are used to add supplementary metadata to the content item. For example, author of the content item may be supplied as {author: "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the corresponding Solr schema includes the author field. Solr indexed can be created/adjusted through LDPath programs.<br>
-      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br>
+      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br/>
+      <b>chain:</b> name of a particular Chain in which the enhancement engines are ordered according to a specific use case or need
     </td>
   </tr>
   <tr>
@@ -335,67 +188,22 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
+
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl7" class="curlLine">curl -i -X POST --data "uri=example1234&content=Paris is the capital of France&constraints={type:city}&title=France" http://localhost:8080/contenthub/contenthub/store/update<hr/></div>curl -i -X POST --data \
-     "uri=example1234&content=Paris is the capital of France&constraints={type:city}&title=France" \
-     http://localhost:8080/contenthub/contenthub/store/update
+<div id="curl5" class="curlLine">curl -i -X POST --data "content=Ankara is the capital of Turkey&title=Ankara" http://localhost:8080/contenthub/contenthub/store<hr/></div>curl -i -X POST --data "content=Ankara is the capital of Turkey&title=Ankara" \ 
+     "http://localhost:8080/contenthub/contenthub/store"
 </pre>
 </div>
 
-<hr>
-
-
-<h4>Update with file</h4>  
-<table>
-<tbody>
-  <tr>
-    <th>Description</th>
-    <td>HTTP POST method to update an existing content item.</td>
-  </tr>
-  <tr>
-    <th>Request</th>
-    <td>POST /contenthub/{indexName}/store/update</td>
-  </tr>
-  <tr>
-    <th>Parameter</th>
-    <td>
-      <b>uri:</b> URI of the content item to be updated.<br>
-      <b>file:</b> File which contains the content for the content item.<br>
-      <b>disposition:</b> Additional information about the file parameter<br>
-      <b>jsonCons:</b> Constraints in JSON format. Constraints are used to add supplementary metadata to the content item. For example, author of the content item may be supplied as {author: "John Doe"}. Then, this constraint is added to the Solr and will be indexed if the corresponding Solr schema includes the author field. Solr indexed can be created/adjusted through LDPath programs.<br>
-      <b>title:</b> The title for the content item. Titles can be used to present summary of the actual content. For example, search results are presented by showing the titles of resultant content items.<br>
-    </td>
-  </tr>
-  <tr>
-    <th>Produces</th>
-    <td>Redirects to "contenthub/{indexName}/store/content/{uri}" which shows the content item in the HTML view.</td>
-  </tr>
-  <tr>
-    <th>Throws</th>
-    <td>
-      URISyntaxException<br>
-      EngineException<br>
-      MalformedURLException<br>
-      IOException<br>
-      StoreException
-    </td>
-  </tr>
-</tbody>
-</table>
-<h4>Example</h4>
 <div class="preParent">
   <img onClick="javascript:getLine(this.parentNode);" class="copyImg" src="${it.staticRootUrl}/contenthub/images/copy_icon_16.png" title="Get command in a single line" />
 <pre>
-<div id="curl8" class="curlLine">curl -i POST -F "file=@/home/mrc/Desktop/test.txt" -F "constraints={type:city}" -F "title=Paris" -F "uri=example1234" http://localhost:8080/contenthub/contenthub/store/update<hr/></div>curl -i POST -F "file=@/home/mrc/Desktop/test.txt" \
-             -F "constraints={type:city}" \
-             -F "title=Paris" \
-             -F "uri=example1234" \
-     http://localhost:8080/contenthub/contenthub/store/update
+<div id="curl6" class="curlLine">curl -i -X POST --data "url=http://en.wikipedia.org/wiki/Istanbul&title=Istanbul" "http://localhost:8080/contenthub/contenthub/store"<hr/></div>curl -i -X POST --data "url=http://en.wikipedia.org/wiki/Istanbul&title=Istanbul" \
+     "http://localhost:8080/contenthub/contenthub/store"
 </pre>
 </div>
-
 <hr>
 
 
@@ -425,7 +233,7 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
-<pre>curl -i -X DELETE http://localhost:8080/contenthub/contenthub/store/example-uri-1234</pre>
+<pre>curl -i -X DELETE "http://localhost:8080/contenthub/contenthub/store/example-uri-1234"</pre>
 
 <hr>
 
@@ -454,7 +262,7 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/content/uri-234231</pre>
+<pre>curl -i -X GET "http://localhost:8080/contenthub/contenthub/store/content/uri-234231"</pre>
 
 <hr>
 
@@ -485,8 +293,8 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/download/metadata/5d85e7c63cc48c0985?format=application%2Fjson</pre>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/download/raw/5d85e7c63cc48c01b8d4?format=application%2Frdf%2Bxml</pre>
+<pre>curl -i -X GET "http://localhost:8080/contenthub/contenthub/store/download/metadata/5d85e7c63cc48c0985?format=application%2Fjson"</pre>
+<pre>curl -i -X GET "http://localhost:8080/contenthub/contenthub/store/download/raw/5d85e7c63cc48c01b8d4"</pre>
 
 <hr>
 
@@ -513,7 +321,7 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/metadata/sha1-5d85e7c63cc48c01</pre>
+<pre>curl -i -X GET "http://localhost:8080/contenthub/contenthub/store/metadata/sha1-5d85e7c63cc48c01"</pre>
 <hr>
 
 
@@ -539,34 +347,7 @@ Tutorials on Stanbol Contenthub can be f
 </tbody>
 </table>
 <h4>Example</h4>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/raw/testuri2343124</pre>
-
-<hr>
-
-
-<h4>Subresource /edit</h4>  
-<table>
-<tbody>
-  <tr>
-    <th>Description</th>
-    <td>Creates the JSON string of a content item (to be edited) to display it in the HTML view</td>
-  </tr>
-  <tr>
-    <th>Request</th>
-    <td>GET /contenthub/{indexName}/store/edit/{uri}</td>
-  </tr>
-  <tr>
-    <th>Parameter</th>
-    <td><b>uri:</b> The URI of the resource in the Stanbol Contenthub store</td>
-  </tr>
-  <tr>
-    <th>Produces</th>
-    <td>200 with an JSON representation of the content item</td>
-  </tr>
-</tbody>
-</table>
-<h4>Example</h4>
-<pre>curl http://localhost:8080/contenthub/contenthub/store/edit/sha1-5d85e7c63cc48c01</pre>
+<pre>curl -i -X GET "http://localhost:8080/contenthub/contenthub/store/raw/testuri2343124"</pre>
 
 <hr>