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/07/19 16:06:33 UTC

svn commit: r1363343 [4/4] - in /incubator/stanbol/branches/contenthub-two-layered-structure/contenthub: ./ bundlelist/src/main/bundles/ index/ index/src/main/java/org/ index/src/main/java/org/apache/ index/src/main/java/org/apache/stanbol/ index/src/m...

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java (from r1352861, 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/LDPathSemanticIndexResource.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/LDPathSemanticIndexResource.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java&r1=1352861&r2=1363343&rev=1363343&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/LDPathSemanticIndexResource.java Thu Jul 19 14:06:30 2012
@@ -20,19 +20,22 @@ import static javax.ws.rs.core.MediaType
 import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
 import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Properties;
 
 import javax.servlet.ServletContext;
 import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
 import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.OPTIONS;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
@@ -43,11 +46,11 @@ import javax.ws.rs.core.Response.Status;
 
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
-import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndexManager;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathException;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathProgram;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathProgramCollection;
-import org.apache.stanbol.contenthub.web.util.RestUtil;
+import org.apache.stanbol.contenthub.index.ldpath.LDPathSemanticIndex;
+import org.apache.stanbol.contenthub.index.ldpath.LDPathSemanticIndexManager;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexException;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexManagementException;
+import org.osgi.framework.Constants;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -61,18 +64,19 @@ import com.sun.jersey.api.view.Viewable;
  * @author anil.sinaci
  * 
  */
-@Path("/contenthub/ldpath")
-public class SemanticIndexManagerResource extends BaseStanbolResource {
+@Path("/contenthub/index/ldpath")
+public class LDPathSemanticIndexResource extends BaseStanbolResource {
 
-    private static final Logger logger = LoggerFactory.getLogger(SemanticIndexManagerResource.class);
+    private static final Logger logger = LoggerFactory.getLogger(LDPathSemanticIndexResource.class);
 
-    private SemanticIndexManager programManager;
+    private LDPathSemanticIndexManager programManager;
 
-    public SemanticIndexManagerResource(@Context ServletContext context) {
-        programManager = ContextHelper.getServiceFromContext(SemanticIndexManager.class, context);
+    public LDPathSemanticIndexResource(@Context ServletContext context) {
+        programManager = ContextHelper.getServiceFromContext(LDPathSemanticIndexManager.class, context);
         if (programManager == null) {
-            logger.error("Missing LDProgramManager = {}", programManager);
-            throw new WebApplicationException(404);
+            logger.error("Missing LDPathSemanticIndexManager");
+            throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR)
+                    .entity("Missing LDPathSemanticIndexManager\n").build());
         }
     }
 
@@ -83,142 +87,90 @@ public class SemanticIndexManagerResourc
         return res.build();
     }
 
-    @OPTIONS
-    @Path("/program")
-    public Response handleCorsPreflightProgram(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
-        return res.build();
-    }
-
-    @OPTIONS
-    @Path("/exists")
-    public Response handleCorsPreflightExists(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
-        return res.build();
-    }
-
     /**
-     * HTTP GET method which returns all LDPath programs residing in Contenthub. LDPath programs are uniquely
-     * identified by their names. Returning JSON string presents each LDPath program in string format aligned
-     * with its name.
-     * 
-     * @param headers
-     *            HTTP headers
-     * @return JSON string of {@code name:program} pairs.
+     * Services to draw HTML view
      */
     @GET
-    @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
-    public Response retrieveAllPrograms(@Context HttpHeaders headers) {
-        MediaType acceptedHeader = RestUtil.getAcceptedMediaType(headers);
-        if (acceptedHeader.isCompatible(MediaType.TEXT_HTML_TYPE)) {
-        	return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
-        } else{
-	        LDPathProgramCollection ldProgramCollection = programManager.retrieveAllPrograms();
-	        ResponseBuilder rb = Response.ok(ldProgramCollection, MediaType.APPLICATION_JSON);
-	        addCORSOrigin(servletContext, rb, headers);
-	        return rb.build();
-        }
+    @Produces(MediaType.TEXT_HTML)
+    public Response retrieveAllPrograms() {
+        return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
     }
 
     /**
      * HTTP POST method which saves an LDPath program into the persistent store of Contenthub.
      * 
-     * @param programName
-     *            Unique name to identify the LDPath program
+     * @param name
+     *            The name identifying the index
+     * @param description
+     *            Description of the index
      * @param program
-     *            The LDPath program.
+     *            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.
+     * @param batchsize
+     *            Maximum number of changes to be returned
+     * @param storecheckperiod
+     *            Time to check changes in the Contenthub Store in second units
+     * @param solrchecktime
+     *            Maximum time in seconds to wait for the availability of the Solr Server
+     * @param ranking
+     *            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
      * @param headers
      *            HTTP Headers
      * @return HTTP OK(200) or BAD REQUEST(400)
-     * @throws LDPathException
+     * @throws IndexManagementException
+     * @throws InterruptedException
+     * @throws IndexException
      */
     @POST
-    @Path("/program")
     @Consumes(APPLICATION_FORM_URLENCODED)
-    public Response submitProgram(@FormParam("name") String programName,
+    public Response submitProgram(@FormParam("name") String name,
+                                  @FormParam("description") String description,
                                   @FormParam("program") String program,
-                                  @Context HttpHeaders headers) throws LDPathException {
-
-        try {
-            programManager.submitProgram(programName, program);
-        } catch (LDPathException e) {
-            logger.error("LDPath program cannot be submitted", e);
-            return Response.status(Status.BAD_REQUEST).entity(e).build();
-        }
+                                  @FormParam("indexContent") boolean indexContent,
+                                  @FormParam("batchsize") @DefaultValue("10") int batchsize,
+                                  @FormParam("storecheckperiod") @DefaultValue("10") int storecheckperiod,
+                                  @FormParam("solrchecktime") @DefaultValue("5") int solrchecktime,
+                                  @FormParam("ranking") @DefaultValue("0") int ranking,
+                                  @Context ServletContext context,
+                                  @Context HttpHeaders headers) throws IndexManagementException,
+                                                               InterruptedException,
+                                                               IndexException {
+
+        Properties parameters = new Properties();
+        parameters.put(LDPathSemanticIndex.PROP_NAME, name);
+        parameters.put(LDPathSemanticIndex.PROP_DESCRIPTION, description);
+        parameters.put(LDPathSemanticIndex.PROP_LD_PATH_PROGRAM, program);
+        parameters.put(LDPathSemanticIndex.PROP_INDEX_CONTENT, indexContent);
+        parameters.put(LDPathSemanticIndex.PROP_BATCH_SIZE, batchsize);
+        parameters.put(LDPathSemanticIndex.PROP_STORE_CHECK_PERIOD, storecheckperiod);
+        parameters.put(LDPathSemanticIndex.PROP_SOLR_CHECK_TIME, solrchecktime);
+        parameters.put(Constants.SERVICE_RANKING, ranking);
+        programManager.createIndex(parameters);
         ResponseBuilder rb = Response
                 .ok("LDPath program has been successfully saved and corresponding Solr Core has been successfully created.");
         addCORSOrigin(servletContext, rb, headers);
         return rb.build();
     }
 
-    /**
-     * HTTP GET method to retrieve an LDPath program, given its name.
-     * 
-     * @param programName
-     *            The name of the LDPath program to be retrieved.
-     * @param headers
-     *            HTTP headers
-     * @return LDPath program in {@link String} format or HTTP NOT FOUND(404)
-     */
-    @GET
-    @Path("/program")
-    public Response getProgramByName(@QueryParam("name") String programName, @Context HttpHeaders headers) {
-        String ldPathProgram = programManager.getProgramByName(programName);
-        if (ldPathProgram == null) {
-            return Response.status(Status.NOT_FOUND).build();
-        } else {
-            ResponseBuilder rb = Response.ok(ldPathProgram);
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
-        }
-    }
-
-    /**
-     * HTTP DELETE method to delete an LDPath program.
-     * 
-     * @param programName
-     *            The name of the LDPath program.
-     * @param headers
-     *            HTTP headers
-     * @return HTTP OK(200)
-     */
-    @DELETE
-    @Path("/program/{name}")
-    public Response deleteProgram(@PathParam(value = "name") String programName, @Context HttpHeaders headers) {
-        programManager.deleteProgram(programName);
-        ResponseBuilder rb = Response.ok();
-        addCORSOrigin(servletContext, rb, headers);
-        return rb.build();
-    }
-
-    /**
-     * HTTP GET method to check whether an LDPath program exists in Contenthub or not.
-     * 
-     * @param programName
-     *            The name of the LDPath program.
-     * @param headers
-     *            HTTP headers
-     * @return HTTP OK(200) or HTTP NOT FOUND(404)
-     */
-    @GET
-    @Path("/exists")
-    public Response isManagedProgram(@QueryParam("name") String programName, @Context HttpHeaders headers) {
-        if (programManager.isManagedProgram(programName)) {
-            ResponseBuilder rb = Response.ok();
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
-        } else {
-            ResponseBuilder rb = Response.status(Status.NOT_FOUND);
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
-        }
-    }
-
     // Helper methods for HTML view
-    public List<LDPathProgram> getLdPrograms() {
-        return programManager.retrieveAllPrograms().asList();
+    public Map<String,List<String>> getLdPrograms() {
+        Map<String,Properties> allIndexMetadata = programManager.getAllIndexMetadata();
+        Map<String,List<String>> indexMetadataMap = new HashMap<String,List<String>>();
+        for (Entry<String,Properties> indexMetadata : allIndexMetadata.entrySet()) {
+            List<String> indexMetadataMapValues = new ArrayList<String>();
+            Properties properties = indexMetadata.getValue();
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_NAME).toString());
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_DESCRIPTION).toString());
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_INDEX_CONTENT).toString());
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_BATCH_SIZE).toString());
+            indexMetadataMapValues
+                    .add(properties.get(LDPathSemanticIndex.PROP_STORE_CHECK_PERIOD).toString());
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_SOLR_CHECK_TIME).toString());
+            indexMetadataMapValues.add(properties.get(LDPathSemanticIndex.PROP_LD_PATH_PROGRAM).toString());
+            indexMetadataMap.put(indexMetadata.getKey(), indexMetadataMapValues);
+        }
+        return indexMetadataMap;
     }
 
 }

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=1363343&r1=1363342&r2=1363343&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 Thu Jul 19 14:06:30 2012
@@ -1,79 +1,51 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 package org.apache.stanbol.contenthub.web.resources;
 
