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/03/28 11:55:50 UTC

svn commit: r1306234 - in /incubator/stanbol/trunk/contenthub/web/src/main: java/org/apache/stanbol/contenthub/web/resources/ resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/

Author: suat
Date: Wed Mar 28 09:55:49 2012
New Revision: 1306234

URL: http://svn.apache.org/viewvc?rev=1306234&view=rev
Log:
Fixed a small bug in HTML interface and added a new method which allows specifying id while submitting a content item.

Modified:
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
    incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
    incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java?rev=1306234&r1=1306233&r2=1306234&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource.java Wed Mar 28 09:55:49 2012
@@ -130,7 +130,7 @@ public class FeaturedSearchResource exte
 	 *            to corresponding Solr queries to enable faceted search. Each
 	 *            constraint is a facet field and values of the constraints maps
 	 *            to the values of the facet fields in Solr queries.
-	 * @param graphURI
+	 * @param ontologyURI
 	 *            URI of the ontology in which related keywords will be searched
 	 *            by
 	 *            {@link RelatedKeywordSearchManager#getRelatedKeywordsFromOntology(String, String)}
@@ -161,7 +161,7 @@ public class FeaturedSearchResource exte
 	public final Response get(@QueryParam("queryTerm") String queryTerm,
 			@QueryParam("solrQuery") String solrQuery,
 			@QueryParam("constraints") String jsonCons,
-			@QueryParam("graphURI") String graphURI,
+			@QueryParam("ontologyURI") String ontologyURI,
 			@QueryParam("offset") @DefaultValue("0") int offset,
 			@QueryParam("limit") @DefaultValue("10") int limit,
 			@QueryParam("fromStore") String fromStore,
@@ -172,7 +172,7 @@ public class FeaturedSearchResource exte
 
 		this.queryTerm = queryTerm = RestUtil.nullify(queryTerm);
 		solrQuery = RestUtil.nullify(solrQuery);
-		graphURI = RestUtil.nullify(graphURI);
+		ontologyURI = RestUtil.nullify(ontologyURI);
 		jsonCons = RestUtil.nullify(jsonCons);
 		this.offset = offset;
 		this.pageSize = limit;
@@ -187,17 +187,17 @@ public class FeaturedSearchResource exte
 				Set<UriRef> mGraphs = tcManager.listMGraphs();
 				Iterator<UriRef> it = mGraphs.iterator();
 				while (it.hasNext()) {
-					graphURI = it.next().getUnicodeString();
-					if (Constants.isGraphReserved(graphURI)) {
+					ontologyURI = it.next().getUnicodeString();
+					if (Constants.isGraphReserved(ontologyURI)) {
 						continue;
 					}
-					this.ontologies.add(graphURI);
+					this.ontologies.add(ontologyURI);
 				}
 				return Response.ok(new Viewable("index", this),
 						MediaType.TEXT_HTML).build();
 			} else {
 				ResponseBuilder rb = performSearch(queryTerm, solrQuery,
-						jsonCons, graphURI, offset, limit,
+						jsonCons, ontologyURI, offset, limit,
 						MediaType.TEXT_HTML_TYPE);
 				addCORSOrigin(servletContext, rb, headers);
 				return rb.build();
@@ -210,7 +210,7 @@ public class FeaturedSearchResource exte
 						.build();
 			} else {
 				ResponseBuilder rb = performSearch(queryTerm, solrQuery,
-						jsonCons, graphURI, offset, limit,
+						jsonCons, ontologyURI, offset, limit,
 						MediaType.APPLICATION_JSON_TYPE);
 				addCORSOrigin(servletContext, rb, headers);
 				return rb.build();

Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java?rev=1306234&r1=1306233&r2=1306234&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java Wed Mar 28 09:55:49 2012
@@ -334,7 +334,7 @@ public class StoreResource extends BaseS
             addCORSOrigin(servletContext, response, headers);
             return response.build();
         } else if (type.equals("raw")) {
-        	//TODO we should return the content directly without the file indirection
+            // 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()) {
@@ -495,6 +495,8 @@ public class StoreResource extends BaseS
      * 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 content
      *            Actual content in text format. If this parameter is supplied, {@link url} is ommitted.
      * @param url
@@ -521,7 +523,8 @@ public class StoreResource extends BaseS
      */
     @POST
     @Consumes(APPLICATION_FORM_URLENCODED)
-    public Response createContentItemFromForm(@FormParam("content") String content,
+    public Response createContentItemFromForm(@FormParam("id") String id,
+                                              @FormParam("content") String content,
                                               @FormParam("url") String url,
                                               @FormParam("constraints") String jsonCons,
                                               @FormParam("title") String title,
@@ -534,7 +537,7 @@ public class StoreResource extends BaseS
         if (jsonCons != null) {
             constraints = JSONUtils.convertToMap(jsonCons);
         }
-        return createContentItemFromForm(content, url, null, null, null, headers, constraints, title);
+        return createContentItemFromForm(id, content, url, null, null, null, headers, constraints, title);
     }
 
     /**
@@ -579,10 +582,12 @@ public class StoreResource extends BaseS
         if (jsonCons != null) {
             constraints = JSONUtils.convertToMap(jsonCons);
         }
-        return createContentItemFromForm(null, null, file, disposition, body, headers, constraints, title);
+        return createContentItemFromForm(file.getName(), null, null, file, disposition, body, headers,
+            constraints, title);
     }
 
-    private Response createContentItemFromForm(String content,
+    private Response createContentItemFromForm(String id,
+                                               String content,
                                                String url,
                                                File file,
                                                FormDataContentDisposition disposition,
@@ -618,8 +623,10 @@ public class StoreResource extends BaseS
         }
 
         if (data != null && mt != null) {
-            String uri = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
-            return createEnhanceAndRedirect(data, mt, uri, true, constraints, title, headers);
+            if (id == null || id.trim().equals("")) {
+                id = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
+            }
+            return createEnhanceAndRedirect(data, mt, id, true, constraints, title, headers);
         } else {
             // TODO: add user-friendly feedback on empty requests from a form
             ResponseBuilder rb = Response.seeOther(new URI("/contenthub/" + indexName + "/store"));
@@ -708,7 +715,7 @@ public class StoreResource extends BaseS
         if (contentURI != null && !contentURI.isEmpty()) {
             deleteContentItem(contentURI, headers);
         }
-        return createContentItemFromForm(content, url, jsonCons, title, headers);
+        return createContentItemFromForm(null, content, url, jsonCons, title, headers);
     }
 
     /**

Modified: incubator/stanbol/trunk/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/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl?rev=1306234&r1=1306233&r2=1306234&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/index.ftl Wed Mar 28 09:55:49 2012
@@ -225,20 +225,24 @@
           //show busy icon
           $("#busyIcon").removeClass("invisible");
 
+		  var urlStr = "${it.publicBaseUri}contenthub/${it.indexName}/search/featured?queryTerm=" + $("#keywordIn").val();
+
           var graph_selected = "";
           var graphInCombo = document.getElementById('graphIn');
           if(graphInCombo != null) {
               var selectedIndex = graphInCombo.selectedIndex;
               if(selectedIndex != 0) {
                   graph_selected = $("#graphIn option:selected").val();
+                  urlStr += "&ontologyURI=" + graph_selected; 
               }
           }
       
+      	    
           $.ajax({
-              url : "${it.publicBaseUri}contenthub/${it.indexName}/search/featured",
+              url : urlStr,
               type : "GET",
               async: true,
-              data: {queryTerm: $("#keywordIn").val(), graph: graph_selected, constraints: JSON.stringify(JSONObject), offset: voffset, limit:vpageSize},
+              data: {queryTerm: $("#keywordIn").val(), ontologyURI: graph_selected, constraints: JSON.stringify(JSONObject), offset: voffset, limit:vpageSize},
               dataType: "html",
               cache: false,
               success: function(result) {