Author: ogrisel
Date: Tue Mar 29 17:52:50 2011
New Revision: 1086653
URL: http://svn.apache.org/viewvc?rev=1086653&view=rev
Log:
STANBOL-120: fix a classloading issue for the static resources contributed in
fragments
Added:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragmentHttpContext.java
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/JerseyEndpoint.java
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragment.java
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/resource/NavigationMixin.java
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/resources/META-INF/templates/imports/common.ftl
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/fragment/EnhancerWebFragment.java
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/JerseyEndpoint.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/JerseyEndpoint.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/JerseyEndpoint.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/JerseyEndpoint.java
Tue Mar 29 17:52:50 2011
@@ -87,14 +87,14 @@ public class JerseyEndpoint {
templateClasspath = templateClasspath.replaceAll("/$", "");
app.contributeTemplateLoader(new ClassTemplateLoader(getClass(),
templateClasspath));
- // register the root of static resources
- httpService.registerResources(staticUrlRoot, staticClasspath, null);
- registeredAlias.add(staticUrlRoot);
+ // register the root of static resources (TODO: move me in a dedicated
fragment instead)
+ String defaultStaticAlias = staticUrlRoot + "/default";
+ httpService.registerResources(defaultStaticAlias, staticClasspath,
null);
+ registeredAlias.add(defaultStaticAlias);
// incrementally contribute fragment resources
List<LinkResource> linkResources = new ArrayList<LinkResource>();
List<ScriptResource> scriptResources = new ArrayList<ScriptResource>();
-
for (WebFragment fragment : webFragments) {
log.info("Registering web fragment '{}' into jaxrs application",
fragment.getName());
linkResources.addAll(fragment.getLinkResources());
@@ -103,7 +103,8 @@ public class JerseyEndpoint {
app.contributeSingletons(fragment.getJaxrsResourceSingletons());
app.contributeTemplateLoader(fragment.getTemplateLoader());
String resourceAlias = staticUrlRoot + '/' + fragment.getName();
- httpService.registerResources(resourceAlias,
fragment.getStaticResourceClassPath(), null);
+ httpService.registerResources(resourceAlias,
fragment.getStaticResourceClassPath(),
+ new WebFragmentHttpContext(fragment));
registeredAlias.add(resourceAlias);
}
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragment.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragment.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragment.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragment.java
Tue Mar 29 17:52:50 2011
@@ -3,6 +3,8 @@ package org.apache.stanbol.commons.web;
import java.util.List;
import java.util.Set;
+import org.osgi.framework.BundleContext;
+
import freemarker.cache.TemplateLoader;
/**
@@ -65,5 +67,7 @@ public interface WebFragment {
* ${it.staticRootUrl}/${script.fragmentName}/${script.relativePath}
*/
public List<ScriptResource> getScriptResources();
+
+ public BundleContext getBundleContext();
}
Added:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragmentHttpContext.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragmentHttpContext.java?rev=1086653&view=auto
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragmentHttpContext.java
(added)
+++
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/WebFragmentHttpContext.java
Tue Mar 29 17:52:50 2011
@@ -0,0 +1,39 @@
+package org.apache.stanbol.commons.web;
+
+import java.net.URL;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.http.HttpContext;
+
+/**
+ * Custom HTTP Context to lookup the resources from the classloader of the
WebFragment bundle.
+ */
+public class WebFragmentHttpContext implements HttpContext {
+
+ private Bundle bundle;
+
+ public WebFragmentHttpContext(WebFragment fragment) {
+ this.bundle = fragment.getBundleContext().getBundle();
+ }
+
+ public String getMimeType(String name) {
+ // someone in the chain seems to already be doing the Mime type mapping
+ return null;
+ }
+
+ public URL getResource(String name) {
+ if (name.startsWith("/")) {
+ name = name.substring(1);
+ }
+
+ return this.bundle.getResource(name);
+ }
+
+ public boolean handleSecurity(HttpServletRequest req, HttpServletResponse
res) {
+ return true;
+ }
+
+}
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/resource/NavigationMixin.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/resource/NavigationMixin.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/resource/NavigationMixin.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/resource/NavigationMixin.java
Tue Mar 29 17:52:50 2011
@@ -2,6 +2,7 @@ package org.apache.stanbol.commons.web.r
import java.net.URI;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import javax.servlet.ServletContext;
@@ -73,11 +74,19 @@ public class NavigationMixin {
@SuppressWarnings("unchecked")
public List<LinkResource> getRegisteredLinkResources() {
- return (List<LinkResource>)
servletContext.getAttribute(LINK_RESOURCES);
+ if (servletContext != null) {
+ return (List<LinkResource>)
servletContext.getAttribute(LINK_RESOURCES);
+ } else {
+ return Collections.emptyList();
+ }
}
@SuppressWarnings("unchecked")
public List<ScriptResource> getRegisteredScriptResources() {
- return (List<ScriptResource>)
servletContext.getAttribute(SCRIPT_RESOURCES);
+ if (servletContext != null) {
+ return (List<ScriptResource>)
servletContext.getAttribute(SCRIPT_RESOURCES);
+ } else {
+ return Collections.emptyList();
+ }
}
}
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/resources/META-INF/templates/imports/common.ftl
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/resources/META-INF/templates/imports/common.ftl?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/resources/META-INF/templates/imports/common.ftl
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/resources/META-INF/templates/imports/common.ftl
Tue Mar 29 17:52:50 2011
@@ -6,8 +6,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<!-- to be moved in the dedicated fragment -->
- <link rel="stylesheet" href="/static/style/stanbol.css" />
- <link rel="icon" type="image/png" href="/static/images/favicon.png" />
+ <link rel="stylesheet" href="/static/default/style/stanbol.css" />
+ <link rel="icon" type="image/png"
href="/static/default/images/favicon.png" />
<#list it.registeredLinkResources as link>
<link rel="${link.rel}"
href="${it.staticRootUrl}/${link.fragmentName}/${link.relativePath}" />
@@ -20,7 +20,7 @@
</head>
<body>
- <div class="home"><a href="/"><img
src="/static/images/apache_stanbol_logo_cropped.png" alt="Stanbol Home"
/></a></div>
+ <div class="home"><a href="/"><img
src="/static/default/images/apache_stanbol_logo_cropped.png" alt="Stanbol Home"
/></a></div>
<div class="header">
<h1>The RESTful Semantic Engine</h1>
@@ -63,9 +63,9 @@ $(".restapitabs a").click(function () {
<div class="column">
<a href="http://www.w3.org/standards/semanticweb/"><img class="swcube"
- src="/static/images/sw-cube.png"/></a>
+ src="/static/default/images/sw-cube.png"/></a>
<a href="http://www.iks-project.eu"><img
- height="60px" alt="IKS Project"
src="/static/images/iks_project_logo.jpg" /></a>
+ height="60px" alt="IKS Project"
src="/static/default/images/iks_project_logo.jpg" /></a>
</div>
<div class="column right">
<em>The research leading to these results has received funding from the
European Community's
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/fragment/EnhancerWebFragment.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/fragment/EnhancerWebFragment.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/fragment/EnhancerWebFragment.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/fragment/EnhancerWebFragment.java
Tue Mar 29 17:52:50 2011
@@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.web.LinkResource;
@@ -14,6 +15,8 @@ import org.apache.stanbol.commons.web.We
import org.apache.stanbol.enhancer.jersey.resource.EnginesRootResource;
import org.apache.stanbol.enhancer.jersey.resource.SparqlQueryResource;
import org.apache.stanbol.enhancer.jersey.resource.StoreRootResource;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.TemplateLoader;
@@ -32,10 +35,17 @@ public class EnhancerWebFragment impleme
private static final String TEMPLATE_PATH =
"/org/apache/stanbol/enhancer/jersey/templates";
+ private BundleContext bundleContext;
+
@Override
public String getName() {
return NAME;
}
+
+ @Activate
+ protected void activate(ComponentContext ctx) {
+ this.bundleContext = ctx.getBundleContext();
+ }
@Override
public Set<Class<?>> getJaxrsResourceClasses() {
@@ -79,4 +89,9 @@ public class EnhancerWebFragment impleme
return resources;
}
+ @Override
+ public BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
}
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/ContentItemResource.java
Tue Mar 29 17:52:50 2011
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@@ -63,14 +64,12 @@ public class ContentItemResource extends
private final Logger log = LoggerFactory.getLogger(getClass());
// TODO make this configurable trough a property
- public static final UriRef SUMMARY = new UriRef(
- "http://www.w3.org/2000/01/rdf-schema#comment");
+ public static final UriRef SUMMARY = new
UriRef("http://www.w3.org/2000/01/rdf-schema#comment");
// TODO make this configurable trough a property
- public static final UriRef THUMBNAIL = new UriRef(
- "http://dbpedia.org/ontology/thumbnail");
+ public static final UriRef THUMBNAIL = new
UriRef("http://dbpedia.org/ontology/thumbnail");
- public static final Map<UriRef, String> DEFAULT_THUMBNAILS = new
HashMap<UriRef, String>();
+ public static final Map<UriRef,String> DEFAULT_THUMBNAILS = new
HashMap<UriRef,String>();
static {
DEFAULT_THUMBNAILS.put(DBPEDIA_PERSON, "/static/images/user_48.png");
DEFAULT_THUMBNAILS.put(DBPEDIA_ORGANISATION,
"/static/images/organization_48.png");
@@ -103,15 +102,20 @@ public class ContentItemResource extends
protected Collection<EntityExtractionSummary> places;
- public ContentItemResource(String localId, ContentItem ci,
- TripleCollection remoteEntityCache, UriInfo uriInfo,
- TcManager tcManager, Serializer serializer) throws IOException {
+ public ContentItemResource(String localId,
+ ContentItem ci,
+ TripleCollection remoteEntityCache,
+ UriInfo uriInfo,
+ TcManager tcManager,
+ Serializer serializer,
+ ServletContext servletContext) throws
IOException {
this.contentItem = ci;
this.localId = localId;
this.uriInfo = uriInfo;
this.tcManager = tcManager;
this.serializer = serializer;
this.remoteEntityCache = remoteEntityCache;
+ this.servletContext = servletContext;
if (localId != null) {
URI rawURI = UriBuilder.fromPath("/store/raw/" + localId).build();
@@ -121,13 +125,11 @@ public class ContentItemResource extends
this.imageSrc = rawURI;
}
this.downloadHref = rawURI;
- this.metadataHref = UriBuilder.fromPath(
- "/store/metadata/" + localId).build();
+ this.metadataHref = UriBuilder.fromPath("/store/metadata/" +
localId).build();
}
}
- public String getRdfMetadata(String mediatype)
- throws UnsupportedEncodingException {
+ public String getRdfMetadata(String mediatype) throws
UnsupportedEncodingException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
serializer.serialize(out, contentItem.getMetadata(), mediatype);
return out.toString("utf-8");
@@ -161,51 +163,44 @@ public class ContentItemResource extends
return metadataHref;
}
- public Collection<EntityExtractionSummary> getPersonOccurrences()
- throws ParseException {
+ public Collection<EntityExtractionSummary> getPersonOccurrences() throws
ParseException {
if (people == null) {
people = getOccurrences(DBPEDIA_PERSON);
}
return people;
}
- public Collection<EntityExtractionSummary> getOrganizationOccurrences()
- throws ParseException {
+ public Collection<EntityExtractionSummary> getOrganizationOccurrences()
throws ParseException {
if (organizations == null) {
organizations = getOccurrences(DBPEDIA_ORGANISATION);
}
return organizations;
}
- public Collection<EntityExtractionSummary> getPlaceOccurrences()
- throws ParseException {
+ public Collection<EntityExtractionSummary> getPlaceOccurrences() throws
ParseException {
if (places == null) {
places = getOccurrences(DBPEDIA_PLACE);
}
return places;
}
- public Collection<EntityExtractionSummary> getOccurrences(UriRef type)
- throws ParseException {
+ public Collection<EntityExtractionSummary> getOccurrences(UriRef type)
throws ParseException {
MGraph graph = contentItem.getMetadata();
String q = "PREFIX enhancer: <http://fise.iks-project.eu/ontology/> "
- + "PREFIX dc: <http://purl.org/dc/terms/> "
- + "SELECT ?textAnnotation ?text ?entity ?entity_label
?confidence WHERE { "
- + " ?textAnnotation a enhancer:TextAnnotation ."
- + " ?textAnnotation dc:type %s ."
- + " ?textAnnotation enhancer:selected-text ?text ."
- + " OPTIONAL {"
- + " ?entityAnnotation dc:relation ?textAnnotation ."
- + " ?entityAnnotation a enhancer:EntityAnnotation . "
- + " ?entityAnnotation enhancer:entity-reference ?entity ."
- + " ?entityAnnotation enhancer:entity-label ?entity_label ."
- + " ?entityAnnotation enhancer:confidence ?confidence . }"
- + "} ORDER BY ?text ";
+ + "PREFIX dc: <http://purl.org/dc/terms/> "
+ + "SELECT ?textAnnotation ?text ?entity ?entity_label
?confidence WHERE { "
+ + " ?textAnnotation a enhancer:TextAnnotation ." + "
?textAnnotation dc:type %s ."
+ + " ?textAnnotation enhancer:selected-text ?text ." + "
OPTIONAL {"
+ + " ?entityAnnotation dc:relation ?textAnnotation ."
+ + " ?entityAnnotation a enhancer:EntityAnnotation . "
+ + " ?entityAnnotation enhancer:entity-reference ?entity ."
+ + " ?entityAnnotation enhancer:entity-label ?entity_label
."
+ + " ?entityAnnotation enhancer:confidence ?confidence .
}" + "} ORDER BY ?text ";
q = String.format(q, type);
SelectQuery query = (SelectQuery) QueryParser.getInstance().parse(q);
ResultSet result = tcManager.executeSparqlQuery(query, graph);
- Map<String, EntityExtractionSummary> occurrenceMap = new
TreeMap<String, EntityExtractionSummary>();
+ Map<String,EntityExtractionSummary> occurrenceMap = new
TreeMap<String,EntityExtractionSummary>();
LiteralFactory lf = LiteralFactory.getInstance();
while (result.hasNext()) {
SolutionMapping mapping = result.next();
@@ -229,8 +224,7 @@ public class ContentItemResource extends
UriRef entityUri = (UriRef) mapping.get("entity");
if (entityUri != null) {
String label = ((Literal)
mapping.get("entity_label")).getLexicalForm();
- Double confidence = lf.createObject(Double.class,
- (TypedLiteral) mapping.get("confidence"));
+ Double confidence = lf.createObject(Double.class,
(TypedLiteral) mapping.get("confidence"));
Graph properties = new GraphNode(entityUri,
remoteEntityCache).getNodeContext();
entity.addSuggestion(entityUri, label, confidence, properties);
}
@@ -238,8 +232,7 @@ public class ContentItemResource extends
return occurrenceMap.values();
}
- public static class EntityExtractionSummary implements
- Comparable<EntityExtractionSummary> {
+ public static class EntityExtractionSummary implements
Comparable<EntityExtractionSummary> {
protected final String name;
@@ -255,10 +248,8 @@ public class ContentItemResource extends
mentions.add(name);
}
- public void addSuggestion(UriRef uri, String label, Double confidence,
- TripleCollection properties) {
- EntitySuggestion suggestion = new EntitySuggestion(uri, type,
- label, confidence, properties);
+ public void addSuggestion(UriRef uri, String label, Double confidence,
TripleCollection properties) {
+ EntitySuggestion suggestion = new EntitySuggestion(uri, type,
label, confidence, properties);
if (!suggestions.contains(suggestion)) {
suggestions.add(suggestion);
Collections.sort(suggestions);
@@ -339,8 +330,7 @@ public class ContentItemResource extends
}
}
- public static class EntitySuggestion implements
- Comparable<EntitySuggestion> {
+ public static class EntitySuggestion implements
Comparable<EntitySuggestion> {
protected final UriRef uri;
@@ -352,8 +342,11 @@ public class ContentItemResource extends
protected TripleCollection entityProperties;
- public EntitySuggestion(UriRef uri, UriRef type, String label,
- Double confidence, TripleCollection entityProperties) {
+ public EntitySuggestion(UriRef uri,
+ UriRef type,
+ String label,
+ Double confidence,
+ TripleCollection entityProperties) {
this.uri = uri;
this.label = label;
this.type = type;
@@ -380,8 +373,7 @@ public class ContentItemResource extends
}
public String getThumbnailSrc() {
- Iterator<Triple> abstracts = entityProperties.filter(uri,
- THUMBNAIL, null);
+ Iterator<Triple> abstracts = entityProperties.filter(uri,
THUMBNAIL, null);
while (abstracts.hasNext()) {
Resource object = abstracts.next().getObject();
if (object instanceof UriRef) {
@@ -396,8 +388,7 @@ public class ContentItemResource extends
}
public String getSummary() {
- Iterator<Triple> abstracts = entityProperties.filter(uri, SUMMARY,
- null);
+ Iterator<Triple> abstracts = entityProperties.filter(uri, SUMMARY,
null);
while (abstracts.hasNext()) {
Resource object = abstracts.next().getObject();
if (object instanceof PlainLiteral) {
@@ -422,18 +413,13 @@ public class ContentItemResource extends
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
EntitySuggestion other = (EntitySuggestion) obj;
if (uri == null) {
- if (other.uri != null)
- return false;
- } else if (!uri.equals(other.uri))
- return false;
+ if (other.uri != null) return false;
+ } else if (!uri.equals(other.uri)) return false;
return true;
}
@@ -446,8 +432,7 @@ public class ContentItemResource extends
/**
* @return an RDF/JSON descriptions of places for the word map widget
*/
- public String getPlacesAsJSON() throws ParseException,
- UnsupportedEncodingException {
+ public String getPlacesAsJSON() throws ParseException,
UnsupportedEncodingException {
MGraph g = new SimpleMGraph();
if (remoteEntityCache != null) {
LiteralFactory lf = LiteralFactory.getInstance();
@@ -457,17 +442,15 @@ public class ContentItemResource extends
continue;
}
UriRef uri = new UriRef(bestGuess.getUri());
- Iterator<Triple> latitudes = remoteEntityCache.filter(uri,
- GEO_LAT, null);
+ Iterator<Triple> latitudes = remoteEntityCache.filter(uri,
GEO_LAT, null);
if (latitudes.hasNext()) {
g.add(latitudes.next());
}
- Iterator<Triple> longitutes = remoteEntityCache.filter(uri,
- GEO_LONG, null);
+ Iterator<Triple> longitutes = remoteEntityCache.filter(uri,
GEO_LONG, null);
if (longitutes.hasNext()) {
g.add(longitutes.next());
- g.add(new TripleImpl(uri, Properties.RDFS_LABEL,
- lf.createTypedLiteral(bestGuess.getLabel())));
+ g.add(new TripleImpl(uri, Properties.RDFS_LABEL,
lf.createTypedLiteral(bestGuess
+ .getLabel())));
}
}
}
@@ -475,7 +458,7 @@ public class ContentItemResource extends
serializer.serialize(out, g, SupportedFormat.RDF_JSON);
return out.toString("utf-8");
}
-
+
@GET
@Produces(TEXT_HTML)
public Response get() {
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/EnginesRootResource.java
Tue Mar 29 17:52:50 2011
@@ -160,7 +160,7 @@ public class EnginesRootResource extends
if (buildAjaxview) {
ContentItemResource contentItemResource = new
ContentItemResource(null, ci, entityCache, uriInfo,
- tcManager, serializer);
+ tcManager, serializer, servletContext);
contentItemResource.setRdfSerializationFormat(format);
Viewable ajaxView = new Viewable("/ajax/contentitem",
contentItemResource);
return Response.ok(ajaxView).type(TEXT_HTML).build();
Modified:
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java
URL:
http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java?rev=1086653&r1=1086652&r2=1086653&view=diff
==============================================================================
---
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java
(original)
+++
incubator/stanbol/branches/http-endpoint-refactoring/enhancer/jersey/src/main/java/org/apache/stanbol/enhancer/jersey/resource/StoreRootResource.java
Tue Mar 29 17:52:50 2011
@@ -307,7 +307,7 @@ public class StoreRootResource extends N
throw new WebApplicationException(404);
}
return new ContentItemResource(localId, ci, entityCache, uriInfo,
- tcManager, serializer);
+ tcManager, serializer, servletContext);
}
@GET