Author: suat
Date: Fri Jul 20 14:54:37 2012
New Revision: 1363815

URL: http://svn.apache.org/viewvc?rev=1363815&view=rev
Log:
STANBOL-499: REST api documentation for LDPathSemanticIndexManagerResource and 
SemanticIndexManagerResource

Added:
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexLdpathRestApi.ftl
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexRestApi.ftl
Modified:
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/storeRestApi.ftl
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource/index.ftl
    
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java
 Fri Jul 20 14:54:37 2012
@@ -97,7 +97,7 @@ public class LDPathSemanticIndexResource
     }
 
     /**
-     * HTTP POST method which saves an LDPath program into the persistent 
store of Contenthub.
+     * HTTP POST method which saves an {@link LDPathSemanticIndex} into the 
persistent store of Contenthub.
      * 
      * @param name
      *            The name identifying the index

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
 Fri Jul 20 14:54:37 2012
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 
 import javax.servlet.ServletContext;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
 import javax.ws.rs.OPTIONS;
 import javax.ws.rs.Path;
@@ -73,7 +74,7 @@ public class SemanticIndexManagerResourc
 
     /**
      * This method returns the {@link SemanticIndex} representations according 
to the given parameters in
-     * <b>application/json</b> format.
+     * <b>application/json</b> format or HTML view.
      * 
      * @param name
      *            Name of the indexes to be returned
@@ -90,7 +91,7 @@ public class SemanticIndexManagerResourc
     @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
     public Response getIndexes(@QueryParam(value = "name") String name,
                                @QueryParam(value = "endpointType") String 
endpointType,
-                               @QueryParam(value = "multiple") boolean 
multiple,
+                               @QueryParam(value = "multiple") 
@DefaultValue("true") boolean multiple,
                                @Context HttpHeaders headers) throws 
IndexManagementException {
         MediaType acceptedHeader = RestUtil.getAcceptedMediaType(headers);
         if (acceptedHeader.isCompatible(MediaType.TEXT_HTML_TYPE)) {

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
 Fri Jul 20 14:54:37 2012
@@ -636,6 +636,9 @@ public class StoreResource extends BaseS
     @Path("/{uri:.+}")
     public Response deleteContentItem(@PathParam(value = "uri") String 
contentURI,
                                       @Context HttpHeaders headers) throws 
StoreException {
+        if(store.get(new UriRef(contentURI)) == null){
+            throw new WebApplicationException(404);
+        }
         store.remove(new UriRef(contentURI));
         ResponseBuilder rb = Response.ok();
         addCORSOrigin(servletContext, rb, headers);

Added: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexLdpathRestApi.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexLdpathRestApi.ftl?rev=1363815&view=auto
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexLdpathRestApi.ftl
 (added)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexLdpathRestApi.ftl
 Fri Jul 20 14:54:37 2012
@@ -0,0 +1,77 @@
+<br>
+<h3>The RESTful API of the Contenthub Index / LDPath</h3>
+
+<h3>Submit an LDPathSemanticIndex</h3>
+<table>
+<tbody>
+  <tr>
+    <th>Description</th>
+    <td>HTTP POST method which saves an LDPathSemanticIndex into the 
persistent store of Contenthub.</td>
+  </tr>
+  <tr>
+    <th>Request</th>
+    <td>POST /contenthub/index/ldpath</td>
+  </tr>
+  <tr>
+    <th>Parameter</th>
+    <td>
+      <b>name:</b> The name identifying the index<br>
+      <b>description:</b> Description of the index<br>
+      <b>program:</b> LDPath program that will be used as a source to create 
the semantic index. Index fields and Solr specific configurations regarding 
those index fields are given in this parameter.<br>
+      <b>batchsize:</b> Maximum number of changes to be returned<br>
+      <b>storecheckperiod:</b> Time to check changes in the Contenthub Store 
in second units<br>
+      <b>solrchecktime:</b> Maximum time in seconds to wait for the 
availability of the Solr Server<br>
+      <b>ranking:</b> To be able to use other SemanticIndex implementations 
rather than this, Service Ranking property of other implementations should be 
set higher than of this one
+    </td>
+  </tr>
+  <tr>
+    <th>Produces</th>
+    <td>HTTP OK(200) or BAD REQUEST(400)</td>
+  </tr>
+  <tr>
+    <th>Throws</th>
+    <td>
+      IndexManagementException<br>
+      InterruptedException<br>
+      IndexException
+    </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="curlLDPath1" class="curlLine">curl -i -X POST -d 
"name=myindex&description=It indexes person and place entities of a 
content&program=@prefix dbp-ont: &lt;http://dbpedia.org/ontology/&gt;; 
person_entities = .[rdf:type is dbp-ont:Person]:: xsd:anyURI 
(termVectors=\"true\"); place_entities = .[rdf:type is dbp-ont:Place]:: 
xsd:anyURI (termVectors=\"true\");" 
${it.publicBaseUri}contenthub/index/ldpath<hr/></div>curl -i -X POST -d 
"name=myindex&\
+                    description=It indexes person and place entities of a 
content&\
+                    program=@prefix dbp-ont: 
&lt;http://dbpedia.org/ontology/&gt;; \
+                    person_entities = .[rdf:type is dbp-ont:Person]:: 
xsd:anyURI (termVectors="true"); \
+                    place_entities = .[rdf:type is dbp-ont:Place]:: xsd:anyURI 
(termVectors="true");" \
+     ${it.publicBaseUri}contenthub/ldpath/program
+</pre>
+</div>
+
+<hr>
+
+<script>
+  function selectText(element) {
+      var doc = document;
+      var text = doc.getElementById(element);    
+      if (doc.body.createTextRange) { // ms
+          var range = doc.body.createTextRange();
+          range.moveToElementText(text);
+          range.select();
+      } else if (window.getSelection) {
+          var selection = window.getSelection();
+          var range = doc.createRange();
+          range.selectNodeContents(text);
+          selection.removeAllRanges();
+          selection.addRange(range);
+      }
+  }
+
+  function getLine(div){
+      $(div).children('pre').children('.curlLine').toggle();
+      selectText($(div).children('pre').children('.curlLine').attr('id'));
+  }
+</script>
\ No newline at end of file

Added: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexRestApi.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexRestApi.ftl?rev=1363815&view=auto
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexRestApi.ftl
 (added)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/indexRestApi.ftl
 Fri Jul 20 14:54:37 2012
@@ -0,0 +1,44 @@
+<br>
+<h3>The RESTful API of the Contenthub Index</h3>
+
+<h3>Get SemanticIndexes</h3>
+<table>
+<tbody>
+  <tr>
+    <th>Description</th>
+    <td>HTTP GET method to get the SemanticIndex representations according to 
the given parameters in application/json format or HTML view.</td>
+  </tr>
+  <tr>
+    <th>Request</th>
+    <td>GET /contenthub/index</td>
+  </tr>
+  <tr>
+    <th>Parameter</th>
+    <td>
+      <b>name:</b> Name of the indexes to be returned<br>
+      <b>endpointType:</b> String representation of the EndpointType of 
indexes to be returned<br>
+      <b>multiple:</b> If this parameter is set to <code>true</code> it 
returns one or more indexes matching the given conditions, otherwise it returns 
only one index representation it there is any satisfying the conditions.
+    </td>
+  </tr>
+  <tr>
+    <th>Produces</th>
+    <td>returns the SemanticIndex representations according to the given 
parameters in application/json format or HTML view.</td>
+  </tr>
+  <tr>
+    <th>Throws</th>
+    <td>IndexException</td>
+  </tr>
+</tbody>
+</table>
+<h4>Example</h4>
+Get all indexes:
+<pre>
+curl -i -X GET "${it.publicBaseUri}contenthub/index"
+</pre>
+
+Get default index:
+<pre>
+curl -i -X GET "${it.publicBaseUri}contenthub/index?name=contenthub"
+</pre>
+
+<hr>
\ No newline at end of file

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/storeRestApi.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/storeRestApi.ftl?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/storeRestApi.ftl
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/doc/storeRestApi.ftl
 Fri Jul 20 14:54:37 2012
@@ -464,25 +464,24 @@ Tutorials on Stanbol Contenthub can be f
 
 
 <script>
-function selectText(element) {
-    var doc = document;
-    var text = doc.getElementById(element);    
-    if (doc.body.createTextRange) { // ms
-        var range = doc.body.createTextRange();
-        range.moveToElementText(text);
-        range.select();
-    } else if (window.getSelection) {
-        var selection = window.getSelection();
-        var range = doc.createRange();
-        range.selectNodeContents(text);
-        selection.removeAllRanges();
-        selection.addRange(range);
-        
-    }
-}
+  function selectText(element) {
+      var doc = document;
+      var text = doc.getElementById(element);    
+      if (doc.body.createTextRange) { // ms
+          var range = doc.body.createTextRange();
+          range.moveToElementText(text);
+          range.select();
+      } else if (window.getSelection) {
+          var selection = window.getSelection();
+          var range = doc.createRange();
+          range.selectNodeContents(text);
+          selection.removeAllRanges();
+          selection.addRange(range);
+      }
+  }
 
   function getLine(div){
-    $(div).children('pre').children('.curlLine').toggle();
-    selectText($(div).children('pre').children('.curlLine').attr('id'));
+      $(div).children('pre').children('.curlLine').toggle();
+      selectText($(div).children('pre').children('.curlLine').attr('id'));
   }
 </script>
\ No newline at end of file

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource/index.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource/index.ftl?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource/index.ftl
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource/index.ftl
 Fri Jul 20 14:54:37 2012
@@ -16,9 +16,9 @@
 -->
 <#import "/imports/common.ftl" as common>
 <#escape x as x?html>
-<@common.page title="Contenthub" hasrestapi=false>
+<@common.page title="Contenthub" hasrestapi=true>
 <div class="panel" id="webview">
-<a href="${it.publicBaseUri}contenthub/store">Store</a> | <a 
href="${it.publicBaseUri}contenthub/index">Index</a><b>/ldpath</b>
+  <a href="${it.publicBaseUri}contenthub/store">Store</a> | <a 
href="${it.publicBaseUri}contenthub/index">Index</a><b>/ldpath</b>
 
   <h3>Recently Submitted LD Path Semantic Indexes</h3>
   <div id="storeContents" class="storeContents">
@@ -103,7 +103,10 @@
     <p>Stanbol is creating your index...</p>
     <p><img alt="Waiting..." 
src="http://localhost:8080/static/home/images/ajax-loader.gif";></p>
   </div>
-</div>  
+</div>
+<div class="panel" id="restapi" style="display: none;">
+  <#include "/imports/doc/indexLdpathRestApi.ftl">
+</div>
   <script language="javascript">
       function submitProgram() {
           var name = $.trim($("#nameText").val());

Modified: 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl?rev=1363815&r1=1363814&r2=1363815&view=diff
==============================================================================
--- 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl
 (original)
+++ 
incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource/index.ftl
 Fri Jul 20 14:54:37 2012
@@ -16,9 +16,9 @@
 -->
 <#import "/imports/common.ftl" as common>
 <#escape x as x?html>
-<@common.page title="Contenthub" hasrestapi=false>
-<div class="panel" id="webview">
-<a href="${it.publicBaseUri}contenthub/store">Store</a> | <b>Index</b><a 
href="${it.publicBaseUri}contenthub/index/ldpath">/ldpath</a>
+<@common.page title="Contenthub" hasrestapi=true>
+  <div class="panel" id="webview">
+  <a href="${it.publicBaseUri}contenthub/store">Store</a> | <b>Index</b><a 
href="${it.publicBaseUri}contenthub/index/ldpath">/ldpath</a>
     <h3>Submitted Indexes: </h3>
     <#if it.semanticIndexes?size &gt; 0>
       <#list it.semanticIndexes as index>
@@ -64,7 +64,10 @@
     <#else>
       There is no submitted index.
     </#if>
-</div>
+  </div>
+  <div class="panel" id="restapi" style="display: none;">
+    <#include "/imports/doc/indexRestApi.ftl">
+  </div>
   <script>
     $(".index p").click(function () {
       $(this).parents("div").toggleClass("collapsed");


Reply via email to