You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2014/02/28 10:55:03 UTC
svn commit: r1572899 [3/3] - in /stanbol/trunk: ./ commons/
commons/ldpath/clerezza/
commons/ldpath/clerezza/src/main/java/org/apache/stanbol/commons/ldpath/clerezza/
commons/ldpath/clerezza/src/test/java/org/apache/stanbol/commons/ldpath/clerezza/
com...
Added: stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java?rev=1572899&view=auto
==============================================================================
--- stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java (added)
+++ stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/resource/SiteManagerRootResource.java Fri Feb 28 09:55:01 2014
@@ -0,0 +1,473 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.entityhub.jersey.resource;
+
+import static javax.ws.rs.HttpMethod.GET;
+import static javax.ws.rs.HttpMethod.OPTIONS;
+import static javax.ws.rs.HttpMethod.POST;
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.N3;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.N_TRIPLE;
+import static org.apache.clerezza.rdf.core.serializedform.SupportedFormat.RDF_JSON;
+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.utils.MediaTypeUtil.getAcceptableMediaType;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.getLDPathParseExceptionMessage;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.handleLDPathRequest;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.prepareQueryLDPathProgram;
+import static org.apache.stanbol.entityhub.jersey.utils.LDPathHelper.transformQueryResults;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.Consumes;
+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.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.clerezza.rdf.ontologies.RDFS;
+import org.apache.marmotta.ldpath.exception.LDPathParseException;
+import org.apache.marmotta.ldpath.model.programs.Program;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
+import org.apache.stanbol.commons.namespaceprefix.NamespaceMappingUtils;
+import org.apache.stanbol.commons.namespaceprefix.NamespacePrefixService;
+import org.apache.stanbol.commons.viewable.Viewable;
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+import org.apache.stanbol.entityhub.core.query.QueryResultListImpl;
+import org.apache.stanbol.entityhub.jersey.utils.JerseyUtils;
+import org.apache.stanbol.entityhub.ldpath.EntityhubLDPath;
+import org.apache.stanbol.entityhub.ldpath.backend.SiteManagerBackend;
+import org.apache.stanbol.entityhub.ldpath.query.LDPathSelect;
+import org.apache.stanbol.entityhub.model.clerezza.RdfValueFactory;
+import org.apache.stanbol.entityhub.servicesapi.model.Entity;
+import org.apache.stanbol.entityhub.servicesapi.model.Representation;
+import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
+import org.apache.stanbol.entityhub.servicesapi.query.FieldQuery;
+import org.apache.stanbol.entityhub.servicesapi.query.QueryResultList;
+import org.apache.stanbol.entityhub.servicesapi.site.SiteManager;
+import org.apache.stanbol.entityhub.servicesapi.util.AdaptingIterator;
+import org.codehaus.jettison.json.JSONArray;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+
+/**
+ * Resource to provide a REST API for the {@link SiteManager}.
+ *
+ * TODO: add description
+ */
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
+@Path("/entityhub/sites")
+public class SiteManagerRootResource extends BaseStanbolResource {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Reference
+ private NamespacePrefixService nsPrefixService;
+
+ @Reference
+ private SiteManager referencedSiteManager;
+
+ public static final Set<String> RDF_MEDIA_TYPES = new TreeSet<String>(Arrays.asList(N3, N_TRIPLE,
+ RDF_XML, TURTLE, X_TURTLE, RDF_JSON));
+
+ /**
+ * The Field used for find requests if not specified TODO: Will be depreciated as soon as EntityQuery is
+ * implemented
+ */
+ private static final String DEFAULT_FIND_FIELD = RDFS.label.getUnicodeString();
+
+ /**
+ * The default number of maximal results of searched sites.
+ */
+ private static final int DEFAULT_FIND_RESULT_LIMIT = 5;
+
+
+
+ @OPTIONS
+ public Response handleCorsPreflight(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ //enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+ @OPTIONS
+ @Path("/find")
+ public Response handleCorsPreflightFind(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ //enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @OPTIONS
+ @Path("/query")
+ public Response handleCorsPreflightQuery(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ //enableCORS(servletContext, res, headers);
+ return res.build();
+ }
+
+ @GET
+ @Produces(MediaType.TEXT_HTML)
+ public Response getSitesPage(@Context HttpHeaders headers) {
+ ResponseBuilder rb = Response.ok(new Viewable("index", this));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+
+// removed to allow request with Accept headers other than text/html to return
+// the JSON array
+// @GET
+// @Path("/referenced")
+// @Produces(MediaType.TEXT_HTML)
+// public Response getReferencedSitesPage() {
+// return Response.ok(new Viewable("referenced", this))
+// .header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8").build();
+// }
+
+ /**
+ * Getter for the id's of all referenced sites
+ *
+ * @return the id's of all referenced sites.
+ */
+ @GET
+ @Path(value = "/referenced")
+ @Produces({MediaType.APPLICATION_JSON,MediaType.TEXT_HTML})
+ public Response getReferencedSites(@Context UriInfo uriInfo,
+ @Context HttpHeaders headers) {
+ MediaType acceptable = getAcceptableMediaType(headers,
+ Arrays.asList(MediaType.APPLICATION_JSON,MediaType.TEXT_HTML) ,
+ MediaType.APPLICATION_JSON_TYPE);
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptable)){
+ ResponseBuilder rb = Response.ok(new Viewable("referenced", this));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ } else {
+ JSONArray referencedSites = new JSONArray();
+ for (String site : referencedSiteManager.getSiteIds()) {
+ referencedSites.put(String.format("%sentityhub/site/%s/", uriInfo.getBaseUri(), site));
+ }
+ ResponseBuilder rb = Response.ok(referencedSites.toString());
+ rb.header(HttpHeaders.CONTENT_TYPE, acceptable+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+ }
+
+ @OPTIONS
+ @Path("/entity")
+ public Response handleCorsPreflightEntity(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ //enableCORS(servletContext, res, headers,OPTIONS,GET);
+ return res.build();
+ }
+ /**
+ * Cool URI handler for Signs.
+ *
+ * @param id
+ * The id of the entity (required)
+ * @param headers
+ * the request headers used to get the requested {@link MediaType}
+ * @return a redirection to either a browser view, the RDF meta data or the raw binary content
+ */
+ @GET
+ @Path("/entity")
+ public Response getEntityById(@QueryParam(value = "id") String id, @Context HttpHeaders headers) {
+ log.debug("getSignById() request\n\t> id : {}\n\t> accept : {}\n\t> mediaType: {}",
+ new Object[] {id, headers.getAcceptableMediaTypes(), headers.getMediaType()});
+
+ Collection<String> supported = new HashSet<String>(JerseyUtils.ENTITY_SUPPORTED_MEDIA_TYPES);
+ supported.add(TEXT_HTML);
+ final MediaType acceptedMediaType = getAcceptableMediaType(
+ headers, supported, MediaType.APPLICATION_JSON_TYPE);
+ if (id == null || id.isEmpty()) {
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){
+ ResponseBuilder rb = Response.ok(new Viewable("entity", this));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ } else {
+ return Response.status(Status.BAD_REQUEST)
+ .entity("No or empty ID was parsed. Missing parameter id.\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+ Entity sign = referencedSiteManager.getEntity(id);
+ if (sign != null) {
+ ResponseBuilder rb = Response.ok(sign);
+ rb.header(HttpHeaders.CONTENT_TYPE, acceptedMediaType+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ } else {
+ // TODO: How to parse an ErrorMessage?
+ // create an Response with the the Error?
+ log.info("getSignById() entity {} not found on any referenced site");
+ return Response.status(Status.NOT_FOUND)
+ .entity("Entity with ID '"+id+"' not found an any referenced site\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+
+// @GET
+// @Path("/find")
+// @Produces(MediaType.TEXT_HTML)
+// public Response getFindPage() {
+// return Response.ok(new Viewable("find", this))
+// .header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8").build();
+// }
+
+ @GET
+ @Path("/find")
+ public Response findEntityfromGet(@QueryParam(value = "name") String name,
+ @QueryParam(value = "field") String field,
+ @QueryParam(value = "lang") String language,
+ // @QueryParam(value="select") String select,
+ @QueryParam(value = "limit") @DefaultValue(value = "-1") int limit,
+ @QueryParam(value = "offset") @DefaultValue(value = "0") int offset,
+ @QueryParam(value = "ldpath") String ldpath,
+ @Context HttpHeaders headers) {
+ return findEntity(name, field, language, limit, offset, ldpath, headers);
+ }
+
+ @POST
+ @Path("/find")
+ public Response findEntity(@FormParam(value = "name") String name,
+ @FormParam(value = "field") String parsedField,
+ @FormParam(value = "lang") String language,
+ // @FormParam(value="select") String select,
+ @FormParam(value = "limit") Integer limit,
+ @FormParam(value = "offset") Integer offset,
+ @FormParam(value = "ldpath") String ldpath,
+ @Context HttpHeaders headers) {
+ log.debug("findEntity() Request");
+ Collection<String> supported = new HashSet<String>(JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES);
+ supported.add(TEXT_HTML);
+ final MediaType acceptedMediaType = getAcceptableMediaType(
+ headers, supported, MediaType.APPLICATION_JSON_TYPE);
+ if(name == null || name.isEmpty()){
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){
+ ResponseBuilder rb = Response.ok(new Viewable("find", this));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ } else {
+ return Response.status(Status.BAD_REQUEST)
+ .entity("The name must not be null nor empty for find requests. Missing parameter name.\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+ final String property;
+ if (parsedField == null) {
+ property = DEFAULT_FIND_FIELD;
+ } else {
+ parsedField = parsedField.trim();
+ if (parsedField.isEmpty()) {
+ property = DEFAULT_FIND_FIELD;
+ } else {
+ property = nsPrefixService.getFullName(parsedField);
+ if(property == null){
+ String messsage = String.format("The prefix '%s' of the parsed field '%' is not "
+ + "mapped to any namespace. Please parse the full URI instead!\n",
+ NamespaceMappingUtils.getPrefix(parsedField),parsedField);
+ return Response.status(Status.BAD_REQUEST)
+ .entity(messsage)
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ }
+ }
+ FieldQuery query = JerseyUtils.createFieldQueryForFindRequest(name, property, language,
+ limit == null || limit < 1 ? DEFAULT_FIND_RESULT_LIMIT : limit, offset,ldpath);
+ return executeQuery(referencedSiteManager, query, acceptedMediaType, headers);
+ }
+ @GET
+ @Path("/query")
+ public Response getQueryDocumentation(@Context HttpHeaders headers){
+ ResponseBuilder rb = Response.ok(new Viewable("query", this));
+ rb.header(HttpHeaders.CONTENT_TYPE, TEXT_HTML+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+ /**
+ * Allows to parse any kind of {@link FieldQuery} in its JSON Representation.
+ * <p>
+ * TODO: as soon as the entityhub supports multiple query types this need to be refactored. The idea is
+ * that this dynamically detects query types and than redirects them to the referenced site
+ * implementation.
+ *
+ * @param query
+ * The field query in JSON format
+ * @param headers
+ * the header information of the request
+ * @return the results of the query
+ */
+ @POST
+ @Path("/query")
+ @Consumes( {MediaType.APPLICATION_JSON})
+ public Response queryEntities(FieldQuery query,
+ @Context HttpHeaders headers) {
+ Collection<String> supported = new HashSet<String>(JerseyUtils.QUERY_RESULT_SUPPORTED_MEDIA_TYPES);
+ supported.add(TEXT_HTML);
+ final MediaType acceptedMediaType = getAcceptableMediaType(
+ headers, supported, MediaType.APPLICATION_JSON_TYPE);
+ if(query == null){
+ //if query is null nd the mediaType is HTML we need to print the
+ //Documentation of the RESTful API
+ if(MediaType.TEXT_HTML_TYPE.isCompatible(acceptedMediaType)){
+ return getQueryDocumentation(headers);
+ } else {
+ return Response.status(Status.BAD_REQUEST)
+ .entity("The query must not be null nor empty for query requests. Missing parameter query.\n")
+ .header(HttpHeaders.ACCEPT, acceptedMediaType).build();
+ }
+ } else {
+ return executeQuery(referencedSiteManager, query, acceptedMediaType, headers);
+ }
+ }
+ /*
+ * LDPath support
+ */
+ @OPTIONS
+ @Path("/ldpath")
+ public Response handleCorsPreflightLDPath(@Context HttpHeaders headers){
+ ResponseBuilder res = Response.ok();
+ //enableCORS(servletContext, res, headers,OPTIONS,GET,POST);
+ return res.build();
+ }
+ @GET
+ @Path("/ldpath")
+ public Response handleLDPathGet(
+ @QueryParam(value = "context")Set<String> contexts,
+ @QueryParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathPost(contexts, ldpath, headers);
+ }
+ @POST
+ @Path("/ldpath")
+ public Response handleLDPathPost(
+ @FormParam(value = "context")Set<String> contexts,
+ @FormParam(value = "ldpath")String ldpath,
+ @Context HttpHeaders headers){
+ return handleLDPathRequest(this,new SiteManagerBackend(referencedSiteManager),
+ ldpath, contexts, headers);
+ }
+ /**
+ * Executes the query parsed by {@link #queryEntities(String, File, HttpHeaders)} or created based
+ * {@link #findEntity(String, String, String, int, int, HttpHeaders)}
+ *
+ * @param manager The {@link SiteManager}
+ * @param query
+ * The query to execute
+ * @param headers the request headers
+ * @return the response (results of error)
+ */
+ private Response executeQuery(SiteManager manager,
+ FieldQuery query, MediaType mediaType,
+ HttpHeaders headers) throws WebApplicationException {
+ if(query instanceof LDPathSelect && ((LDPathSelect)query).getLDPathSelect() != null){
+ //use the LDPath variant to process this query
+ return executeLDPathQuery(manager, query, ((LDPathSelect)query).getLDPathSelect(),
+ mediaType, headers);
+ } else { //use the default query execution
+ QueryResultList<Representation> result = manager.find(query);
+ ResponseBuilder rb = Response.ok(result);
+ rb.header(HttpHeaders.CONTENT_TYPE, mediaType+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+ }
+
+ /**
+ * Execute a Query that uses LDPath to process results.
+ * @param query the query
+ * @param mediaType the mediaType for the response
+ * @param headers the http headers of the request
+ * @return the response
+ */
+ private Response executeLDPathQuery(SiteManager manager,FieldQuery query, String ldpathProgramString, MediaType mediaType, HttpHeaders headers) {
+ QueryResultList<Representation> result;
+ ValueFactory vf = new RdfValueFactory(new IndexedMGraph());
+ SiteManagerBackend backend = new SiteManagerBackend(manager);
+ EntityhubLDPath ldPath = new EntityhubLDPath(backend,vf);
+ //copy the selected fields, because we might need to delete some during
+ //the preparation phase
+ Set<String> selectedFields = new HashSet<String>(query.getSelectedFields());
+ //first prepare (only execute the query if the parameters are valid)
+ Program<Object> program;
+ try {
+ program = prepareQueryLDPathProgram(ldpathProgramString, selectedFields, backend, ldPath);
+ } catch (LDPathParseException e) {
+ log.warn("Unable to parse LDPath program used as select for a Query to the '/sites' endpoint:");
+ log.warn("FieldQuery: \n {}",query);
+ log.warn("LDPath: \n {}",((LDPathSelect)query).getLDPathSelect());
+ log.warn("Exception:",e);
+ return Response.status(Status.BAD_REQUEST)
+ .entity(("Unable to parse LDPath program (Messages: "+
+ getLDPathParseExceptionMessage(e)+")!\n"))
+ .header(HttpHeaders.ACCEPT, mediaType).build();
+ } catch (IllegalStateException e) {
+ log.warn("parsed LDPath program is not compatible with the Query " +
+ "parsed to the '/sites' endpoint!",e);
+ return Response.status(Status.BAD_REQUEST)
+ .entity(e.getMessage())
+ .header(HttpHeaders.ACCEPT, mediaType).build();
+ }
+ //2. execute the query
+ // we need to adapt from Entity to Representation
+ //TODO: should we add the metadata to the result?
+ Iterator<Representation> resultIt = new AdaptingIterator<Entity,Representation>(manager.findEntities(query).iterator(),
+ new AdaptingIterator.Adapter<Entity,Representation>() {
+ @Override
+ public Representation adapt(Entity value, Class<Representation> type) {
+ return value.getRepresentation();
+ }},Representation.class);
+ //process the results
+ Collection<Representation> transformedResults = transformQueryResults(resultIt, program,
+ selectedFields, ldPath, backend, vf);
+ result = new QueryResultListImpl<Representation>(query, transformedResults, Representation.class);
+ ResponseBuilder rb = Response.ok(result);
+ rb.header(HttpHeaders.CONTENT_TYPE, mediaType+"; charset=utf-8");
+ //addCORSOrigin(servletContext, rb, headers);
+ return rb.build();
+ }
+}
Modified: stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java (original)
+++ stanbol/trunk/entityhub/jersey/src/main/java/org/apache/stanbol/entityhub/jersey/utils/LDPathHelper.java Fri Feb 28 09:55:01 2014
@@ -21,6 +21,7 @@ import static javax.ws.rs.core.MediaType
import static org.apache.stanbol.commons.web.base.utils.MediaTypeUtil.getAcceptableMediaType;
import static org.apache.stanbol.entityhub.ldpath.LDPathUtils.getReader;
+import java.net.URI;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -37,6 +38,12 @@ import javax.ws.rs.core.Response.Respons
import javax.ws.rs.core.Response.Status;
import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+import org.apache.marmotta.ldpath.exception.LDPathParseException;
+import org.apache.marmotta.ldpath.model.fields.FieldMapping;
+import org.apache.marmotta.ldpath.model.programs.Program;
+import org.apache.marmotta.ldpath.model.selectors.PropertySelector;
+import org.apache.marmotta.ldpath.model.transformers.DoubleTransformer;
import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
import org.apache.stanbol.commons.viewable.Viewable;
import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
@@ -54,15 +61,6 @@ import org.apache.stanbol.entityhub.serv
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.exception.LDPathParseException;
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.model.programs.Program;
-import at.newmedialab.ldpath.model.selectors.PropertySelector;
-import at.newmedialab.ldpath.model.transformers.DoubleTransformer;
-
-
public class LDPathHelper {
private static final Logger log = LoggerFactory.getLogger(LDPathHelper.class);
@@ -72,7 +70,8 @@ public class LDPathHelper {
*/
public static final FieldMapping<Double,Object> RESULT_SCORE_MAPPING =
new FieldMapping<Double,Object>(RdfResourceEnum.resultScore.getUri(),
- "http://www.w3.org/2001/XMLSchema#double", new PropertySelector<Object>(
+ URI.create("http://www.w3.org/2001/XMLSchema#double"),
+ new PropertySelector<Object>(
InMemoryValueFactory.getInstance().createReference(
RdfResourceEnum.resultScore.getUri())),
new DoubleTransformer<Object>(), null);
Modified: stanbol/trunk/entityhub/ldpath/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/pom.xml?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/pom.xml (original)
+++ stanbol/trunk/entityhub/ldpath/pom.xml Fri Feb 28 09:55:01 2014
@@ -55,9 +55,9 @@
<configuration>
<instructions>
<Import-Package>
- at.newmedialab.ldpath; provide:=true,
- at.newmedialab.ldpath.api.backend; provide:=true,
- at.newmedialab.ldpath.api.transformers; provide:=true,
+ org.apache.marmotta.ldpath; provide:=true,
+ org.apache.marmotta.ldpath.api.backend; provide:=true,
+ org.apache.marmotta.ldpath.api.transformers; provide:=true,
org.apache.stanbol.entityhub.servicesapi.query; provide:=true; version="[0.11,1.1)",
org.apache.stanbol.entityhub.ldpath,
org.apache.stanbol.entityhub.ldpath.backend,
@@ -100,12 +100,12 @@
<!-- LD Path -->
<dependency>
- <groupId>at.newmedialab.ldpath</groupId>
+ <groupId>org.apache.marmotta</groupId>
<artifactId>ldpath-api</artifactId>
</dependency>
<dependency>
- <groupId>at.newmedialab.ldpath</groupId>
- <artifactId>ldpath-core-bundle</artifactId>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-core</artifactId>
</dependency>
<!-- generic tax -->
Modified: stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPath.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPath.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPath.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPath.java Fri Feb 28 09:55:01 2014
@@ -18,6 +18,11 @@ package org.apache.stanbol.entityhub.ldp
import java.util.Collection;
+import org.apache.marmotta.ldpath.LDPath;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+import org.apache.marmotta.ldpath.model.fields.FieldMapping;
+import org.apache.marmotta.ldpath.model.programs.Program;
+import org.apache.marmotta.ldpath.parser.DefaultConfiguration;
import org.apache.stanbol.entityhub.core.mapping.ValueConverterFactory.AnyUriConverter;
import org.apache.stanbol.entityhub.core.mapping.ValueConverterFactory.ReferenceConverter;
import org.apache.stanbol.entityhub.core.mapping.ValueConverterFactory.TextConverter;
@@ -31,13 +36,6 @@ import org.apache.stanbol.entityhub.serv
import org.apache.stanbol.entityhub.servicesapi.model.Text;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-import at.newmedialab.ldpath.model.fields.FieldMapping;
-import at.newmedialab.ldpath.model.programs.Program;
-import at.newmedialab.ldpath.parser.DefaultConfiguration;
-
/**
* {@link LDPath} with Entityhub specific configurations.
* In detail this registers {@link NodeTransformer} for:<ul>
Modified: stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/LDPathUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/LDPathUtils.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/LDPathUtils.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/LDPathUtils.java Fri Feb 28 09:55:01 2014
@@ -22,8 +22,6 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
-import at.newmedialab.ldpath.model.programs.Program;
-
public class LDPathUtils {
/**
* Utility method that creates a reader over the parsed String using UTF-8
Modified: stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/AbstractBackend.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/AbstractBackend.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/AbstractBackend.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/backend/AbstractBackend.java Fri Feb 28 09:55:01 2014
@@ -34,6 +34,7 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ThreadPoolExecutor;
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
import org.apache.stanbol.entityhub.core.mapping.ValueConverterFactory;
import org.apache.stanbol.entityhub.servicesapi.EntityhubException;
import org.apache.stanbol.entityhub.servicesapi.defaults.DataTypeEnum;
@@ -51,7 +52,6 @@ import org.apache.stanbol.entityhub.serv
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
/**
* Abstract super class for all Entityhub related {@link RDFBackend}
* implementations. This implements the whole {@link RDFBackend} interface by
Modified: stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/ValueConverterTransformerAdapter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/ValueConverterTransformerAdapter.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/ValueConverterTransformerAdapter.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/main/java/org/apache/stanbol/entityhub/ldpath/transformer/ValueConverterTransformerAdapter.java Fri Feb 28 09:55:01 2014
@@ -16,16 +16,16 @@
*/
package org.apache.stanbol.entityhub.ldpath.transformer;
+import java.util.Map;
+
+import org.apache.marmotta.ldpath.api.backend.RDFBackend;
+import org.apache.marmotta.ldpath.api.transformers.NodeTransformer;
import org.apache.stanbol.entityhub.core.mapping.ValueConverterFactory.ValueConverter;
import org.apache.stanbol.entityhub.core.model.InMemoryValueFactory;
import org.apache.stanbol.entityhub.servicesapi.model.Reference;
import org.apache.stanbol.entityhub.servicesapi.model.Text;
import org.apache.stanbol.entityhub.servicesapi.model.ValueFactory;
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.api.transformers.NodeTransformer;
-
/**
* LDPath {@link NodeTransformer} internally using the Entityhub
* {@link ValueConverter}. <p>
@@ -49,7 +49,7 @@ public class ValueConverterTransformerAd
this.vc = vc;
}
@Override
- public T transform(RDFBackend<Object> backend, Object node) throws IllegalArgumentException {
+ public T transform(RDFBackend<Object> backend, Object node, Map<String, String> configuration) throws IllegalArgumentException {
T value = vc.convert(node, vf);
if(value == null){
value = vc.convert(backend.stringValue(node), vf);
Modified: stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPathTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPathTest.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPathTest.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/EntityhubLDPathTest.java Fri Feb 28 09:55:01 2014
@@ -18,6 +18,7 @@ package org.apache.stanbol.entityhub.ldp
import static org.apache.stanbol.entityhub.ldpath.LDPathUtils.getReader;
import static org.junit.Assert.*;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -27,6 +28,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
+import org.apache.marmotta.ldpath.model.programs.Program;
import org.apache.stanbol.entityhub.core.model.InMemoryValueFactory;
import org.apache.stanbol.entityhub.ldpath.impl.LDPathTestBase;
import org.apache.stanbol.entityhub.ldpath.transformer.ValueConverterTransformerAdapter;
@@ -40,9 +42,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.model.programs.Program;
-
public class EntityhubLDPathTest extends LDPathTestBase {
private static final Logger log = LoggerFactory.getLogger(EntityhubLDPathTest.class);
Modified: stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/backend/BackendTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/backend/BackendTest.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/backend/BackendTest.java (original)
+++ stanbol/trunk/entityhub/ldpath/src/test/java/org/apache/stanbol/entityhub/ldpath/backend/BackendTest.java Fri Feb 28 09:55:01 2014
@@ -26,6 +26,9 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+
+import org.apache.marmotta.ldpath.LDPath;
+import org.apache.marmotta.ldpath.model.programs.Program;
import org.apache.stanbol.entityhub.ldpath.impl.LDPathTestBase;
import org.apache.stanbol.entityhub.servicesapi.model.Representation;
import org.junit.Assert;
@@ -33,10 +36,6 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import at.newmedialab.ldpath.LDPath;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.model.programs.Program;
-
public class BackendTest extends LDPathTestBase {
private static final Logger log = LoggerFactory.getLogger(BackendTest.class);
Modified: stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/DbpediaLDPathTest.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/DbpediaLDPathTest.java?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/DbpediaLDPathTest.java (original)
+++ stanbol/trunk/integration-tests/src/test/java/org/apache/stanbol/entityhub/it/ldpath/DbpediaLDPathTest.java Fri Feb 28 09:55:01 2014
@@ -120,7 +120,7 @@ public class DbpediaLDPathTest extends E
.withFormContent(
"context","http://dbpedia.org/resource/Paris",
//unknown namespace prefix
- "ldpath","name = dct:subject :: xsd:anyURI;")
+ "ldpath","name = nonexistendWkTzK:localName :: xsd:anyURI;")
)
.assertStatus(Status.BAD_REQUEST.getStatusCode());
executor.execute(
Propchange: stanbol/trunk/launchers/
------------------------------------------------------------------------------
Merged /stanbol/branches/release-0.12/launchers:r1572588
Modified: stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml (original)
+++ stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml Fri Feb 28 09:55:01 2014
@@ -104,6 +104,11 @@
<version>2.6</version>
</bundle>
<bundle>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.2.1</version>
+ </bundle>
+ <bundle>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
@@ -581,14 +586,19 @@
<!-- LD Path -->
<startLevel level="27">
<bundle> <!-- LD Path -->
- <groupId>at.newmedialab.ldpath</groupId>
+ <groupId>org.apache.marmotta</groupId>
<artifactId>ldpath-api</artifactId>
- <version>0.9.5</version>
+ <version>3.2.0-SNAPSHOT</version>
</bundle>
<bundle>
- <groupId>at.newmedialab.ldpath</groupId>
+ <groupId>org.apache.marmotta</groupId>
<artifactId>ldpath-core-bundle</artifactId>
- <version>0.9.5</version>
+ <version>3.2.0-SNAPSHOT</version>
+ </bundle>
+ <bundle>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-template</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
</bundle>
<bundle>
<groupId>org.apache.stanbol</groupId>
Modified: stanbol/trunk/launchers/full/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/launchers/full/pom.xml?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/launchers/full/pom.xml (original)
+++ stanbol/trunk/launchers/full/pom.xml Fri Feb 28 09:55:01 2014
@@ -303,14 +303,6 @@
<type>partialbundlelist</type>
<scope>provided</scope>
</dependency>
- <!-- TODO Paoding does not yet support Solr 4 -->
- <!-- dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.launchers.bundlelists.languageextras.paoding</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <type>partialbundlelist</type>
- <scope>provided</scope>
- </dependency -->
<!-- Japanese Language Support -->
<dependency>
<groupId>org.apache.stanbol</groupId>
Propchange: stanbol/trunk/parent/
------------------------------------------------------------------------------
Merged /stanbol/branches/release-0.12/parent:r1572588
Modified: stanbol/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/parent/pom.xml?rev=1572899&r1=1572898&r2=1572899&view=diff
==============================================================================
--- stanbol/trunk/parent/pom.xml (original)
+++ stanbol/trunk/parent/pom.xml Fri Feb 28 09:55:01 2014
@@ -61,6 +61,8 @@
<solr-version>4.4.0</solr-version>
<pax-exam-version>2.3.0.M1</pax-exam-version>
<sesame-version>2.7.7</sesame-version>
+ <marmotta-version>3.2.0-SNAPSHOT</marmotta-version>
+ <ldpath-version>${marmotta-version}</ldpath-version>
<sourceReleaseAssemblyDescriptor>stanbol-source-release-zip-tar</sourceReleaseAssemblyDescriptor>
</properties>
@@ -894,6 +896,11 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.6.1</version>
</dependency>
@@ -1273,16 +1280,71 @@
<type>jar</type>
</dependency>
- <!-- LD Path -->
+ <!-- Marmotta LD Path -->
<dependency>
- <groupId>at.newmedialab.ldpath</groupId>
+ <groupId>org.apache.marmotta</groupId>
<artifactId>ldpath-api</artifactId>
- <version>0.9.5</version>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-core</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-collections</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-date</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-html</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-math</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-text</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-functions-xml</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-backend-jena</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-backend-sesame</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-backend-linkeddata</artifactId>
+ <version>${ldpath-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-backend-file</artifactId>
+ <version>${ldpath-version}</version>
</dependency>
<dependency>
- <groupId>at.newmedialab.ldpath</groupId>
- <artifactId>ldpath-core-bundle</artifactId>
- <version>0.9.5</version>
+ <groupId>org.apache.marmotta</groupId>
+ <artifactId>ldpath-template</artifactId>
+ <version>${ldpath-version}</version>
</dependency>
<!-- Apache Tika -->