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/02/02 09:32:52 UTC
svn commit: r1239480 - in /incubator/stanbol/trunk:
contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/
enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/
Author: sinaci
Date: Thu Feb 2 08:32:52 2012
New Revision: 1239480
URL: http://svn.apache.org/viewvc?rev=1239480&view=rev
Log:
Upon clicking the download links on ContentHub Store, raw content item and its metadata were being displayed. Now, they can be "downloaded" by the browsers.
Modified:
incubator/stanbol/trunk/contenthub/web/src/main/java/org/apache/stanbol/contenthub/web/resources/StoreResource.java
incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnhancerRootResource.java
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=1239480&r1=1239479&r2=1239480&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 Feb 2 08:32:52 2012
@@ -653,8 +653,8 @@ public class StoreResource extends BaseS
if (ci == null) {
throw new WebApplicationException(404);
}
- return new ContentItemResource(localId, ci, uriInfo, uriInfo.getBaseUriBuilder().path(
- "/contenthub/store"), tcManager, serializer, servletContext);
+ return new ContentItemResource(localId, ci, uriInfo, "/contenthub/store/download", tcManager,
+ serializer, servletContext);
}
// Helper methods for HTML view
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java?rev=1239480&r1=1239479&r2=1239480&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java Thu Feb 2 08:32:52 2012
@@ -60,7 +60,6 @@ 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 javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import org.apache.clerezza.rdf.core.Language;
@@ -144,7 +143,7 @@ public class ContentItemResource extends
public ContentItemResource(String localId,
ContentItem ci,
UriInfo uriInfo,
- UriBuilder uriBuilder,
+ String storePath,
TcManager tcManager,
Serializer serializer,
ServletContext servletContext) throws IOException {
@@ -156,7 +155,7 @@ public class ContentItemResource extends
this.servletContext = servletContext;
if (localId != null) {
- URI rawURI = uriBuilder.path("raw").path(localId).build();
+ URI rawURI = uriInfo.getBaseUriBuilder().path(storePath).path("raw").path(localId).build();
if (ci.getMimeType().equals("text/plain")) {
this.textContent = IOUtils.toString(ci.getStream(), "UTF-8");
} else if (ci.getMimeType().startsWith("image/")) {
@@ -169,7 +168,7 @@ public class ContentItemResource extends
}
}
this.downloadHref = rawURI;
- this.metadataHref = uriBuilder.path("metadata").path(localId).build();
+ this.metadataHref = uriInfo.getBaseUriBuilder().path(storePath).path("metadata").path(localId).build();
}
defaultThumbnails.put(DBPEDIA_PERSON, getStaticRootUrl() + "/home/images/user_48.png");
defaultThumbnails.put(DBPEDIA_ORGANISATION, getStaticRootUrl() + "/home/images/organization_48.png");
Modified: incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnhancerRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnhancerRootResource.java?rev=1239480&r1=1239479&r2=1239480&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnhancerRootResource.java (original)
+++ incubator/stanbol/trunk/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnhancerRootResource.java Thu Feb 2 08:32:52 2012
@@ -22,19 +22,9 @@ import static javax.ws.rs.core.MediaType
import static javax.ws.rs.core.MediaType.WILDCARD;
import static org.apache.stanbol.commons.web.base.CorsHelper.addCORSOrigin;
import static org.apache.stanbol.commons.web.base.CorsHelper.enableCORS;
-import static org.apache.stanbol.commons.web.base.utils.MediaTypeUtil.SUPPORTED_RDF_TYPES;
-import static org.apache.stanbol.commons.web.base.utils.MediaTypeUtil.isAcceptableMediaType;
-import static org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper.getReference;
-import static org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper.getExecutionNode;
-import static org.apache.stanbol.enhancer.servicesapi.helper.ExecutionPlanHelper.isOptional;
-import static org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionPlan.EXECUTION_NODE;
-import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
import java.io.IOException;
import java.net.URI;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -58,7 +48,6 @@ import org.apache.clerezza.rdf.core.Grap
import org.apache.clerezza.rdf.core.MGraph;
import org.apache.clerezza.rdf.core.NonLiteral;
import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
import org.apache.clerezza.rdf.core.access.TcManager;
import org.apache.clerezza.rdf.core.serializedform.Serializer;
import org.apache.stanbol.commons.web.base.ContextHelper;
@@ -74,13 +63,9 @@ import org.apache.stanbol.enhancer.servi
import org.apache.stanbol.enhancer.servicesapi.EnhancementException;
import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
import org.apache.stanbol.enhancer.servicesapi.NoSuchPartException;
-import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
-import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionMetadataHelper;
import org.apache.stanbol.enhancer.servicesapi.helper.ExecutionPlanHelper;
import org.apache.stanbol.enhancer.servicesapi.helper.InMemoryContentItem;
import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionMetadata;
-import org.apache.stanbol.enhancer.servicesapi.rdf.ExecutionPlan;
-import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -123,10 +108,10 @@ public class EnhancerRootResource extend
chain = chainManager.getDefault();
}
- public URI getServiceUrl(){
+ public URI getServiceUrl() {
return uriInfo.getAbsolutePath();
}
-
+
@OPTIONS
public Response handleCorsPreflight(@Context HttpHeaders headers) {
ResponseBuilder res = Response.ok();
@@ -260,7 +245,7 @@ public class EnhancerRootResource extend
@Context HttpHeaders headers) throws EnhancementException, IOException {
log.info("enhance from From: " + content);
ContentItem ci = new InMemoryContentItem(content.getBytes("UTF-8"), TEXT_PLAIN);
- return enhanceAndBuildResponse(format, headers, ci, false ,buildAjaxview);
+ return enhanceAndBuildResponse(format, headers, ci, false, buildAjaxview);
}
/**
@@ -295,15 +280,16 @@ public class EnhancerRootResource extend
protected Response enhanceAndBuildResponse(String format,
HttpHeaders headers,
ContentItem ci,
- boolean inclExecMetadata ,
- boolean buildAjaxview) throws EnhancementException, IOException {
+ boolean inclExecMetadata,
+ boolean buildAjaxview) throws EnhancementException,
+ IOException {
if (jobManager != null) {
jobManager.enhanceContent(ci, chain);
}
if (buildAjaxview) {
- ContentItemResource contentItemResource = new ContentItemResource(null, ci, uriInfo,
- uriInfo.getBaseUriBuilder(), tcManager, serializer, servletContext);
+ ContentItemResource contentItemResource = new ContentItemResource(null, ci, uriInfo, "",
+ tcManager, serializer, servletContext);
contentItemResource.setRdfSerializationFormat(format);
Viewable ajaxView = new Viewable("/ajax/contentitem", contentItemResource);
ResponseBuilder rb = Response.ok(ajaxView);
@@ -313,7 +299,7 @@ public class EnhancerRootResource extend
}
MGraph graph = ci.getMetadata();
- if(inclExecMetadata){
+ if (inclExecMetadata) {
try {
graph.addAll(ci.getPart(ExecutionMetadata.CHAIN_EXECUTION, MGraph.class));
} catch (NoSuchPartException e) {