-import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
 import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
 import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.servlet.ServletContext;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.FormParam;
 import javax.ws.rs.GET;
 import javax.ws.rs.OPTIONS;
-import javax.ws.rs.POST;
 import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.ResponseBuilder;
-import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
 
 import org.apache.stanbol.commons.web.base.ContextHelper;
 import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+import org.apache.stanbol.contenthub.servicesapi.index.EndpointType;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexException;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexManagementException;
+import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndex;
 import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndexManager;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathException;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathProgram;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathProgramCollection;
+import org.apache.stanbol.contenthub.web.util.JSONUtils;
 import org.apache.stanbol.contenthub.web.util.RestUtil;
+import org.codehaus.jettison.json.JSONException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.sun.jersey.api.view.Viewable;
 
-/**
- * This class the the web resource to handle the RESTful requests and HTML view of the LDProgram management
- * facilities within Contenthub.
- * 
- * @author anil.pacaci
- * @author anil.sinaci
- * 
- */
-@Path("/contenthub/ldpath")
+@Path("/contenthub/index")
 public class SemanticIndexManagerResource extends BaseStanbolResource {
 
-    private static final Logger logger = LoggerFactory.getLogger(SemanticIndexManagerResource.class);
+    private final Logger logger = LoggerFactory.getLogger(SemanticIndexManagerResource.class);
 
-    private SemanticIndexManager programManager;
+    private SemanticIndexManager semanticIndexManager;
 
-    public SemanticIndexManagerResource(@Context ServletContext context) {
-        programManager = ContextHelper.getServiceFromContext(SemanticIndexManager.class, context);
-        if (programManager == null) {
-            logger.error("Missing LDProgramManager = {}", programManager);
-            throw new WebApplicationException(404);
-        }
+    public SemanticIndexManagerResource(@Context ServletContext context, @Context UriInfo uriInfo) {
+        this.semanticIndexManager = ContextHelper.getServiceFromContext(SemanticIndexManager.class, context);
     }
 
     @OPTIONS
@@ -83,142 +55,110 @@ public class SemanticIndexManagerResourc
         return res.build();
     }
 
-    @OPTIONS
-    @Path("/program")
-    public Response handleCorsPreflightProgram(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
-        return res.build();
-    }
-
-    @OPTIONS
-    @Path("/exists")
-    public Response handleCorsPreflightExists(@Context HttpHeaders headers) {
-        ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
-        return res.build();
-    }
-
     /**
-     * HTTP GET method which returns all LDPath programs residing in Contenthub. LDPath programs are uniquely
-     * identified by their names. Returning JSON string presents each LDPath program in string format aligned
-     * with its name.
+     * This method returns the {@link SemanticIndex} representations according to the given parameters in
+     * <b>application/json</b> format.
      * 
-     * @param headers
-     *            HTTP headers
-     * @return JSON string of {@code name:program} pairs.
+     * @param name
+     *            Name of the indexes to be returned
+     * @param endpointType
+     *            String representation of the {@link EndpointType} of indexes to be returned
+     * @param multiple
+     *            If this parameter is set to {@code true} it returns one or more indexes matching the given
+     *            conditions, otherwise it returns only one index representation it there is any satisfying
+     *            the conditions.
+     * @return
+     * @throws IndexException
      */
     @GET
     @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON})
-    public Response retrieveAllPrograms(@Context HttpHeaders headers) {
+    public Response getIndexes(@QueryParam(value = "name") String name,
+                               @QueryParam(value = "endpointType") String endpointType,
+                               @QueryParam(value = "multiple") boolean multiple,
+                               @Context HttpHeaders headers) throws IndexManagementException {
         MediaType acceptedHeader = RestUtil.getAcceptedMediaType(headers);
         if (acceptedHeader.isCompatible(MediaType.TEXT_HTML_TYPE)) {
-        	return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
-        } else{
-	        LDPathProgramCollection ldProgramCollection = programManager.retrieveAllPrograms();
-	        ResponseBuilder rb = Response.ok(ldProgramCollection, MediaType.APPLICATION_JSON);
-	        addCORSOrigin(servletContext, rb, headers);
-	        return rb.build();
-        }
-    }
-
-    /**
-     * HTTP POST method which saves an LDPath program into the persistent store of Contenthub.
-     * 
-     * @param programName
-     *            Unique name to identify the LDPath program
-     * @param program
-     *            The LDPath program.
-     * @param headers
-     *            HTTP Headers
-     * @return HTTP OK(200) or BAD REQUEST(400)
-     * @throws LDPathException
-     */
-    @POST
-    @Path("/program")
-    @Consumes(APPLICATION_FORM_URLENCODED)
-    public Response submitProgram(@FormParam("name") String programName,
-                                  @FormParam("program") String program,
-                                  @Context HttpHeaders headers) throws LDPathException {
-
-        try {
-            programManager.submitProgram(programName, program);
-        } catch (LDPathException e) {
-            logger.error("LDPath program cannot be submitted", e);
-            return Response.status(Status.BAD_REQUEST).entity(e).build();
-        }
-        ResponseBuilder rb = Response
-                .ok("LDPath program has been successfully saved and corresponding Solr Core has been successfully created.");
-        addCORSOrigin(servletContext, rb, headers);
-        return rb.build();
-    }
-
-    /**
-     * HTTP GET method to retrieve an LDPath program, given its name.
-     * 
-     * @param programName
-     *            The name of the LDPath program to be retrieved.
-     * @param headers
-     *            HTTP headers
-     * @return LDPath program in {@link String} format or HTTP NOT FOUND(404)
-     */
-    @GET
-    @Path("/program")
-    public Response getProgramByName(@QueryParam("name") String programName, @Context HttpHeaders headers) {
-        String ldPathProgram = programManager.getProgramByName(programName);
-        if (ldPathProgram == null) {
-            return Response.status(Status.NOT_FOUND).build();
+            return Response.ok(new Viewable("index", this), MediaType.TEXT_HTML).build();
         } else {
-            ResponseBuilder rb = Response.ok(ldPathProgram);
+            // if (name == null && endpointType == null) {
+            // throw new IllegalArgumentException("At least an index name or an endpoint type must be given");
+            // }
+            EndpointType epType = null;
+            if (endpointType != null) {
+                epType = EndpointType.valueOf(endpointType);
+            }
+            List<SemanticIndex> semanticIndexes = new ArrayList<SemanticIndex>();
+            if (multiple) {
+                semanticIndexes = semanticIndexManager.getIndexes(name, epType);
+            } else {
+                SemanticIndex semanticIndex = semanticIndexManager.getIndex(name, epType);
+                semanticIndexes.add(semanticIndex);
+            }
+            ResponseBuilder rb = null;
+            try {
+                rb = Response.ok(JSONUtils.createJSONString(semanticIndexes), MediaType.APPLICATION_JSON);
+            } catch (IndexException e) {
+                logger.error("Failed to get field names and field properties from index");
+                throw new IndexManagementException(
+                        "Failed to get field names and field properties from index");
+            } catch (JSONException e) {
+                logger.error("Index properties cannot be put to JSON Object");
+                throw new IndexManagementException("Index properties cannot be put to JSON Object");
+            }
             addCORSOrigin(servletContext, rb, headers);
             return rb.build();
         }
     }
 
-    /**
-     * HTTP DELETE method to delete an LDPath program.
-     * 
-     * @param programName
-     *            The name of the LDPath program.
-     * @param headers
-     *            HTTP headers
-     * @return HTTP OK(200)
-     */
-    @DELETE
-    @Path("/program/{name}")
-    public Response deleteProgram(@PathParam(value = "name") String programName, @Context HttpHeaders headers) {
-        programManager.deleteProgram(programName);
-        ResponseBuilder rb = Response.ok();
-        addCORSOrigin(servletContext, rb, headers);
-        return rb.build();
-    }
-
-    /**
-     * HTTP GET method to check whether an LDPath program exists in Contenthub or not.
-     * 
-     * @param programName
-     *            The name of the LDPath program.
-     * @param headers
-     *            HTTP headers
-     * @return HTTP OK(200) or HTTP NOT FOUND(404)
-     */
-    @GET
-    @Path("/exists")
-    public Response isManagedProgram(@QueryParam("name") String programName, @Context HttpHeaders headers) {
-        if (programManager.isManagedProgram(programName)) {
-            ResponseBuilder rb = Response.ok();
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
-        } else {
-            ResponseBuilder rb = Response.status(Status.NOT_FOUND);
-            addCORSOrigin(servletContext, rb, headers);
-            return rb.build();
+    //
+    // HTML view
+    //
+    
+    public class IndexView {
+        private String name;
+        private String description;
+        private String state;
+        private long revision;
+        private Map<String,String> endpoints;
+        
+        public IndexView(String name,String description, String state,long revision, Map<String,String> endpoints){
+            this.name = name;
+            this.description = description;
+            this.state = state;
+            this.revision = revision;
+            this.endpoints = endpoints;
+        }
+        
+        public String getName(){
+            return name;
+        }
+        public String getDescription(){
+            return description;
+        }
+        public String getState(){
+            return state;
+        }
+        public long getRevision(){
+            return revision;
+        }
+        public Map<String,String> getEndpoints(){
+            return endpoints;
         }
     }
-
-    // Helper methods for HTML view
-    public List<LDPathProgram> getLdPrograms() {
-        return programManager.retrieveAllPrograms().asList();
+    
+    public List<IndexView> getSemanticIndexes() throws IndexManagementException {
+        List<IndexView> indexView = new ArrayList<IndexView>();
+        List<SemanticIndex> indexes = semanticIndexManager.getIndexes(null, null);
+        for(SemanticIndex index : indexes){
+            Map<EndpointType,String> restEndpoints = index.getRESTSearchEndpoints();
+            Map<String,String> endpoints = new HashMap<String,String>();
+            for(Entry<EndpointType,String> restEndpoint : restEndpoints.entrySet()){
+                endpoints.put(restEndpoint.getKey().name(), restEndpoint.getValue());
+            }
+            indexView.add(new IndexView(index.getName(), index.getDescription(), index.getState().name(), index.getRevision(),endpoints));
+        }
+        return indexView;
     }
+    
 
 }

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=1363343&r1=1363342&r2=1363343&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 Thu Jul 19 14:06:30 2012
@@ -17,6 +17,9 @@
 
 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.HttpMethod.POST;
 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;
@@ -236,7 +239,7 @@ public class StoreResource extends BaseS
     @Path("/{uri:.+}")
     public Response handleCorsPreflightURI(@Context HttpHeaders headers) {
         ResponseBuilder res = Response.ok();
-        enableCORS(servletContext, res, headers);
+        enableCORS(servletContext, res, headers, POST, DELETE, OPTIONS);
         return res.build();
     }
 
@@ -582,7 +585,8 @@ public class StoreResource extends BaseS
 
         ContentItem ci = null;
         try {
-            ci = cif.createContentItem(contentURI, new ByteArraySource(content, mediaType.toString()));
+            ci = cif.createContentItem(new UriRef(contentURI),
+                new ByteArraySource(content, mediaType.toString()));
             if (constraints != null && !constraints.trim().equals("")) {
                 ci.addPart(FileStore.CONSTRAINTS_URI, cif.createBlob(new StringSource(constraints)));
             }

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java?rev=1363343&r1=1363342&r2=1363343&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java Thu Jul 19 14:06:30 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,14 +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.index.ldpath.LDPathProgramCollection;
-import org.apache.stanbol.contenthub.servicesapi.index.search.featured.DocumentResult;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexException;
+import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndex;
 import org.apache.stanbol.contenthub.servicesapi.index.search.featured.SearchResult;
 import org.apache.stanbol.contenthub.servicesapi.index.search.related.RelatedKeyword;
-import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
@@ -114,14 +110,10 @@ public class JSONUtils {
         return jObject.toString();
     }
 
-    private static JSONObject toJSON(DocumentResult resultantDocument) throws JSONException {
+    private static JSONObject toJSON(String resultantDocument) throws JSONException {
         JSONObject jObj = new JSONObject();
         if (resultantDocument != null) {
-            jObj.put("uri", resultantDocument.getDereferencableURI());
-            jObj.put("localid", resultantDocument.getLocalId());
-            jObj.put("mimetype", resultantDocument.getMimetype());
-            jObj.put("title", resultantDocument.getTitle());
-            jObj.put("enhancementcount", resultantDocument.getEnhancementCount());
+            jObj.put("uri", resultantDocument);
         }
         return jObj;
     }
@@ -130,14 +122,14 @@ public class JSONUtils {
         JSONArray jArr = new JSONArray();
         if (list != null) {
             for (T element : list) {
-                if (DocumentResult.class.isAssignableFrom(element.getClass())) {
-                    jArr.put(toJSON((DocumentResult) element));
-                } else if (FacetField.class.isAssignableFrom(element.getClass())) {
+                if (FacetField.class.isAssignableFrom(element.getClass())) {
                     jArr.put(toJSON((FacetField) element));
                 } else if (FacetField.Count.class.isAssignableFrom(element.getClass())) {
                     jArr.put(toJSON((FacetField.Count) element));
                 } else if (RelatedKeyword.class.isAssignableFrom(element.getClass())) {
                     jArr.put(toJSON((RelatedKeyword) element));
+                } else if (String.class.isAssignableFrom(element.getClass())) {
+                    jArr.put(toJSON((String) element));
                 }
             }
         }
@@ -200,28 +192,26 @@ 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(LDPathProgramCollection ldpc) throws JSONException {
+    public static String createJSONString(List<SemanticIndex> semanticIndexes) throws JSONException,
+                                                                              IndexException {
         JSONObject jObj = new JSONObject();
-        for (Map.Entry<String,String> entry : ldpc.asMap().entrySet()) {
-            jObj.put(entry.getKey(), entry.getValue());
+        for (SemanticIndex semanticIndex : semanticIndexes) {
+            JSONObject siRep = new JSONObject();
+            siRep.put("name", semanticIndex.getName());
+            siRep.put("description", semanticIndex.getDescription());
+            siRep.put("revision", semanticIndex.getRevision());
+            siRep.put("fieldNames", semanticIndex.getFieldsNames());
+
+            JSONObject fieldProperties = new JSONObject();
+            for (String fieldName : semanticIndex.getFieldsNames()) {
+                Map<String,Object> singleFieldProperties = semanticIndex.getFieldProperties(fieldName);
+                fieldProperties.put(fieldName, singleFieldProperties);
+            }
+            siRep.put("fieldProperties", fieldProperties);
+            siRep.put("restEndpoints", semanticIndex.getRESTSearchEndpoints());
+
+            jObj.put(semanticIndex.getName(), siRep);
         }
         return jObj.toString(4);
     }
-
 }

Copied: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/SemanticIndexWriter.java (from r1352861, incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/LDProgramCollectionWriter.java)
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/SemanticIndexWriter.java?p2=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/SemanticIndexWriter.java&p1=incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/LDProgramCollectionWriter.java&r1=1352861&r2=1363343&rev=1363343&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/LDProgramCollectionWriter.java (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/writers/SemanticIndexWriter.java Thu Jul 19 14:06:30 2012
@@ -21,7 +21,9 @@ import static javax.ws.rs.core.MediaType
 import java.io.IOException;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.util.List;
 
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
@@ -32,28 +34,39 @@ import javax.ws.rs.ext.Provider;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.stanbol.contenthub.servicesapi.Constants;
-import org.apache.stanbol.contenthub.servicesapi.index.ldpath.LDPathProgramCollection;
+import org.apache.stanbol.contenthub.servicesapi.index.IndexException;
+import org.apache.stanbol.contenthub.servicesapi.index.SemanticIndex;
 import org.apache.stanbol.contenthub.web.util.JSONUtils;
 import org.apache.stanbol.contenthub.web.util.RestUtil;
 import org.codehaus.jettison.json.JSONException;
 
 /**
  * 
- * @author anil.sinaci
+ * @author suat
  * 
  */
 @Provider
-public class LDProgramCollectionWriter implements MessageBodyWriter<LDPathProgramCollection> {
+public class SemanticIndexWriter implements MessageBodyWriter<List<SemanticIndex>> {
 
     @Override
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        boolean isWritable = false;
         String mediaTypeString = mediaType.getType() + '/' + mediaType.getSubtype();
-        return LDPathProgramCollection.class.isAssignableFrom(type)
-               && RestUtil.supportedMediaTypes.contains(mediaTypeString);
+
+        if (List.class.isAssignableFrom(type) && genericType instanceof ParameterizedType
+            && RestUtil.supportedMediaTypes.contains(mediaTypeString)) {
+
+            ParameterizedType parameterizedType = (ParameterizedType) genericType;
+            Type[] actualTypeArgs = (parameterizedType.getActualTypeArguments());
+
+            Class<?> actualType = (Class<?>) actualTypeArgs[0];
+            isWritable = (actualTypeArgs.length == 1 && SemanticIndex.class.isAssignableFrom(actualType));
+        }
+        return isWritable;
     }
 
     @Override
-    public long getSize(LDPathProgramCollection t,
+    public long getSize(List<SemanticIndex> t,
                         Class<?> type,
                         Type genericType,
                         Annotation[] annotations,
@@ -62,7 +75,7 @@ public class LDProgramCollectionWriter i
     }
 
     @Override
-    public void writeTo(LDPathProgramCollection t,
+    public void writeTo(List<SemanticIndex> t,
                         Class<?> type,
                         Type genericType,
                         Annotation[] annotations,
@@ -80,6 +93,8 @@ public class LDProgramCollectionWriter i
                 IOUtils.write(jsonstr, entityStream, encoding);
             } catch (JSONException e) {
                 throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
+            } catch (IndexException e) {
+                throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
             }
         }
     }

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_folded.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_folded.png?rev=1363343&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_folded.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_unfolded.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_unfolded.png?rev=1363343&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/images/foldable_unfolded.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/style/contenthub.css
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/style/contenthub.css?rev=1363343&r1=1363342&r2=1363343&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/style/contenthub.css (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/static/style/contenthub.css Thu Jul 19 14:06:30 2012
@@ -98,4 +98,41 @@ H3.ui-accordion-header{
 
 .curlLine{
   display: none;
+}
+
+.index {
+  padding: 0.5em;
+  border: 1px solid #eee;
+  border-radius: 8px;
+}
+
+.index .collapseheader {
+  margin: 0.1em;
+  cursor: pointer;
+  background: url("../images/foldable_unfolded.png") no-repeat scroll right center transparent;
+}
+
+.index .collapsed .collapseheader {
+  background: url("../images/foldable_folded.png") no-repeat scroll right center transparent;
+}
+
+.index .collapsed .collapsable {
+  display: none;
+}
+
+.index ul {
+  padding-left: 0;
+}
+
+.index ul li {
+  list-style: none;
+  padding-left: 20px; 
+}
+
+.waitingDiv{
+  position: fixed; 
+  top: 42%; 
+  left: 42%; 
+  text-align: center;
+  display: none;
 }
\ 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/facetResultMacro.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/facetResultMacro.ftl?rev=1363343&r1=1363342&r2=1363343&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl Thu Jul 19 14:06:30 2012
@@ -24,14 +24,14 @@
   <#if facetField?exists>
     <#if facetField.values?exists && facetField.values?size != 0>
       <#assign facetNameEscaped = facetField.name?url("UTF-8")?js_string/>
-      <#if facetField.name == "stanbolreserved_creationdate">
+      <#if facetField.name == "contenthubreserved_creationdate">
         ${facetHtmlName}
         <br/>
         <#assign orderedList = facetField.values?sort_by("name") />
         <p>
           <input id="dateFrom" class="facetText" type="text" value="${orderedList[0].name?substring(0,10)}" readonly="true"/> 
           to <input id="dateTo" class="facetText" type="text" value="${orderedList[orderedList?size-1].name?substring(0,10)}" readonly="true"/>
-          <a href="javascript:getResults('stanbolreserved_creationdate','','date')"><input type="button" value=">" /></a>
+          <a href="javascript:getResults('contenthubreserved_creationdate','','date')"><input type="button" value=">" /></a>
         </p>
       <#else>
         ${facetHtmlName}

Modified: incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/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/storeRestApi.ftl?rev=1363343&r1=1363342&r2=1363343&view=diff
==============================================================================
--- incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/storeRestApi.ftl (original)
+++ incubator/stanbol/branches/contenthub-two-layered-structure/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/storeRestApi.ftl Thu Jul 19 14:06:30 2012
@@ -375,7 +375,7 @@ Tutorials on Stanbol Contenthub can be f
 </table>
 <h4>Example</h4>
 <pre>curl http://localhost:8080/contenthub/store/download/metadata/5d85e7c63cc48c0985?format=application%2Fjson</pre>
-<pre>curl http://localhost:8080/contenthub/store/download/raw/5d85e7c63cc48c01b8d4?format=application%2Frdf%2Bxml</pre>
+<pre>curl http://localhost:8080/contenthub/store/download/raw/5d85e7c63cc48c01b8d4</pre>
 
 <hr>
 

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/FeaturedSearchResource/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/FeaturedSearchResource/index.ftl?rev=1363343&r1=1363342&r2=1363343&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/FeaturedSearchResource/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/FeaturedSearchResource/index.ftl Thu Jul 19 14:06:30 2012
@@ -22,6 +22,7 @@
     <fieldset>
       <legend>Keyword Based Search</legend>
       
+      <!-- Index selection combobox-->
       <p>
         Select an index: <div id="indexDiv"><#--this div will be populated by ajax--></div>
       </p>
@@ -64,7 +65,6 @@
   <script language="javascript">
   
       function init() {
-        
           //accordion
           $(".keywords").accordion({collapsible: true});
           //if a GET gets a parameters, then does the search with that parameter
@@ -74,12 +74,16 @@
               getResults(null,null,'first');
           }
           
-          $.get("${it.publicBaseUri}contenthub/ldpath", function(indexes) {
-              innerStr = "<select id='indexSelect' onChange='javascript:redirectIndex();'>" + "<option value='contenthub'>contenthub</option>"
-              for(var index in indexes) {
-                  innerStr += "<option value=" + index + ">" + index + "</option>";
+          $.get("${it.publicBaseUri}contenthub/index?multiple=true", function(indexes) {
+              if(jQuery.isEmptyObject(indexes)){
+                  innerStr = "You should submit an index to search";
+              } else {
+                  innerStr = "<select id='indexSelect' onChange='javascript:redirectIndex();'>";
+                  for(var index in indexes) {
+                      innerStr += "<option value=" + index + ">" + index + "</option>";
+                  }
+                  innerStr += "</select>";
               }
-              innerStr += "</select>";
               $("#indexDiv").html(innerStr);
               $("#indexSelect").val("${it.indexName}");
           });
@@ -87,34 +91,26 @@
     
       $(document).ready(init);
    
-      function hideDiv() {
-          $('#facets').hide("slow");
-      }
-      
-      function showDiv() {
-          $('#facets').show("slow");
-      }
-    
       function redirectIndex() {
           var index = $("#indexSelect").val();
           window.location.replace("${it.publicBaseUri}contenthub/" + index + "/search/featured");
       }
-    
-      function completePattern() {
-          var pattern = $("#keywordIn").val();
-          $.get("${it.publicBaseUri}contenthub/${it.indexName}/search/related/autocomplete?pattern="+pattern, function(data) {
-              var jsonSource = JSON.parse(data);
-              $(".autoCompleteText").autocomplete({
-                  source: jsonSource['completedKeywords']
-              });         
-          });
-      }
-
+      
       function getResults(facetName,facetValue,operation,voffset,vpageSize) {
         
+          $("#keywordIn").val($.trim($("#keywordIn").val()));  
           //clears the content of div because it'll be filled by explorer posts
           var keywordToSearch = $("#keywordIn").val();
           
+          if(keywordToSearch == null || $.trim(keywordToSearch).length == 0) {
+              alert("You should enter keyword(s) for search");
+              return;
+          }
+          
+          if($("#keywordIn").val() == "*" || $("#keywordIn").val() == "?"){
+              $("#keywordIn").val("*:*");
+          }
+          
           jsonCons = $("#chosenFacetsHidden").attr("value");
           if(typeof(jsonCons) == "undefined") {
               jsonCons = "{}";
@@ -266,6 +262,28 @@
           });
       }
       
+      function hideDiv() {
+          $('#facets').hide("slow");
+      }
+      
+      function showDiv() {
+          $('#facets').show("slow");
+      }
+    
+
+    
+      function completePattern() {
+          var pattern = $("#keywordIn").val();
+          $.get("${it.publicBaseUri}contenthub/${it.indexName}/search/related/autocomplete?pattern="+pattern, function(data) {
+              var jsonSource = JSON.parse(data);
+              $(".autoCompleteText").autocomplete({
+                  source: jsonSource['completedKeywords']
+              });         
+          });
+      }
+
+
+      
       function setChosenFacet(JSONObject) {
           var resultString = "";
           var chosenCons = $("#chosenFacetsHidden").attr("value");
@@ -299,7 +317,7 @@
       }
         
       function isReserved(str) {
-          return str.indexOf("stanbolreserved_") == 0; 
+          return str.indexOf("contenthubreserved_") == 0; 
       }
     
       function getHtmlName(name) {
@@ -315,7 +333,6 @@
           }
           return name;
       }
-      
   </script>
 </...@common.page>
 </#escape>

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/FeaturedSearchResource/result.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/FeaturedSearchResource/result.ftl?rev=1363343&r1=1363342&r2=1363343&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/FeaturedSearchResource/result.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/FeaturedSearchResource/result.ftl Thu Jul 19 14:06:30 2012
@@ -76,9 +76,9 @@
           <#if it.searchResults.documents?size == 0>
           Your search did not match any documents
           <#else>
-            <#list it.documents as docRes>
+            <#list it.documents as docUri>
               <div class="bordered-bottom">
-                <li class="lined"><a href="${it.publicBaseUri}contenthub/${it.indexName}/store/page/${docRes.localId}">${docRes.title}</a></li>
+                <li class="lined"><a href="${it.publicBaseUri}contenthub/store/page/${docUri}">${docUri}</a></li>
               </div>  
             </#list>
           </#if>

Added: 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=1363343&view=auto
==============================================================================
--- 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 (added)
+++ 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 Thu Jul 19 14:06:30 2012
@@ -0,0 +1,149 @@
+<#--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<#import "/imports/common.ftl" as common>
+<#escape x as x?html>
+<@common.page title="Contenthub" hasrestapi=false>
+<div class="panel" id="webview">
+<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">
+    <div id="submittedPrograms">
+      <table>
+        <tr>
+          <th>Name</th>
+          <th>Description</th>
+          <th>Index Content</th>
+          <th>Batch Size</th>
+          <th>Store Check Period</th>
+          <th>Solr Check Time</th>
+          <th>Program</th>
+        </tr>
+        <#list it.ldPrograms?keys as pid>
+          <#assign properties = it.ldPrograms[pid]>
+          <tr>
+            <#list properties as property>
+              <td>${property}</td>
+            </#list>
+          </tr>
+        </#list>
+      </table>
+    </div>
+  </div>
+
+  <br/>
+  <h3>Submit a new LD Path Semantic Index</h3>
+  <fieldset>
+    <legend>Give required information about LD Path Semantic Index</legend>
+    <p>
+      <b>Name<font color="red">*</font>: </b>
+      <font size=1>(The name identifying the index)</font>
+    </p>
+    <p><input type="text" id="nameText" /></p>
+    
+    <p>
+      <b>Description: </b>
+      <font size=1>(Description of the index)</font>
+    </p>
+    <p><input type="text" id="descriptionText" /></p>
+
+    <p>
+      <b>Index Content: </b>
+      <font size=1>(Set to TRUE to enable indexing content)</font>
+    </p>
+    <p><input type="checkbox" id="indexContentCheckBox" checked="true" /> Index Content</p>
+        
+    <p>
+      <b>Batch Size: </b>
+      <font size=1>(Maximum number of changes to be returned)</font>
+    </p>
+    <p><input type="text" id="batchsizeText" value="10" /></p>
+    
+    <p>
+      <b>Store Check Period: </b>
+      <font size=1>(Time to check changes in the Contenthub  Store in second units)</font>
+    </p>
+    <p><input type="text" id="storecheckperiodText" value="20" /></p>
+    
+    <p>
+      <b>Solr Server Check Time: </b>
+      <font size=1>(Maximum time in seconds to wait for the availability of the Solr Server)</font>
+    </p>
+    <p><input type="text" id="solrchecktimeText" value="5" /></p>
+    
+    <p>
+      <b>Service Ranking: </b>
+      <font size=1>(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)</font>
+    </p>
+    <p><input type="text" id="rankingText" value="0" /></p>
+    
+    <p>
+      <b>LDPath Program<font color="red">*</font>: </b>
+      <font size=1>(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.)</font>
+    </p>
+    <p><textarea rows="15" id="programTextArea" name="content"></textarea></p>
+    <p><input type="submit" id="ldProgramSubmit" value="Submit" onClick="javascript:submitProgram();" /></p>
+  </fieldset>
+  
+  <div class="waitingDiv">
+    <p>Stanbol is creating your index...</p>
+    <p><img alt="Waiting..." src="http://localhost:8080/static/home/images/ajax-loader.gif"></p>
+  </div>
+</div>  
+  <script language="javascript">
+      function submitProgram() {
+          var name = $.trim($("#nameText").val());
+          var description = $.trim($("#descriptionText").val());
+          var indexContent = $("#indexContentCheckBox").is(':checked');
+          var batchsize = $.trim($("#batchsizeText").val());
+          var storecheckperiod = $.trim($("#storecheckperiodText").val());
+          var solrchecktime = $.trim($("#solrchecktimeText").val());
+          var ranking = $.trim($("#rankingText").val());
+          var program = $.trim($("#programTextArea").val());
+      
+          if(name == "" || program == "") {
+              alert("You should enter an LD Program Name and LD Path Program");
+              return false;
+          }
+          $(".waitingDiv").show();
+          
+          $.ajax({
+              url: "${it.publicBaseUri}contenthub/index/ldpath",
+              type: "POST",
+              data: { name: name, description: description, indexContent: indexContent, batchsize: batchsize, storecheckperiod: storecheckperiod, solrchecktime: solrchecktime, ranking: ranking, program: program },
+              success: function() {
+                  $(".waitingDiv").hide();
+                  $("#submittedPrograms").load("${it.publicBaseUri}contenthub/index/ldpath #submittedPrograms>table");
+                  $("#nameText").attr("value", "");
+                  $("#descriptionText").attr("value", "");
+                  $("#indexContentCheckBox").attr("checked", true);
+                  $("#batchsizeText").attr("value", "10");
+                  $("#storecheckperiodText").attr("value", "20");
+                  $("#solrchecktimeText").attr("value", "5");
+                  $("#rankingText").attr("value", "0");
+                  $("#programTextArea").attr("value", "");
+              },
+              error: function(jqXHR, textStatus, errorThrown) {
+                  $(".waitingDiv").hide();
+                  alert(jqXHR.status + " " + errorThrown);
+              }
+          });
+      }
+  </script>
+  
+</...@common.page>
+</#escape>
\ 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/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=1363343&r1=1363342&r2=1363343&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 Thu Jul 19 14:06:30 2012
@@ -16,79 +16,59 @@
 -->
 <#import "/imports/common.ftl" as common>
 <#escape x as x?html>
-<@common.page title="LD Path" hasrestapi=true>
-
-  <h3>Recently Submitted LD Programs</h3>
-  <div id="storeContents" class="storeContents">
-    <div id="submittedPrograms">
-      <table>
-        <tr>
-          <th></th>
-          <th>ProgramName</th>
-          <th>LD Path Program</th>
-        </tr>
-        <#list it.ldPrograms as ldProgram>
-          <tr>
-            <td><img src="${it.staticRootUrl}/contenthub/images/delete_icon_16.png" onClick="javascript:deleteProgram('${ldProgram.name}')" title="Delete this program" /></td>
-            <td>${ldProgram.name}</td>
-            <td>${ldProgram.ldPathProgram}</td>
-          </tr>
-        </#list>
-      </table>
-    </div>
-  </div>
-  
-  <br/>
-  
-  <h3>Submit a new LD Program</h3>
-  <fieldset>
-    <legend>Give an LD Program Name and LD Path Program</legend>
-    <p>Program Name:</p>
-    <p><input type="text" id="programNameText" /></p>
-    <p>LD Path Program:</p>
-    <p><textarea rows="15" id="ldPathProgramTextArea" name="content"></textarea></p>
-    <p><input type="submit" id="ldProgramSubmit" value="Submit Program" onClick="javascript:submitProgram();" /></p>
-  </fieldset>
-  
-  <script language="javascript">
-      function submitProgram() {
-          var programName = $.trim($("#programNameText").val());
-          var ldPathProgram = $.trim($("#ldPathProgramTextArea").val());
-          
-          if(programName == "" || ldPathProgram == "") {
-              alert("You should enter an LD Program Name and LD Path Program");
-              return false;
-          }
-          
-          $.ajax({
-              url: "${it.publicBaseUri}contenthub/ldpath/program",
-              type: "POST",
-              data: { name: programName, program: ldPathProgram },
-              success: function() {
-                  $("#submittedPrograms").load("${it.publicBaseUri}contenthub/ldpath #submittedPrograms>table");
-                  $("#programNameText").attr("value", "");
-                  $("#ldPathProgramTextArea").attr("value", "");
-              },
-              error: function(jqXHR, textStatus, errorThrown) {
-                  alert(jqXHR.status + " " + errorThrown);
-              }
-          });
-      }
-      
-      function deleteProgram(programName) {
-          $.ajax({
-            url: "${it.publicBaseUri}contenthub/ldpath/program/"+programName,
-            type: "DELETE",
-            async: true,
-            success: function() {
-                $("#submittedPrograms").load("${it.publicBaseUri}contenthub/ldpath #submittedPrograms>table");
-            },
-            error: function(result) {
-                alert(result.status);
-            }
-          });
-      }
+<@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>
+    <h3>Submitted Indexes: </h3>
+    <#if it.semanticIndexes?size &gt; 0>
+      <#list it.semanticIndexes as index>
+        <div class="index">
+          <div class="collapsed">
+            <p class="collapseheader"><b>${index.name}</b></p>
+            <div class="collapsable">
+              <ul>
+                <li>Description: ${index.description}</li>
+                <li>
+                  State: 
+                  <#if index.state?contains("INDEXING") >
+                  <span style="color:#FDD017">
+                  </#if>
+                  <#if index.state?contains("ACTIVE") >
+                  <span style="color:#006600">
+                  </#if>
+                  <#if index.state?contains("UNINIT") >
+                  <span style="color:#808080">
+                  </#if>
+                  ${index.state}
+                  </span>
+                </li>
+                <li>Revision: ${index.revision}</li>
+                <li>RESTful Endpoints: <br/>
+                  <ul>
+                    <#list index.endpoints?keys as endpoint>
+                      <li>
+                        ${endpoint}:
+                        
+                        <a href="${it.publicBaseUri + index.endpoints[endpoint]}<#if endpoint?lower_case = "solr">/select?q=*:*</#if>">
+                          ${it.publicBaseUri + index.endpoints[endpoint]}<br/>
+                        </a>
+                      </li>
+                    </#list>
+                  </ul>
+                </li>
+              </ul>
+            </div>
+          </div>
+        </div>
+      </#list>
+    <#else>
+      There is no submitted index.
+    </#if>
+</div>
+  <script>
+    $(".index p").click(function () {
+      $(this).parents("div").toggleClass("collapsed");
+    })
   </script>
-  
 </...@common.page>
 </#escape>
\ 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/StoreResource/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/StoreResource/index.ftl?rev=1363343&r1=1363342&r2=1363343&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/StoreResource/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/StoreResource/index.ftl Thu Jul 19 14:06:30 2012
@@ -19,7 +19,7 @@
 <@common.page title="Contenthub" hasrestapi=true> 
 
 <div class="panel" id="webview">
-
+<b>Store</b> | <a href="${it.publicBaseUri}contenthub/index">Index</a>
   <div id="searchResult" class="invisible"></div>
 
   <h3>Recently uploaded Content Items</h3>
@@ -103,6 +103,11 @@
       </p>
     </fieldset>
   </form>
+  
+  <div class="waitingDiv">
+    <p>Stanbol is storing your content...</p>
+    <p><img alt="Waiting..." src="http://localhost:8080/static/home/images/ajax-loader.gif"></p>
+  </div>
 </div>
 
 <div class="panel" id="restapi" style="display: none;">
@@ -113,7 +118,7 @@
 
     var counter = 0;
     
-    function setConstraints() {
+    function setConstraints() { 
         var titleStr = document.getElementById("valueTitle").value;
         var fileStr = document.getElementById("file").value;
         if((!fileStr || fileStr == "") && (!titleStr || titleStr == "")) {
@@ -121,6 +126,7 @@
             alert('You should enter title for your content');
             return false;
         }
+        $(".waitingDiv").show();
         
         var i;
         var result = JSON.parse("{}");