You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by si...@apache.org on 2012/03/15 13:43:45 UTC
svn commit: r1300961 [2/2] - in /incubator/stanbol/trunk:
contenthub/ldpath/src/main/java/org/apache/stanbol/contenthub/ldpath/backend/clerezza/
contenthub/ldpath/src/main/resources/solr/core/
contenthub/search/featured/src/main/java/org/apache/stanbol...
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=1300961&r1=1300960&r2=1300961&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 Thu Mar 15 12:43:43 2012
@@ -18,6 +18,7 @@
package org.apache.stanbol.contenthub.web.resources;
import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
+import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
import java.io.IOException;
import java.util.ArrayList;
@@ -29,6 +30,7 @@ import java.util.Set;
import javax.servlet.ServletContext;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
+import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
@@ -94,8 +96,15 @@ public class FeaturedSearchResource exte
@PathParam(value = "index") String indexName) throws IOException,
InvalidSyntaxException {
this.indexName = indexName;
- featuredSearch = ContextHelper.getServiceFromContext(FeaturedSearch.class, context);
- tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
+ this.featuredSearch = ContextHelper.getServiceFromContext(FeaturedSearch.class, context);
+ this.tcManager = ContextHelper.getServiceFromContext(TcManager.class, context);
+ }
+
+ @OPTIONS
+ public Response handleCorsPreflight(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
}
/**
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RelatedKeywordResource.java Thu Mar 15 12:43:43 2012
@@ -17,6 +17,7 @@
package org.apache.stanbol.contenthub.web.resources;
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.Collection;
@@ -25,6 +26,7 @@ import java.util.List;
import javax.servlet.ServletContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
+import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
@@ -80,6 +82,13 @@ public class RelatedKeywordResource exte
relatedKeywordSearchManager = ContextHelper.getServiceFromContext(RelatedKeywordSearchManager.class,
context);
}
+
+ @OPTIONS
+ public Response handleCorsPreflight(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
/**
* HTTP GET method to retrieve related keywords from all resources defined within Contenthub.
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/RootResource.java Thu Mar 15 12:43:43 2012
@@ -16,12 +16,18 @@
*/
package org.apache.stanbol.contenthub.web.resources;
+import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
+
import java.net.URI;
import java.net.URISyntaxException;
import javax.ws.rs.GET;
+import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
@@ -34,6 +40,13 @@ import org.apache.stanbol.commons.web.ba
@Path("/contenthub")
public class RootResource extends BaseStanbolResource {
+ @OPTIONS
+ public Response handleCorsPreflight(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
@GET
public Response getView() throws URISyntaxException {
return Response.seeOther(new URI(uriInfo.getBaseUri() + "contenthub/contenthub/store/")).build();
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/SemanticIndexManagerResource.java Thu Mar 15 12:43:43 2012
@@ -76,7 +76,6 @@ public class SemanticIndexManagerResourc
}
}
- // copied from SiteManagerRootResource
@OPTIONS
public Response handleCorsPreflight(@Context HttpHeaders headers) {
ResponseBuilder res = Response.ok();
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=1300961&r1=1300960&r2=1300961&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 Thu Mar 15 12:43:43 2012
@@ -28,11 +28,13 @@ import static org.apache.clerezza.rdf.co
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.RDF_XML;
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.TURTLE;
import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.X_TURTLE;
+import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
+import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
-import java.io.BufferedWriter;
+import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
@@ -53,6 +55,7 @@ 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;
@@ -80,10 +83,9 @@ import org.apache.stanbol.commons.web.ba
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
import org.apache.stanbol.contenthub.search.featured.util.SolrContentItemConverter;
import org.apache.stanbol.contenthub.search.solr.SolrSearchImpl;
-import org.apache.stanbol.contenthub.servicesapi.Constants;
import org.apache.stanbol.contenthub.servicesapi.ldpath.SemanticIndexManager;
import org.apache.stanbol.contenthub.servicesapi.search.SearchException;
-import org.apache.stanbol.contenthub.servicesapi.search.featured.ResultantDocument;
+import org.apache.stanbol.contenthub.servicesapi.search.featured.DocumentResult;
import org.apache.stanbol.contenthub.servicesapi.search.solr.SolrSearch;
import org.apache.stanbol.contenthub.servicesapi.store.StoreException;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
@@ -136,7 +138,7 @@ public class StoreResource extends BaseS
private int pageSize = 5;
- private List<ResultantDocument> recentlyEnhanced;
+ private List<DocumentResult> recentlyEnhanced;
private String indexName;
@@ -174,6 +176,69 @@ public class StoreResource extends BaseS
}
}
+ @OPTIONS
+ public Response handleCorsPreflight(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/content/{uri:.+}")
+ public Response handleCorsPreflightContent(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/download/{type}/{uri:.+}")
+ public Response handleCorsPreflightDownload(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/metadata/{uri:.+}")
+ public Response handleCorsPreflightMetadata(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/raw/{uri:.+}")
+ public Response handleCorsPreflightRaw(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/edit/{uri:.+}")
+ public Response handleCorsPreflightEdit(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/{uri:.+}")
+ public Response handleCorsPreflightURI(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/update")
+ public Response handleCorsPreflightUpdate(@Context HttpHeaders headers) {
+ ResponseBuilder res = Response.ok();
+ enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
/*
* Methods for retrieving various parts e.g raw content, metadata of content items
*/
@@ -201,7 +266,9 @@ public class StoreResource extends BaseS
if (mt.toString().startsWith(TEXT_HTML)) {
URI pageUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName)
.path("store/page").path(contentURI).build();
- return Response.temporaryRedirect(pageUri).build();
+ ResponseBuilder rb = Response.temporaryRedirect(pageUri);
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
}
@@ -210,12 +277,16 @@ public class StoreResource extends BaseS
if (RDF_MEDIA_TYPES.contains(mt.toString())) {
URI metadataUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName)
.path("store/metadata").path(contentURI).build();
- return Response.temporaryRedirect(metadataUri).build();
+ ResponseBuilder rb = Response.temporaryRedirect(metadataUri);
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
}
URI rawUri = uriInfo.getBaseUriBuilder().path("/contenthub").path(indexName).path("store/raw")
.path(contentURI).build();
- return Response.temporaryRedirect(rawUri).build();
+ ResponseBuilder rb = Response.temporaryRedirect(rawUri);
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
/**
@@ -234,47 +305,52 @@ public class StoreResource extends BaseS
@GET
@Path("/download/{type}/{uri:.+}")
public Response downloadContentItem(@PathParam(value = "type") String type,
- @PathParam(value = "uri") String contentURI) throws IOException,
- StoreException {
+ @PathParam(value = "uri") String contentURI,
+ @Context HttpHeaders headers) throws IOException, StoreException {
ContentItem ci = solrStore.get(contentURI, indexName);
if (ci == null) {
throw new WebApplicationException(404);
}
if (type.equals("metadata")) {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- serializer.serialize(out, ci.getMetadata(), SupportedFormat.RDF_XML);
String fileName = contentURI + "-metadata";
File file = new File(fileName);
+ if (file.exists()) {
+ file.delete();
+ }
boolean success = file.createNewFile();
if (success) {
- BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));
- bufferedWriter.write(out.toString());
- bufferedWriter.close();
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
+ serializer.serialize(bos, ci.getMetadata(), SupportedFormat.RDF_XML);
+ bos.close();
} else {
- log.error("File already exists");
+ log.error("Failed to create file: {}", fileName);
}
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.type("text/plain");
+ addCORSOrigin(servletContext, response, headers);
return response.build();
} else if (type.equals("raw")) {
- // TODO: It is only for text content
String fileName = contentURI + "-raw";
File file = new File(fileName);
+ if (file.exists()) {
+ file.delete();
+ }
boolean success = file.createNewFile();
if (success) {
- BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileName));
- bufferedWriter.write(IOUtils.toString(ci.getStream(), Constants.DEFAULT_ENCODING));
- bufferedWriter.close();
+ BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
+ bos.write(IOUtils.toByteArray(ci.getStream()));
+ bos.close();
} else {
- log.error("File already exists");
+ log.error("Failed to create file: {}", fileName);
}
ResponseBuilder response = Response.ok((Object) file);
response.header("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.type(ci.getMimeType());
+ addCORSOrigin(servletContext, response, headers);
return response.build();
} else {
throw new WebApplicationException(404);
@@ -294,8 +370,8 @@ public class StoreResource extends BaseS
*/
@GET
@Path("/metadata/{uri:.+}")
- public Response getContentItemMetaData(@PathParam(value = "uri") String contentURI) throws IOException,
- StoreException {
+ public Response getContentItemMetaData(@PathParam(value = "uri") String contentURI,
+ @Context HttpHeaders headers) throws IOException, StoreException {
ContentItem ci = solrStore.get(contentURI, indexName);
if (ci == null) {
throw new WebApplicationException(404);
@@ -303,8 +379,9 @@ public class StoreResource extends BaseS
ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.serialize(out, ci.getMetadata(), SupportedFormat.RDF_XML);
-
- return Response.ok(out.toString(), "text/plain").build();
+ ResponseBuilder rb = Response.ok(out.toString(), "text/plain");
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
/**
@@ -318,14 +395,15 @@ public class StoreResource extends BaseS
*/
@GET
@Path("/raw/{uri:.+}")
- public Response getRawContent(@PathParam(value = "uri") String contentURI) throws IOException,
- StoreException {
+ public Response getRawContent(@PathParam(value = "uri") String contentURI, @Context HttpHeaders headers) throws IOException,
+ StoreException {
ContentItem ci = solrStore.get(contentURI, indexName);
if (ci == null) {
throw new WebApplicationException(404);
}
-
- return Response.ok(ci.getStream(), ci.getMimeType()).build();
+ ResponseBuilder rb = Response.ok(ci.getStream(), ci.getMimeType());
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
/**
@@ -338,7 +416,7 @@ public class StoreResource extends BaseS
*/
@GET
@Path("/edit/{uri:.+}")
- public String editContentItem(@PathParam(value = "uri") String contentURI) throws StoreException {
+ public Response editContentItem(@PathParam(value = "uri") String contentURI, @Context HttpHeaders headers) throws StoreException {
SolrContentItem sci = (SolrContentItem) solrStore.get(contentURI, indexName);
if (sci == null) {
throw new WebApplicationException(404);
@@ -350,13 +428,16 @@ public class StoreResource extends BaseS
} catch (JSONException e) {
throw new StoreException(e.getMessage(), e);
}
- return jsonString;
+ ResponseBuilder rb = Response.ok(jsonString);
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
/*
* Services for content item creation
*/
- // TODO other parameters like title, ldprogram/index should be considered for this service
+ // TODO other parameters like title, ldprogram/index should be considered
+ // for this service
/**
* HTTP POST method to create a content item in Contenthub. This is the very basic method to create the
* content item. The payload of the POST method should include the raw data of the content item to be
@@ -378,7 +459,7 @@ public class StoreResource extends BaseS
EngineException,
StoreException {
String contentURI = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
- return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI);
+ return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI, headers);
}
/**
@@ -405,7 +486,7 @@ public class StoreResource extends BaseS
@Context HttpHeaders headers) throws URISyntaxException,
EngineException,
StoreException {
- return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI);
+ return createEnhanceAndRedirect(data, headers.getMediaType(), contentURI, headers);
}
/**
@@ -527,27 +608,30 @@ public class StoreResource extends BaseS
// feedback
}
} else if (file != null) {
- /*MimeUtil2 mimeUtil = new MimeUtil2();
- mimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.ExtensionMimeDetector");
- mimeUtil.registerMimeDetector("eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
- Collection<?> mimeTypes = mimeUtil.getMimeTypes(file);
- mt = MediaType.valueOf(MimeUtil2.getMostSpecificMimeType(mimeTypes).toString());
- mimeUtil.unregisterMimeDetector("eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
- mimeUtil.unregisterMimeDetector("eu.medsea.mimeutil.detector.ExtensionMimeDetector");
- */
+ /*
+ * MimeUtil2 mimeUtil = new MimeUtil2(); mimeUtil.registerMimeDetector
+ * ("eu.medsea.mimeutil.detector.ExtensionMimeDetector"); mimeUtil.registerMimeDetector
+ * ("eu.medsea.mimeutil.detector.MagicMimeMimeDetector"); Collection<?> mimeTypes =
+ * mimeUtil.getMimeTypes(file); mt = MediaType
+ * .valueOf(MimeUtil2.getMostSpecificMimeType(mimeTypes).toString ());
+ * mimeUtil.unregisterMimeDetector( "eu.medsea.mimeutil.detector.MagicMimeMimeDetector");
+ * mimeUtil.unregisterMimeDetector ("eu.medsea.mimeutil.detector.ExtensionMimeDetector");
+ */
mt = body.getMediaType();
data = FileUtils.readFileToByteArray(file);
- if(title == null || title.isEmpty()) {
- title = disposition.getFileName();
+ if (title == null || title.isEmpty()) {
+ title = disposition.getFileName();
}
}
if (data != null && mt != null) {
String uri = ContentItemHelper.makeDefaultUrn(data).getUnicodeString();
- return createEnhanceAndRedirect(data, mt, uri, true, constraints, title);
+ return createEnhanceAndRedirect(data, mt, uri, true, constraints, title, headers);
} else {
// TODO: add user-friendly feedback on empty requests from a form
- return Response.seeOther(new URI("/contenthub/" + indexName + "/store")).build();
+ ResponseBuilder rb = Response.seeOther(new URI("/contenthub/" + indexName + "/store"));
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
}
@@ -561,19 +645,24 @@ public class StoreResource extends BaseS
String contentURI,
boolean useExplicitRedirect,
Map<String,List<Object>> constraints,
- String title) throws EngineException,
- URISyntaxException,
- StoreException {
+ String title,
+ HttpHeaders headers) throws EngineException,
+ URISyntaxException,
+ StoreException {
SolrContentItem sci = solrStore.create(content, contentURI, title, mediaType.toString(), constraints);
solrStore.enhanceAndPut(sci, indexName);
if (useExplicitRedirect) {
// use an redirect to point browsers to newly created content
- return Response.seeOther(makeRedirectionURI(sci.getUri().getUnicodeString())).build();
+ ResponseBuilder rb = Response.seeOther(makeRedirectionURI(sci.getUri().getUnicodeString()));
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
} else {
// use the correct way of notifying the RESTful client that the
// resource has been successfully created
- return Response.created(makeRedirectionURI(sci.getUri().getUnicodeString())).build();
+ ResponseBuilder rb = Response.created(makeRedirectionURI(sci.getUri().getUnicodeString()));
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
}
@@ -582,7 +671,7 @@ public class StoreResource extends BaseS
}
/**
- * HTTP PUT method to update an existing content item.
+ * HTTP POST method to update an existing content item.
*
* @param contentURI
* URI of the content item to be updated.
@@ -624,12 +713,13 @@ public class StoreResource extends BaseS
IOException,
StoreException {
if (contentURI != null && !contentURI.isEmpty()) {
- deleteContentItem(contentURI);
+ deleteContentItem(contentURI, headers);
}
return createContentItemFromForm(content, url, jsonCons, title, headers);
}
/**
+ * HTTP POST method to update an existing content item.
*
* @param contentURI
* URI of the content item to be updated.
@@ -671,7 +761,7 @@ public class StoreResource extends BaseS
IOException,
StoreException {
if (contentURI != null && !contentURI.isEmpty()) {
- deleteContentItem(contentURI);
+ deleteContentItem(contentURI, headers);
}
return createContentItemFromForm(file, disposition, body, jsonCons, title, headers);
}
@@ -686,15 +776,21 @@ public class StoreResource extends BaseS
*/
@DELETE
@Path("/{uri:.+}")
- public Response deleteContentItem(@PathParam(value = "uri") String contentURI) throws StoreException {
+ public Response deleteContentItem(@PathParam(value = "uri") String contentURI,
+ @Context HttpHeaders headers) throws StoreException {
solrStore.deleteById(contentURI, indexName);
- return Response.ok().build();
+ ResponseBuilder rb = Response.ok();
+ addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
}
- private Response createEnhanceAndRedirect(byte[] data, MediaType mediaType, String contentURI) throws EngineException,
- URISyntaxException,
- StoreException {
- return createEnhanceAndRedirect(data, mediaType, contentURI, false, null, null);
+ private Response createEnhanceAndRedirect(byte[] data,
+ MediaType mediaType,
+ String contentURI,
+ HttpHeaders headers) throws EngineException,
+ URISyntaxException,
+ StoreException {
+ return createEnhanceAndRedirect(data, mediaType, contentURI, false, null, null, headers);
}
/*
@@ -709,7 +805,7 @@ public class StoreResource extends BaseS
InvalidSyntaxException {
this.offset = offset;
this.pageSize = pageSize;
- this.recentlyEnhanced = new ArrayList<ResultantDocument>();
+ this.recentlyEnhanced = new ArrayList<DocumentResult>();
if (!(solrSearch instanceof SolrSearchImpl)) {
throw new WebApplicationException(Response.status(Status.INTERNAL_SERVER_ERROR)
@@ -742,18 +838,19 @@ public class StoreResource extends BaseS
@Path("/page/{uri:.+}")
@Produces(TEXT_HTML)
public ContentItemResource getContentItemView(@PathParam(value = "uri") String contentURI) throws IOException,
- StoreException {
+ StoreException {
ContentItem ci = solrStore.get(contentURI, indexName);
if (ci == null) {
throw new WebApplicationException(404);
}
- return new ContentItemResource(contentURI, ci, uriInfo, "/contenthub/" + indexName + "/store/download",
- tcManager, serializer, servletContext);
+ return new ContentItemResource(contentURI, ci, uriInfo, "/contenthub/" + indexName
+ + "/store/download", tcManager, serializer,
+ servletContext);
}
// Helper methods for HTML view
- public List<ResultantDocument> getRecentlyEnhancedItems() throws ParseException {
+ public List<DocumentResult> getRecentlyEnhancedItems() throws ParseException {
if (recentlyEnhanced.size() > pageSize) {
return recentlyEnhanced.subList(0, pageSize);
} else {
@@ -763,8 +860,8 @@ public class StoreResource extends BaseS
public URI getMoreRecentItemsUri() {
if (offset >= pageSize) {
- return uriInfo.getBaseUriBuilder().path("contenthub").path(indexName).path("store").queryParam("offset", offset - pageSize)
- .build();
+ return uriInfo.getBaseUriBuilder().path("contenthub").path(indexName).path("store")
+ .queryParam("offset", offset - pageSize).build();
} else {
return null;
}
@@ -774,12 +871,12 @@ public class StoreResource extends BaseS
if (recentlyEnhanced.size() <= pageSize) {
return null;
} else {
- return uriInfo.getBaseUriBuilder().path("contenthub").path(indexName).path("store").queryParam("offset", offset + pageSize)
- .build();
+ return uriInfo.getBaseUriBuilder().path("contenthub").path(indexName).path("store")
+ .queryParam("offset", offset + pageSize).build();
}
}
-
+
public String getIndexName() {
- return this.indexName;
+ return this.indexName;
}
}
\ No newline at end of file
Modified: incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/util/JSONUtils.java Thu Mar 15 12:43:43 2012
@@ -30,7 +30,7 @@ import org.apache.solr.client.solrj.resp
import org.apache.stanbol.contenthub.servicesapi.Constants;
import org.apache.stanbol.contenthub.servicesapi.ldpath.LDProgramCollection;
import org.apache.stanbol.contenthub.servicesapi.search.featured.SearchResult;
-import org.apache.stanbol.contenthub.servicesapi.search.featured.ResultantDocument;
+import org.apache.stanbol.contenthub.servicesapi.search.featured.DocumentResult;
import org.apache.stanbol.contenthub.servicesapi.search.related.RelatedKeyword;
import org.apache.stanbol.contenthub.servicesapi.store.solr.SolrContentItem;
import org.apache.stanbol.contenthub.store.solr.util.ContentItemIDOrganizer;
@@ -115,7 +115,7 @@ public class JSONUtils {
return jObject.toString();
}
- private static JSONObject toJSON(ResultantDocument resultantDocument) throws JSONException {
+ private static JSONObject toJSON(DocumentResult resultantDocument) throws JSONException {
JSONObject jObj = new JSONObject();
if (resultantDocument != null) {
jObj.put("uri", resultantDocument.getDereferencableURI());
@@ -131,8 +131,8 @@ public class JSONUtils {
JSONArray jArr = new JSONArray();
if (list != null) {
for (T element : list) {
- if (ResultantDocument.class.isAssignableFrom(element.getClass())) {
- jArr.put(toJSON((ResultantDocument) element));
+ if (DocumentResult.class.isAssignableFrom(element.getClass())) {
+ jArr.put(toJSON((DocumentResult) element));
} else if (FacetField.class.isAssignableFrom(element.getClass())) {
jArr.put(toJSON((FacetField) element));
} else if (FacetField.Count.class.isAssignableFrom(element.getClass())) {
Modified: incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/imports/facetResultMacro.ftl Thu Mar 15 12:43:43 2012
@@ -14,51 +14,46 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
+<#escape x as x?html>
<#macro facetResultMacro facetField consLink>
<#assign limit=4 />
<#if facetField?exists>
<#if facetField.values?exists && facetField.values?size != 0>
+ <#assign consLinkEscaped = consLink/>
+ <#assign facetNameEscaped = facetField.name?url("UTF-8")?js_string/>
+
<#if facetField.name == "stanbolreserved_creationdate">
- <#assign facetName=facetField.name?substring(facetField.name?index_of("_")+1,facetField.name?length)/>
- ${facetName}
+ <#assign facetHtmlName=facetField.htmlName />
+ ${facetHtmlName}
<br/>
<#assign orderedList = facetField.values?sort_by("name") />
<ul><li>
<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"/>
- <#assign consLinkEscaped = consLink?url("UTF-8")?js_string/>
<a href="javascript:getResults('${consLinkEscaped}','stanbolreserved_creationdate','','date')"><input type="button" value=">" /></a>
</li></ul>
<#else>
- <#if facetField.name?last_index_of("_") > 0>
- <#assign facetName=facetField.name?substring(0,facetField.name?last_index_of("_"))/>
- <#else>
- <#assign facetName=facetField.name />
- </#if>
- ${facetName}
- <ul id="${facetName}list">
+ <#assign facetHtmlName=facetField.htmlName />
+ ${facetHtmlName}
+ <ul id="${facetHtmlName}list">
<#if facetField.name?ends_with("_l")>
<li>
- <input id="${facetField.name}TextMin" class="facetText" type="text"/>
- to <input id="${facetField.name}TextMax" class="facetText" type="text"/>
- <#assign facetNameEscaped = facetField.name?url("UTF-8")?js_string/>
- <#assign consLinkEscaped = consLink?url("UTF-8")?js_string/>
+ <input id="${facetHtmlName}TextMin" class="facetText" type="text"/>
+ to <input id="${facetHtmlName}TextMax" class="facetText" type="text"/>
<a href="javascript:getResults('${consLinkEscaped}','${facetNameEscaped}','','range')"><input type="button" value=">" /></a>
</li>
</#if>
<#assign x=0 />
<#list facetField.values as count>
- <#assign facetNameEscaped = facetField.name?url("UTF-8")?js_string/>
<#assign countNameEscaped = count.name?url("UTF-8")?js_string/>
- <#assign consLinkEscaped = consLink?url("UTF-8")?js_string/>
<#if x = limit><#break/></#if>
- <li><a href=javascript:getResults('${consLinkEscaped}','${facetNameEscaped}','${countNameEscaped}','addFacet')>${count.name} ( ${count.count} )</a></li>
+ <li><a href="javascript:getResults('${consLinkEscaped}','${facetNameEscaped}','${countNameEscaped}','addFacet')">${count.name} ( ${count.count} )</a></li>
<#assign x=x+1 />
</#list>
</ul>
<#if facetField.values?size > limit>
- <a id="${facetName?replace(':','_')}" href="">more</a><br>
+ <a id="${facetHtmlName?replace(':','_')}" href="">more</a><br>
</#if>
</#if>
</#if>
@@ -70,30 +65,28 @@
function init() {
-
- $(document).ready(function(){
$("#dateFrom").datepicker({ dateFormat: 'yy-mm-dd' });
$("#dateTo").datepicker({ dateFormat: 'yy-mm-dd' });
- });
- $("#${facetName?replace(':','_')}", this).click(function(e) {
+ $("#${facetHtmlName?replace(':','_')}", this).click(function(e) {
// disable regular form click
e.preventDefault();
- if(document.getElementById("${facetName?replace(':','_')}").innerHTML == "more")
+ if(document.getElementById("${facetHtmlName?replace(':','_')}").innerHTML == "more")
{
var a="<#list facetField.values as count><#assign consLinkEscaped = consLink?url("UTF-8")?js_string/><#assign countNameEscaped = count.name?url("UTF-8")?js_string/><#assign facetNameEscaped = facetField.name?url("UTF-8")?js_string/><li><a href=javascript:getResults('${consLinkEscaped}','${facetNameEscaped}','${countNameEscaped}','addFacet')>${count.name} ( ${count.count} )</a></li></#list>";
- document.getElementById("${facetName}list").innerHTML=a;
- $(this).attr({ 'innerHTML': 'less' });
+ document.getElementById("${facetHtmlName}list").innerHTML=a;
+ document.getElementById("${facetHtmlName?replace(':','_')}").innerHTML = "less";
}
else
{
var a="<#assign x=0 /><#list facetField.values as count><#if x = limit><#break/></#if><li><a href=javascript:getResults('${consLinkEscaped}','${facetNameEscaped}','${countNameEscaped}','addFacet')>${count.name} ( ${count.count} )</a></li><#assign x=x+1 /></#list>";
- document.getElementById("${facetName}list").innerHTML=a;
- $(this).attr({ 'innerHTML': 'more' });
+ document.getElementById("${facetHtmlName}list").innerHTML=a;
+ document.getElementById("${facetHtmlName?replace(':','_')}").innerHTML = "more";
}
});
}
-
+
$(document).ready(init);
</script>
-</#macro>
\ No newline at end of file
+</#macro>
+</#escape>
\ No newline at end of file
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=1300961&r1=1300960&r2=1300961&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 Thu Mar 15 12:43:43 2012
@@ -109,6 +109,10 @@
}
function getResults(jsonCons,facetName,facetValue,operation,voffset,vpageSize){
+ if(operation == "deleteFacet") {
+ facetName = decodeURIComponent(facetName);
+ facetValue = decodeURIComponent(facetValue);
+ }
//clears the content of div because it'll be filled by explorer posts
var keywordToSearch = $("#keywordIn").val();
@@ -134,8 +138,8 @@
}
else if(operation == "deleteFacet") {
- var values = JSONObject[facetName];
-
+
+ var values = JSONObject[facetName];
var length=0;
var index;
for(var value in values) {
@@ -150,7 +154,6 @@
if(length == 1) {
delete JSONObject[facetName];
} else {
- <#-- TODO: change -->
delete JSONObject[facetName][index];
}
}
@@ -208,11 +211,11 @@
JSONObject[facetName].push(facetValue);
}
else if(operation == "range"){
-
+ var facetHtmlName = getHtmlName(facetName);
var JSONObject = JSON.parse(jsonCons);
- var facetValue = "[" + document.getElementById(facetName+"TextMin").value + " TO " +
- document.getElementById(facetName+"TextMax").value + "]";
-
+ var facetValue = "[" + document.getElementById(facetHtmlName+"TextMin").value + " TO " +
+ document.getElementById(facetHtmlName+"TextMax").value + "]";
+
JSONObject[facetName] = new Array();
JSONObject[facetName].push(facetValue);
}
@@ -265,22 +268,22 @@
}
function setChosenFacet(JSONObject) {
var resultString = "";
- var chosenCons = "'" + $("#chosenFacetsHidden").attr("value") + "'";
+ var chosenCons = $("#chosenFacetsHidden").attr("value");
if(JSONObject != null) {
for(var p in JSONObject) {
if(JSONObject.hasOwnProperty(p)) {
for(var value in p) {
if(p.hasOwnProperty(value) && typeof(JSONObject[p][value]) != "undefined") {
- var escapedFacetName = encodeURI(p.toString());
- var escapedFacetValue = encodeURI(JSONObject[p][value]);
- var startindex = (isReserved(p)) ? p.toString().indexOf("_")+1 : 0;
- var lastindex = (isReserved(p) || p.toString().lastIndexOf("_") < 0) ? p.length : p.toString().lastIndexOf("_");
- var href = "<a href=javascript:getResults(";
- href += encodeURI(chosenCons) + ",\"";
- href += escapedFacetName + "\",\"" + escapedFacetValue + "\",\"deleteFacet\") title='Remove'>";
+ var escapedFacetName = escape(encodeURIComponent(p.toString()));
+ var escapedFacetValue = escape(encodeURIComponent(JSONObject[p][value]));
+ var uriEncodedChosenConstraints = chosenCons;
+ var facetHtmlName = getHtmlName(p.toString());
+ var href = "<a href=javascript:getResults('";
+ href += uriEncodedChosenConstraints + "','";
+ href += escapedFacetName + "','" + escapedFacetValue + "','deleteFacet') title='Remove'>";
href += "<img src='${it.staticRootUrl}/contenthub/images/delete_icon_16.png'></a>";
- href += p.toString().substring(startindex, lastindex) + " : " +
+ href += facetHtmlName + " : " +
((isReserved(p)) ? JSONObject[p][value].substring(1,11)+" to "+JSONObject[p][value].substring(25,35) :
JSONObject[p][value]) + "<br/>";
resultString += href;
@@ -296,9 +299,22 @@
}
function isReserved(str){
- return str.indexOf("stanbolreserved") == 0;
+ return str.indexOf("stanbolreserved_") == 0;
}
+ function getHtmlName(name){
+ if(isReserved(name)){
+ return name.substring(name.indexOf("_")+1);
+ }
+ lastUnderscore = name.lastIndexOf("_");
+ if (lastUnderscore >= 0) {
+ underScoreExtension = name.substring(lastUnderscore);
+ if (underScoreExtension == "_t" || underScoreExtension == "_l" || underScoreExtension == "_d" || underScoreExtension == "_dt") {
+ return name.substring(0, lastUnderscore);
+ }
+ }
+ return name;
+ }
</script>
</...@common.page>
</#escape>
Modified: incubator/stanbol/trunk/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/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/FeaturedSearchResource/result.ftl Thu Mar 15 12:43:43 2012
@@ -17,6 +17,7 @@
<#setting url_escaping_charset='ISO-8859-1'>
<#import "/imports/facetResultMacro.ftl" as facetResultMacro>
<#import "/imports/relatedKeywordMacro.ftl" as relatedKeywordMacro>
+<#escape x as x?html>
<#-- limit for the more less button -->
<#assign limit=4>
<div id="text">
@@ -49,7 +50,7 @@
<#if it.chosenFacets?exists && it.chosenFacets != "{}">
<fieldset>
<div id="chosenFacets"></div>
- <div id="chosenFacetsHidden" class="invisible" value='${it.chosenFacets?js_string}'/>
+ <div id="chosenFacetsHidden" class="invisible" value="${it.chosenFacets?url("UTF-8")?js_string}"/>
</fieldset>
</#if>
</div>
@@ -61,7 +62,7 @@
<#list it.searchResults.facets as facet>
<#if facet.values?exists>
<#if it.chosenFacets?exists>
- <@facetResultMacro.facetResultMacro facetField=facet consLink=it.chosenFacets/>
+ <@facetResultMacro.facetResultMacro facetField=facet consLink=it.chosenFacets?url("UTF-8")?js_string/>
<#else>
<@facetResultMacro.facetResultMacro facetField=facet consLink="{}"/>
</#if>
@@ -102,4 +103,5 @@
</ul>
</div>
-</div>
\ No newline at end of file
+</div>
+</#escape>
\ No newline at end of file
Modified: incubator/stanbol/trunk/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/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl?rev=1300961&r1=1300960&r2=1300961&view=diff
==============================================================================
--- incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl (original)
+++ incubator/stanbol/trunk/contenthub/web/src/main/resources/org/apache/stanbol/contenthub/web/templates/org/apache/stanbol/contenthub/web/resources/StoreResource/index.ftl Thu Mar 15 12:43:43 2012
@@ -16,7 +16,7 @@
-->
<#import "/imports/common.ftl" as common>
<#escape x as x?html>
-<@common.page title="Content Hub" hasrestapi=true>
+<@common.page title="Contenthub" hasrestapi=true>
<div class="panel" id="webview">
<table>
@@ -97,7 +97,7 @@ on the disk, just in memory.</em>
</div>
<br/>
- <label onClick="javascript:addConstraint(null);">
+ <label onClick="javascript:addConstraint();">
<img src="${it.staticRootUrl}/contenthub/images/add_icon_16.png" /> Add a new constraint
</label>
</fieldset>
@@ -144,85 +144,79 @@ on the disk, just in memory.</em>
</div>
<div class="panel" id="restapi" style="display: none;">
-<h3>Uploading new content to the Content Hub</h3>
+<h3>Uploading new content to the Contenthub</h3>
- <p>You can upload content to the Content Hub for analysis with or without providing the content
+ <p>Contenthub lives at the endpoint starting with "contenthub":</p>
+ <code>${it.publicBaseUri}contenthub/</code>
+ <p>This endpoint automatically forwards to:</p>
+ <code>${it.publicBaseUri}contenthub/${it.indexName}/store/</code>
+ <p>The endpoint to which Contenthub automatically forwards includes the name of the default index,
+ whose name is "contenthub". That is the reason for two consecutive "contenthub"s in the endpoint.
+ Lastly, "store" page provides the storage related functionalities of Contenthub such as document submission.</p>
+
+ <p>You can upload content to the Contenthub for analysis with or without providing the content
id at your option:</p>
- <ol>
- <li><code>PUT</code> content to <code>${it.publicBaseUri}contenthub/${it.indexName}/content/<strong>content-id</strong></code>
+ <ul>
+ <li><code>POST</code> content to <code>${it.publicBaseUri}contenthub/${it.indexName}/store/<strong>content-id</strong></code>
with <code>Content-Type: text/plain</code>.</li>
- <li><code>GET</code> enhancements from the same URL with
- header <code>Accept: application/rdf+xml</code>.</li>
- </ol>
+ <li><code>GET</code> content with its enhancements from the same URL.</li>
+ </ul>
- <p><code><strong>content-id</strong></code> can be any valid path and
- will be used to fetch your item back later.</p>
+ <p><code><strong>content-id</strong></code> can be any valid URI and
+ will be used to fetch your item back later. <code><strong>content-id</strong></code>s are unique within Contenthub.</p>
<p>On a unix-ish box you can use run the following command from
- the top-level source directory to populate the Stanbol enhancer service with
- sample content items:</p>
+ the top-level source directory to populate the Stanbol Contenthub service with
+ sample content items:</p>
-<pre>
-for file in enhancer/data/text-examples/*.txt;
-do
- curl -i -X PUT -H "Content-Type:text/plain" -T $file ${it.publicBaseUri}contenthub/${it.indexName}/content/$(basename $file) ;
-done
-</pre>
-
- Alternatively you can let the Stanbol enhancer automatically build an id base on the SHA1
- hash of the content by posting it at the root of the Content Hub.
- <ol>
- <li><code>POST</code> content to <code>${it.publicBaseUri}contenthub/</code>
+ <pre>
+ for file in enhancer/data/text-examples/*.txt;
+ do
+ curl -i -X POST -H "Content-Type:text/plain" -T $file ${it.publicBaseUri}contenthub/${it.indexName}/store/$(basename $file);
+ done
+ </pre>
+
+ Alternatively you can let the Stanbol Contenthub automatically build an id base on the SHA1
+ hash of the content by posting it at the root of the Contenthub.
+ <ul>
+ <li><code>POST</code> content to <code>${it.publicBaseUri}contenthub/${it.indexName}/store</code>
with <code>Content-Type: text/plain</code>.</li>
- <li><code>GET</code> enhancements from the URL in the response along with
- header <code>Accept: application/rdf+xml</code>.</li>
- </ol>
+ </ul>
<p>For instance:</p>
<pre>
curl -i -X POST -H "Content-Type:text/plain" \
--data "The Stanbol enhancer can detect famous cities such as Paris." \
- ${it.publicBaseUri}contenthub
+ ${it.publicBaseUri}contenthub/${it.indexName}/store
HTTP/1.1 201 Created
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/content/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
+Location: ${it.publicBaseUri}contenthub/${it.indexName}/store/content/{<code><strong>content-id</strong><code>}
Content-Length: 0
Server: Jetty(6.1.x)
</pre>
+<h3>Fetching back the original content item and the related enhancements from the Contenthub</h3>
-<h3>Fetching back the original content item and the related enhancements from the Content Hub</h3>
-
-<p>Once the content is created in the Content Hub, you can fetch back either the original content, a HTML summary view or
-the extracted RDF metadata by dereferencing the URL using the <code>Accept</code> header
-as selection switch:</p>
+<p>Once the content is created in the Contenthub, you can fetch back either the original content, a HTML summary view or
+the extracted RDF metadata by dereferencing the URL:</p>
<pre>
-curl -i <strong>-H "Accept: text/plain"</strong> ${it.publicBaseUri}contenthub/${it.indexName}/content/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
+curl -i <strong>-H "Accept: text/plain"</strong> ${it.publicBaseUri}contenthub/${it.indexName}/store/content/{<code><strong>content-id</strong><code>}
HTTP/1.1 307 TEMPORARY_REDIRECT
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/<strong>raw</strong>/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
+Location: ${it.publicBaseUri}contenthub/${it.indexName}/store/raw/{<code><strong>content-id</strong><code>}
Content-Length: 0
Server: Jetty(6.1.x)
</pre>
-<pre>
-curl -i <strong>-H "Accept: text/html"</strong> ${it.publicBaseUri}contenthub/${it.indexName}/content/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
-
-HTTP/1.1 307 TEMPORARY_REDIRECT
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/<strong>page</strong>/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
-Content-Length: 0
-Server: Jetty(6.1.x)
-</pre>
+<p>
+Tutorials on Stanbol Contenthub can be found in the following links:<br/>
+<a href="http://incubator.apache.org/stanbol/docs/trunk/contenthub/">Contenhub - One Minute Tutorial</a><br/>
+<a href="http://incubator.apache.org/stanbol/docs/trunk/contenthub/contenthub5min">Contenthub - Five Minutes Tutorial</a>
+</p>
-<pre>
-curl -i <strong>-H "Accept: application/rdf+xml"</strong> ${it.publicBaseUri}contenthub/${it.indexName}/content/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
+<h4>The RESTful API of the Contenthub</h4>
-HTTP/1.1 307 TEMPORARY_REDIRECT
-Location: ${it.publicBaseUri}contenthub/${it.indexName}/<strong>metadata</strong>/sha1-84854eb6802a601ca2349ba28cc55f0b930ac96d
-Content-Length: 0
-Server: Jetty(6.1.x)
-</pre>
</div>
<script language="javascript">
@@ -259,7 +253,7 @@ Server: Jetty(6.1.x)
var i;
var result = JSON.parse("{}");
- for(i=1; i<=counter; i++){
+ for(i=0; i<=counter; i++){
if (document.getElementById("textDiv" + i)) {
var field = jQuery.trim(document.getElementsByName("fieldText"+i)[0].value);
var value = jQuery.trim(document.getElementsByName("valueText"+i)[0].value);
@@ -287,8 +281,7 @@ Server: Jetty(6.1.x)
return true;
}
- function addConstraint(vfn){
- counter++;
+ function addConstraint(){
var newCons = document.createElement('div');
newCons.setAttribute('id','textDiv' + counter);
var fieldName = "fieldText"+counter;
@@ -302,6 +295,7 @@ Server: Jetty(6.1.x)
document.getElementById("constraintsDiv").appendChild(newCons);
document.getElementsByName(fieldName)[0].focus();
+ counter++;
}
function removeConstraint(divNo){
@@ -374,14 +368,11 @@ Server: Jetty(6.1.x)
for(var p in contentItem) {
if(contentItem.hasOwnProperty(p)) {
- var fieldName = p.toString();
- if(fieldName.indexOf("_") != -1) {
- var lastindex = fieldName.lastIndexOf("_");
- fieldName = fieldName.substring(0, lastindex);
- }
- addConstraint(fieldName);
- document.getElementsByName("fieldText"+counter)[0].value = fieldName;
- document.getElementsByName("valueText"+counter)[0].value = contentItem[p].substring(1, contentItem[p].length-1);
+ var fieldHtmlName = getHtmlName(p.toString());
+ addConstraint();
+ var createdConstraintIndex = counter - 1;
+ document.getElementsByName("fieldText"+createdConstraintIndex)[0].value = fieldHtmlName;
+ document.getElementsByName("valueText"+createdConstraintIndex)[0].value = contentItem[p].substring(1, contentItem[p].length-1);
}
}
}
@@ -416,6 +407,17 @@ Server: Jetty(6.1.x)
window.location.replace(lurl);
}
+ function getHtmlName(name){
+ lastUnderscore = name.lastIndexOf("_");
+ if (lastUnderscore >= 0) {
+ underScoreExtension = name.substring(lastUnderscore);
+ if (underScoreExtension == "_t" || underScoreExtension == "_l" || underScoreExtension == "_d" || underScoreExtension == "_dt") {
+ return name.substring(0, lastUnderscore);
+ }
+ }
+ return name;
+ }
+
</script>
</...@common.page>
</#escape>
Added: incubator/stanbol/trunk/data/bundlelist/target/.plxarc
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/data/bundlelist/target/.plxarc?rev=1300961&view=auto
==============================================================================
--- incubator/stanbol/trunk/data/bundlelist/target/.plxarc (added)
+++ incubator/stanbol/trunk/data/bundlelist/target/.plxarc Thu Mar 15 12:43:43 2012
@@ -0,0 +1 @@
+maven-shared-archive-resources
\ No newline at end of file
Added: incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/DEPENDENCIES
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/DEPENDENCIES?rev=1300961&view=auto
==============================================================================
--- incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/DEPENDENCIES (added)
+++ incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/DEPENDENCIES Thu Mar 15 12:43:43 2012
@@ -0,0 +1,13 @@
+// ------------------------------------------------------------------
+// Transitive dependencies of this project determined from the
+// Apache Maven POM organized by organization.
+//
+// For a list of transitive depencies of this project determined
+// from the Apache Maven POM organized by licenses see the
+// DEPENDENCIES-BY-LICENSE file.
+// ------------------------------------------------------------------
+
+
+
+
+
Added: incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/LICENSE?rev=1300961&view=auto
==============================================================================
--- incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/LICENSE (added)
+++ incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/LICENSE Thu Mar 15 12:43:43 2012
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
Added: incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/NOTICE?rev=1300961&view=auto
==============================================================================
--- incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/NOTICE (added)
+++ incubator/stanbol/trunk/data/bundlelist/target/maven-shared-archive-resources/META-INF/NOTICE Thu Mar 15 12:43:43 2012
@@ -0,0 +1,8 @@
+
+Apache Stanbol Data Bundle List
+Copyright 2010-2012 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+
Added: incubator/stanbol/trunk/data/bundlelist/target/org.apache.stanbol.data.bundlelist-0.9.0-incubating-SNAPSHOT-sources.jar
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/data/bundlelist/target/org.apache.stanbol.data.bundlelist-0.9.0-incubating-SNAPSHOT-sources.jar?rev=1300961&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/stanbol/trunk/data/bundlelist/target/org.apache.stanbol.data.bundlelist-0.9.0-incubating-SNAPSHOT-sources.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream