You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2013/10/14 17:34:50 UTC
[1/5] git commit: checking valid context uris
Updated Branches:
refs/heads/develop b5b75ed7d -> 64b93b3d7
checking valid context uris
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/02a29e3a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/02a29e3a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/02a29e3a
Branch: refs/heads/develop
Commit: 02a29e3aae632bfdac6bd5f528be57778fee0f99
Parents: 85d3f3f
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Oct 14 14:06:16 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Oct 14 14:06:16 2013 +0200
----------------------------------------------------------------------
.../core/api/triplestore/ContextService.java | 27 +++--
.../importer/ImportWatchServiceImpl.java | 70 ++++++------
.../triplestore/ContextServiceImpl.java | 38 +++----
.../core/webservices/io/ImportWebService.java | 68 +++++++-----
.../webservices/resource/MetaWebService.java | 108 +++++++++----------
5 files changed, 163 insertions(+), 148 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/02a29e3a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
index 70f9565..d224654 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/api/triplestore/ContextService.java
@@ -18,6 +18,7 @@
package org.apache.marmotta.platform.core.api.triplestore;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.util.List;
import java.util.Set;
@@ -58,14 +59,6 @@ public interface ContextService {
* @return base context
*/
String getBaseContext();
-
- /**
- * Return the knowledge space that is currently selected for write access. The currently active context
- * is either the default context or explicitly passed as argument ctx to web service calls.
- *
- * @return a KiWiUriResource representing the current knowledge space
- */
- URI getCurrentContext();
/**
* Return the set of contexts that is currently active for reading. The set of active contexts
@@ -79,28 +72,32 @@ public interface ContextService {
* Return the context used for storing system information.
*
* @return a URI representing the system context
+ * @throws URISyntaxException
*/
- URI getSystemContext();
+ URI getSystemContext() throws URISyntaxException;
/**
* Get the uri of the inferred context
*
* @return uri of this inferred context
+ * @throws URISyntaxException
*/
- URI getInferredContext();
+ URI getInferredContext() throws URISyntaxException;
/**
* Get the uri of the default context
*
* @return
+ * @throws URISyntaxException
*/
- URI getDefaultContext();
+ URI getDefaultContext() throws URISyntaxException;
/**
* Get the uri of the context used for caching linked data
* @return
+ * @throws URISyntaxException
*/
- URI getCacheContext();
+ URI getCacheContext() throws URISyntaxException;
/**
* List all contexts currently available
@@ -131,8 +128,9 @@ public interface ContextService {
*
* @param uri the uri of the context to create
* @return a URI representing the created context
+ * @throws URISyntaxException
*/
- URI createContext(String uri);
+ URI createContext(String uri) throws URISyntaxException;
/**
* Create a new context with the given URI or return the already existing context. Essentially
@@ -141,8 +139,9 @@ public interface ContextService {
* @param uri
* @param label
* @return
+ * @throws URISyntaxException
*/
- URI createContext(String uri, String label);
+ URI createContext(String uri, String label) throws URISyntaxException;
/**
* Return the context with the given URI if it exists.
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/02a29e3a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
index 06e9106..c7edb6f 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/importer/ImportWatchServiceImpl.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -121,40 +122,46 @@ public class ImportWatchServiceImpl implements ImportWatchService {
final WatchKey key = watcher.take();
for (WatchEvent<?> event : key.pollEvents()) {
- @SuppressWarnings("unchecked")
- Path item = ((WatchEvent<Path>) event).context();
- Path dir = keys.get(key);
- File file = new File(dir.toString(), item.toString()).getAbsoluteFile();
-
- if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind())) {
- if (file.isDirectory()) {
- //recursive registration of sub-directories
- register(Paths.get(dir.toString(), item.toString()), watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE);
- task.updateProgress(++count);
- } else {
- URI context = getTargetContext(file);
- log.debug("Importing '{}'...", file.getAbsolutePath());
- task.updateMessage("importing...");
- task.updateDetailMessage(TASK_DETAIL_PATH, file.getAbsolutePath());
- task.updateDetailMessage(TASK_DETAIL_CONTEXT, context.stringValue());
- if (execImport(file, context)) {
- log.info("Sucessfully imported file '{}' into {}", file.getAbsolutePath(), context.stringValue());
- try {
- //delete the imported file
- log.debug("Deleting {}...", file.getAbsolutePath());
- file.delete();
- } catch (Exception ex) {
- log.error("Error deleing {}: {}", file.getAbsolutePath(), ex.getMessage());
+ try {
+ @SuppressWarnings("unchecked")
+ Path item = ((WatchEvent<Path>) event).context();
+ Path dir = keys.get(key);
+ File file = new File(dir.toString(), item.toString()).getAbsoluteFile();
+
+ if (StandardWatchEventKinds.ENTRY_CREATE.equals(event.kind())) {
+ if (file.isDirectory()) {
+ //recursive registration of sub-directories
+ register(Paths.get(dir.toString(), item.toString()), watcher, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE);
+ task.updateProgress(++count);
+ } else {
+ URI context = getTargetContext(file);
+ log.debug("Importing '{}'...", file.getAbsolutePath());
+ task.updateMessage("importing...");
+ task.updateDetailMessage(TASK_DETAIL_PATH, file.getAbsolutePath());
+ task.updateDetailMessage(TASK_DETAIL_CONTEXT, context.stringValue());
+ if (execImport(file, context)) {
+ log.info("Sucessfully imported file '{}' into {}", file.getAbsolutePath(), context.stringValue());
+ try {
+ //delete the imported file
+ log.debug("Deleting {}...", file.getAbsolutePath());
+ file.delete();
+ } catch (Exception ex) {
+ log.error("Error deleing {}: {}", file.getAbsolutePath(), ex.getMessage());
+ }
}
+ task.updateProgress(++count);
+ task.updateMessage("watching...");
+ task.updateDetailMessage(TASK_DETAIL_PATH, path);
+ task.removeDetailMessage(TASK_DETAIL_CONTEXT);
}
+ } else if (StandardWatchEventKinds.ENTRY_DELETE.equals(event.kind()) && Files.isDirectory(item)) {
+ //TODO: unregister deleted directories?
task.updateProgress(++count);
- task.updateMessage("watching...");
- task.updateDetailMessage(TASK_DETAIL_PATH, path);
- task.removeDetailMessage(TASK_DETAIL_CONTEXT);
}
- } else if (StandardWatchEventKinds.ENTRY_DELETE.equals(event.kind()) && Files.isDirectory(item)) {
- //TODO: unregister deleted directories?
- task.updateProgress(++count);
+ } catch (IOException e) {
+ log.error("Error importing '{}': {}", path, e.getMessage());
+ } catch (URISyntaxException e) {
+ log.error("Error creating context uri for file '{}': {}", path, e.getMessage());
}
}
@@ -230,8 +237,9 @@ public class ImportWatchServiceImpl implements ImportWatchService {
*
* @param file
* @return
+ * @throws URISyntaxException
*/
- private URI getTargetContext(File file) {
+ private URI getTargetContext(File file) throws URISyntaxException {
String subdir = StringUtils.removeStart(file.getParentFile().getAbsolutePath(), this.path);
if (StringUtils.isBlank(subdir)) {
return contextService.getDefaultContext();
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/02a29e3a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
index afe1792..ea1d698 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/ContextServiceImpl.java
@@ -20,6 +20,7 @@ package org.apache.marmotta.platform.core.services.triplestore;
import static org.apache.marmotta.commons.sesame.repository.ExceptionUtils.handleRepositoryException;
import java.io.InputStream;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -31,6 +32,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import org.apache.commons.lang3.StringUtils;
+import org.apache.marmotta.commons.http.UriUtil;
import org.apache.marmotta.commons.sesame.repository.ResourceUtils;
import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.api.importer.ImportService;
@@ -39,7 +41,6 @@ import org.apache.marmotta.platform.core.api.triplestore.SesameService;
import org.apache.marmotta.platform.core.api.user.UserService;
import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
import org.apache.marmotta.platform.core.qualifiers.kspace.ActiveKnowledgeSpaces;
-import org.apache.marmotta.platform.core.qualifiers.kspace.CurrentKnowledgeSpace;
import org.apache.marmotta.platform.core.qualifiers.kspace.DefaultKnowledgeSpace;
import org.apache.marmotta.platform.core.qualifiers.kspace.InferredKnowledgeSpace;
import org.apache.marmotta.platform.core.qualifiers.kspace.SystemKnowledgeSpace;
@@ -167,14 +168,21 @@ public class ContextServiceImpl implements ContextService {
*
* @param uri the uri of the context to create
* @return a URI representing the created context, or null if the URI could not be created
+ * @throws URISyntaxException
*/
@Override
- public URI createContext(String uri) {
+ public URI createContext(String uri) throws URISyntaxException {
return createContext(uri, null);
}
@Override
- public URI createContext(String uri, String label) {
+ public URI createContext(String uri, String label) throws URISyntaxException {
+ if (!UriUtil.validate(uri)) {
+ uri = configurationService.getBaseContext() + uri;
+ if (!UriUtil.validate(uri)) {
+ throw new URISyntaxException(uri, "not valid context uri");
+ }
+ }
try {
RepositoryConnection conn = sesameService.getConnection();
try {
@@ -215,25 +223,14 @@ public class ContextServiceImpl implements ContextService {
}
/**
- * Return the context that is currently selected for write access. The currently active knowledge space
- * is either the default context or explicitly passed as argument ctx to web service calls.
- *
- * @return a KiWiUriResource representing the current knowledge space
- */
- @Override
- @Produces @RequestScoped @CurrentKnowledgeSpace
- public URI getCurrentContext() {
- return null; //To change body of implemented methods use File | Settings | File Templates.
- }
-
- /**
* Return the context used for storing system information.
*
* @return a KiWiUriResource representing the system knowledge space
+ * @throws URISyntaxException
*/
@Override
@Produces @RequestScoped @SystemKnowledgeSpace
- public URI getSystemContext() {
+ public URI getSystemContext() throws URISyntaxException {
return createContext(configurationService.getSystemContext());
}
@@ -263,10 +260,11 @@ public class ContextServiceImpl implements ContextService {
* Get the uri of the inferred context
*
* @return uri of this inferred context
+ * @throws URISyntaxException
*/
@Override
@Produces @RequestScoped @InferredKnowledgeSpace
- public URI getInferredContext() {
+ public URI getInferredContext() throws URISyntaxException {
return createContext(configurationService.getInferredContext());
}
@@ -274,10 +272,11 @@ public class ContextServiceImpl implements ContextService {
* Get the uri of the default context
*
* @return
+ * @throws URISyntaxException
*/
@Override
@Produces @RequestScoped @DefaultKnowledgeSpace
- public URI getDefaultContext() {
+ public URI getDefaultContext() throws URISyntaxException {
return createContext(configurationService.getDefaultContext());
}
@@ -285,9 +284,10 @@ public class ContextServiceImpl implements ContextService {
* Get the uri of the context used for caching linked data
*
* @return
+ * @throws URISyntaxException
*/
@Override
- public URI getCacheContext() {
+ public URI getCacheContext() throws URISyntaxException {
return createContext(configurationService.getCacheContext());
}
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/02a29e3a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java
index 9b0b36d..88cc7ce 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/io/ImportWebService.java
@@ -17,6 +17,31 @@
*/
package org.apache.marmotta.platform.core.webservices.io;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
import org.apache.marmotta.platform.core.api.importer.ImportService;
import org.apache.marmotta.platform.core.api.task.Task;
import org.apache.marmotta.platform.core.api.task.TaskInfo;
@@ -29,24 +54,6 @@ import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.Rio;
import org.slf4j.Logger;
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
/**
* A webservice offering functionality to import data from the KiWi knowledge base.
* <p/>
@@ -153,7 +160,7 @@ public class ImportWebService {
*/
@POST
@Path("/external")
- public Response externalData(@HeaderParam("Content-Type") String type, @QueryParam("url") String url, @QueryParam("context") String context_string) throws IOException, MarmottaImportException {
+ public Response externalData(@HeaderParam("Content-Type") String type, @QueryParam("url") String url, @QueryParam("context") String context) throws IOException, MarmottaImportException {
try {
log.debug("Received 'external' request for {} with {}%n", type, url);
if(type != null && type.lastIndexOf(';') >= 0) {
@@ -161,11 +168,11 @@ public class ImportWebService {
}
if(type==null || !importService.getAcceptTypes().contains(type)) return Response.status(412).entity("define a valid content-type (types: "+importService.getAcceptTypes()+")").build();
final URL finalUrl = new URL(url);
- final URI context = getContext(context_string);
+ final URI ctx = getContext(context);
try {
- URLConnection con = finalUrl.openConnection();
- con.connect();
+ URLConnection conn = finalUrl.openConnection();
+ conn.connect();
} catch(IOException ex) {
return Response.status(502).entity("the URL passed as argument cannot be retrieved").build();
}
@@ -178,11 +185,11 @@ public class ImportWebService {
Task task = taskManagerService.createTask("Import from external source", TASK_GROUP_NAME);
task.updateDetailMessage("source", finalUrl.toExternalForm());
task.updateDetailMessage("type", finalType);
- if (context != null) {
- task.updateDetailMessage("context", context.toString());
+ if (ctx != null) {
+ task.updateDetailMessage("context", ctx.toString());
}
try {
- importService.importData(finalUrl,finalType,userService.getCurrentUser(),context);
+ importService.importData(finalUrl,finalType,userService.getCurrentUser(),ctx);
} catch(Exception e) {
log.error("exception while asynchronously importing data",e);
} finally {
@@ -199,7 +206,9 @@ public class ImportWebService {
return Response.ok().entity(String.format("{\"tname\":\"%s\"}", t.getName())).build();
} catch(MalformedURLException ex) {
return Response.status(400).entity("the URL passed as argument is not valid").build();
- }
+ } catch (URISyntaxException e1) {
+ return Response.status(400).entity("invalid context URI: " + context).build();
+ }
}
/**
@@ -264,11 +273,12 @@ public class ImportWebService {
// return running;
}
- private URI getContext(String context_string) {
- if(context_string != null)
+ private URI getContext(String context_string) throws URISyntaxException {
+ if(context_string != null) {
return contextService.createContext(context_string);
- else
+ } else {
return contextService.getDefaultContext();
+ }
}
protected static class Status {
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/02a29e3a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
index 27785c6..30de0f8 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/webservices/resource/MetaWebService.java
@@ -20,6 +20,7 @@ package org.apache.marmotta.platform.core.webservices.resource;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.LinkedList;
import java.util.List;
@@ -273,72 +274,67 @@ public class MetaWebService {
return response;
}
- if(r != null) {
+ final Resource subject = r;
- final Resource subject = r;
-
- StreamingOutput entity = new StreamingOutput() {
- @Override
- public void write(OutputStream output) throws IOException, WebApplicationException {
- // FIXME: This method is executed AFTER the @Transactional!
- RDFWriter writer = Rio.createWriter(serializer,output);
+ StreamingOutput entity = new StreamingOutput() {
+ @Override
+ public void write(OutputStream output) throws IOException, WebApplicationException {
+ // FIXME: This method is executed AFTER the @Transactional!
+ RDFWriter writer = Rio.createWriter(serializer,output);
+ try {
+ RepositoryConnection connection = sesameService.getConnection();
try {
- RepositoryConnection connection = sesameService.getConnection();
- try {
- connection.begin();
- connection.exportStatements(subject,null,null,true,writer);
- } finally {
- connection.commit();
- connection.close();
- }
- } catch (RepositoryException e) {
- throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
- } catch (RDFHandlerException e) {
- throw new IOException("error while writing RDF data to stream", e);
+ connection.begin();
+ connection.exportStatements(subject,null,null,true,writer);
+ } finally {
+ connection.commit();
+ connection.close();
}
-
+ } catch (RepositoryException e) {
+ throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR);
+ } catch (RDFHandlerException e) {
+ throw new IOException("error while writing RDF data to stream", e);
}
- };
-
- // build response
- Response response = Response.ok(entity).lastModified(KiWiSesameUtil.lastModified(r, conn)).build();
- response.getMetadata().add("ETag", "W/\"" + ETagGenerator.getWeakETag(conn, r) + "\"");
-
- if (!mimetype.contains("html")) { // then create a proper filename
- String[] components;
- if (resource.contains("#")) {
- components = resource.split("#");
- } else {
- components = resource.split("/");
- }
- final String fileName = components[components.length-1] + "." + serializer.getDefaultFileExtension();
- response.getMetadata().add("Content-Disposition", "attachment; filename=\""+fileName+"\"");
+
}
+ };
- // create the Content-Type header for the response
- if (mimetype.startsWith("text/") || mimetype.startsWith("application/")) {
- response.getMetadata().add("Content-Type", mimetype + "; charset=" + ResourceWebService.CHARSET);
+ // build response
+ Response response = Response.ok(entity).lastModified(KiWiSesameUtil.lastModified(r, conn)).build();
+ response.getMetadata().add("ETag", "W/\"" + ETagGenerator.getWeakETag(conn, r) + "\"");
+
+ if (!mimetype.contains("html")) { // then create a proper filename
+ String[] components;
+ if (resource.contains("#")) {
+ components = resource.split("#");
} else {
- response.getMetadata().add("Content-Type", mimetype);
+ components = resource.split("/");
}
+ final String fileName = components[components.length-1] + "." + serializer.getDefaultFileExtension();
+ response.getMetadata().add("Content-Disposition", "attachment; filename=\""+fileName+"\"");
+ }
- // create the Link headers for the response
- List<String> links = new LinkedList<String>();
+ // create the Content-Type header for the response
+ if (mimetype.startsWith("text/") || mimetype.startsWith("application/")) {
+ response.getMetadata().add("Content-Type", mimetype + "; charset=" + ResourceWebService.CHARSET);
+ } else {
+ response.getMetadata().add("Content-Type", mimetype);
+ }
- // build the link to the human readable content of this resource (if it exists)
- String contentLink = ResourceWebServiceHelper.buildContentLink(r, contentService.getContentType(r), configurationService);
- if(!"".equals(contentLink)) {
- links.add(contentLink);
- }
+ // create the Link headers for the response
+ List<String> links = new LinkedList<String>();
- if (links.size() > 0) {
- response.getMetadata().add("Link", CollectionUtils.fold(links, ", "));
- }
- return response;
- } else {
- return Response.status(Response.Status.NOT_FOUND).entity("resource with URI "+resource+" does not exist").build();
+ // build the link to the human readable content of this resource (if it exists)
+ String contentLink = ResourceWebServiceHelper.buildContentLink(r, contentService.getContentType(r), configurationService);
+ if(!"".equals(contentLink)) {
+ links.add(contentLink);
}
- } finally {
+
+ if (links.size() > 0) {
+ response.getMetadata().add("Link", CollectionUtils.fold(links, ", "));
+ }
+ return response;
+ } finally {
if (conn.isOpen()) {
conn.commit();
conn.close();
@@ -376,11 +372,13 @@ public class MetaWebService {
// add RDF data from input to the suject
connection.add(request.getReader(), configurationService.getBaseUri(), parser, contextService.getDefaultContext());
- } finally {
+ } finally {
connection.commit();
connection.close();
}
return Response.ok().build();
+ } catch (URISyntaxException e) {
+ return ResourceWebServiceHelper.buildErrorPage(uri, configurationService.getBaseUri(), Status.INTERNAL_SERVER_ERROR, "invalid target context", configurationService, templatingService);
} catch (RepositoryException e) {
return ResourceWebServiceHelper.buildErrorPage(uri, configurationService.getBaseUri(), Status.INTERNAL_SERVER_ERROR, e.getMessage(), configurationService, templatingService);
} catch (IOException e) {
[5/5] git commit: Merge branch 'develop' of
https://git-wip-us.apache.org/repos/asf/incubator-marmotta into develop
Posted by wi...@apache.org.
Merge branch 'develop' of https://git-wip-us.apache.org/repos/asf/incubator-marmotta into develop
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/64b93b3d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/64b93b3d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/64b93b3d
Branch: refs/heads/develop
Commit: 64b93b3d74492bf21cc4dac76355af22be5b6b87
Parents: 5dca2ca b5b75ed
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Oct 14 17:34:38 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Oct 14 17:34:38 2013 +0200
----------------------------------------------------------------------
libraries/kiwi/kiwi-loader/pom.xml | 147 +++++
.../apache/marmotta/kiwi/loader/KiWiLoader.java | 541 +++++++++++++++++++
.../marmotta/kiwi/loader/KiWiLoaderTest.java | 219 ++++++++
.../src/test/resources/logback-test.xml | 28 +
libraries/kiwi/pom.xml | 1 +
parent/pom.xml | 5 +
6 files changed, 941 insertions(+)
----------------------------------------------------------------------
[4/5] git commit: MARMOTTA-196: accordingly update the webapp
archetype
Posted by wi...@apache.org.
MARMOTTA-196: accordingly update the webapp archetype
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/5dca2ca4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/5dca2ca4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/5dca2ca4
Branch: refs/heads/develop
Commit: 5dca2ca44f61de33bd944b9946cfe95f71563851
Parents: 5ea9649
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Oct 14 15:32:01 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Oct 14 15:32:01 2013 +0200
----------------------------------------------------------------------
.../src/main/webapp/WEB-INF/web.xml | 96 ++------------------
1 file changed, 10 insertions(+), 86 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5dca2ca4/build/archetypes/marmotta-archetype-webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/build/archetypes/marmotta-archetype-webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/build/archetypes/marmotta-archetype-webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
index ffbe30d..f4d8824 100644
--- a/build/archetypes/marmotta-archetype-webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
+++ b/build/archetypes/marmotta-archetype-webapp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
@@ -1,6 +1,3 @@
-#set( $symbol_pound = '#' )
-#set( $symbol_dollar = '$' )
-#set( $symbol_escape = '\' )
<?xml version="1.0" encoding="UTF-8"?>
<!--
@@ -21,105 +18,47 @@
limitations under the License.
-->
-<web-app version="2.5"
+<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <!-- enable LMF custom JNDI implementation -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.jndi.MarmottaJndiListener</listener-class>
- </listener>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<!-- enable CDI / Weld for dependency injection -->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
- <!-- Initialise the KiWi system -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupListener</listener-class>
- </listener>
-
<!-- RESTeasy Webservices -->
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
- <!-- specifies the LMF home directory; overridden by environment variable LMF_HOME or system property kiwi.home -->
+ <!-- specifies the home directory; overridden by environment variable MARMOTTA_HOME or system property marmotta.home -->
<context-param>
- <param-name>kiwi.home</param-name>
- <param-value>/tmp/lmf</param-value>
+ <param-name>marmotta.home</param-name>
+ <param-value>/tmp/marmotta</param-value>
</context-param>
-
-
- <!-- handle OPTIONS requests -->
- <filter>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaOptionsFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- enables a cors filter and maps it to any request -->
+
+ <!-- enables a CORS filter and maps it to any request -->
<!-- for more fine grained configuration have a look at http://software.dzhuvinov.com/cors-filter-configuration.html -->
<filter>
<!-- The CORS filter with parameters -->
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
-
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, PUT, DELETE, OPTIONS</param-value>
</init-param>
-
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Origin, Accept, Content-Type</param-value>
</init-param>
-
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
- <!-- this filter performs startup configurations for first installation -->
- <filter>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- Serve static resources from file system and from .jar files of the respective modules -->
- <filter>
- <filter-name>MarmottaResourceFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter</filter-class>
- <init-param>
- <!-- cache resources loaded from module jar files? -->
- <param-name>kiwi.resourceCaching</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaResourceFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- H2 Configuration -->
- <filter>
- <filter-name>MarmottaH2ConsoleFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaH2ConsoleFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaH2ConsoleFilter</filter-name>
- <url-pattern>/database/*</url-pattern>
- </filter-mapping>
+
<servlet>
<servlet-name>H2Console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
@@ -133,8 +72,8 @@
</servlet-mapping>
<mime-mapping>
+ <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<extension>.xsl</extension>
- <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<mime-type>application/xslt+xml</mime-type>
</mime-mapping>
@@ -142,7 +81,6 @@
<servlet-name>ViewStatusMessages</servlet-name>
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet</servlet-class>
</servlet>
-
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logging/status</url-pattern>
@@ -150,15 +88,12 @@
<filter>
<filter-name>MarmottaWebservices</filter-name>
- <filter-class>
- org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
- </filter-class>
+ <filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.apache.marmotta.platform.core.webservices.CoreApplication</param-value>
</init-param>
</filter>
-
<filter-mapping>
<filter-name>MarmottaWebservices</filter-name>
<url-pattern>/*</url-pattern>
@@ -169,15 +104,4 @@
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
</context-param>
- <filter>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <filter-class>
- org.apache.marmotta.platform.core.servlet.MarmottaPostStartupFilter
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
</web-app>
[2/5] git commit: MARMOTTA-196: switched to servlet 3.0 java
annotations to considerably reduce the size of the minimum web.xml file
Posted by wi...@apache.org.
MARMOTTA-196: switched to servlet 3.0 java annotations to considerably reduce the size of the minimum web.xml file
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/bcccd8fb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/bcccd8fb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/bcccd8fb
Branch: refs/heads/develop
Commit: bcccd8fbccd1b336a404689bcda456ecb3c3f53d
Parents: 02a29e3
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Oct 14 15:27:39 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Oct 14 15:27:39 2013 +0200
----------------------------------------------------------------------
.../platform/core/jndi/MarmottaJndiListener.java | 8 +++++---
.../core/servlet/MarmottaH2ConsoleFilter.java | 11 +++++------
.../core/servlet/MarmottaOptionsFilter.java | 19 ++++++-------------
.../core/servlet/MarmottaPostStartupFilter.java | 2 ++
.../core/servlet/MarmottaPreStartupFilter.java | 13 ++++++-------
.../core/servlet/MarmottaPreStartupListener.java | 15 +++++++++------
.../core/servlet/MarmottaResourceFilter.java | 4 ++++
7 files changed, 37 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jndi/MarmottaJndiListener.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jndi/MarmottaJndiListener.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jndi/MarmottaJndiListener.java
index e905d06..4d27802 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jndi/MarmottaJndiListener.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/jndi/MarmottaJndiListener.java
@@ -24,12 +24,14 @@ import javax.naming.NamingException;
import javax.naming.spi.NamingManager;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
+ * Listener to enable custom JNDI implementation
+ *
+ * @author Sebastian Schaffert
*/
+@WebListener
public class MarmottaJndiListener implements ServletContextListener {
private static Logger log = LoggerFactory.getLogger(MarmottaJndiListener.class);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaH2ConsoleFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaH2ConsoleFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaH2ConsoleFilter.java
index 8b24b59..0ca497c 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaH2ConsoleFilter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaH2ConsoleFilter.java
@@ -17,8 +17,7 @@
*/
package org.apache.marmotta.platform.core.servlet;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.slf4j.Logger;
+import java.io.IOException;
import javax.inject.Inject;
import javax.servlet.Filter;
@@ -27,21 +26,21 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
+
+import org.apache.marmotta.platform.core.api.config.ConfigurationService;
/**
* This filter injects the database configuration into the H2 console using the LMF Configuration settings
* <p/>
* User: sschaffe
*/
+@WebFilter("/database/*")
public class MarmottaH2ConsoleFilter implements Filter {
@Inject
- private Logger log;
-
- @Inject
private ConfigurationService configurationService;
@Override
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaOptionsFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaOptionsFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaOptionsFilter.java
index d14209e..8d45eb4 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaOptionsFilter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaOptionsFilter.java
@@ -17,25 +17,23 @@
*/
package org.apache.marmotta.platform.core.servlet;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.jboss.resteasy.spi.DefaultOptionsMethodException;
-import org.jboss.resteasy.spi.ResteasyProviderFactory;
-import org.slf4j.Logger;
+import java.io.IOException;
-import javax.inject.Inject;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
-import java.io.IOException;
-import java.util.Arrays;
+
+import org.jboss.resteasy.spi.DefaultOptionsMethodException;
+import org.jboss.resteasy.spi.ResteasyProviderFactory;
/**
* This filter checks for OPTIONS requests. If the response returned by the other filters throws an exception
@@ -45,14 +43,9 @@ import java.util.Arrays;
* <p/>
* Author: Sebastian Schaffert
*/
+@WebFilter("/*")
public class MarmottaOptionsFilter implements Filter {
- @Inject
- private Logger log;
-
- @Inject
- private ConfigurationService configurationService;
-
/**
* Called by the web container to indicate to a filter that it is being placed into
* service. The servlet container calls the init method exactly once after instantiating the
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPostStartupFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPostStartupFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPostStartupFilter.java
index b7095a5..890f423 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPostStartupFilter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPostStartupFilter.java
@@ -28,6 +28,7 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
import org.apache.marmotta.platform.core.api.config.ConfigurationService;
import org.apache.marmotta.platform.core.events.SystemStartupEvent;
@@ -39,6 +40,7 @@ import org.slf4j.Logger;
* <p/>
* User: sschaffe
*/
+@WebFilter("/*")
public class MarmottaPostStartupFilter implements Filter {
@Inject
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupFilter.java
index f55b96c..438a8f0 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupFilter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupFilter.java
@@ -17,9 +17,7 @@
*/
package org.apache.marmotta.platform.core.servlet;
-import org.apache.marmotta.platform.core.api.config.ConfigurationService;
-import org.apache.marmotta.platform.core.startup.MarmottaStartupService;
-import org.slf4j.Logger;
+import java.io.IOException;
import javax.inject.Inject;
import javax.servlet.Filter;
@@ -28,8 +26,11 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
+
+import org.apache.marmotta.platform.core.startup.MarmottaStartupService;
+import org.slf4j.Logger;
/**
* This filter is evaluated when the Apache Marmotta system is accessed for the very first time using an HTTP client (e.g. a
@@ -43,6 +44,7 @@ import java.io.IOException;
* <p/>
* User: Sebastian Schaffert
*/
+@WebFilter("/*")
public class MarmottaPreStartupFilter implements Filter {
@Inject
@@ -51,9 +53,6 @@ public class MarmottaPreStartupFilter implements Filter {
@Inject
private MarmottaStartupService startupService;
- @Inject
- private ConfigurationService configurationService;
-
private boolean started = false;
/**
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupListener.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupListener.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupListener.java
index 7124578..a9b6a77 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupListener.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaPreStartupListener.java
@@ -17,21 +17,24 @@
*/
package org.apache.marmotta.platform.core.servlet;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.annotation.WebListener;
+
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.FileConfiguration;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.marmotta.platform.core.startup.MarmottaStartupService;
import org.apache.marmotta.platform.core.util.CDIContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
/**
- * This filter is executed first in the startup chain. It initialises the Apache Marmotta system variables if necessary and
- * starts up the configuration service.
+ * This listener is executed first in the startup chain, initializing the Apache
+ * Marmotta system variables if necessary and starting up the configuration service
+ *
+ * @author Sebastian Schaffert
*/
+@WebListener
public class MarmottaPreStartupListener implements ServletContextListener {
private static Logger log = LoggerFactory.getLogger(MarmottaPreStartupListener.class);
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/bcccd8fb/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java
index 2fb635c..7bafd51 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/servlet/MarmottaResourceFilter.java
@@ -31,7 +31,10 @@ import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.annotation.WebInitParam;
import javax.servlet.http.HttpServletRequest;
+
import java.io.IOException;
import java.io.Serializable;
import java.net.URL;
@@ -50,6 +53,7 @@ import java.util.List;
* <p/>
* User: sschaffe
*/
+@WebFilter(value="/*", initParams = { @WebInitParam(name="kiwi.resourceCaching", value="true ") })
public class MarmottaResourceFilter implements Filter {
@Inject
[3/5] git commit: MARMOTTA-196: removed unnecesary configuration (now
defined by annotations) in the webxml files of our launchers
Posted by wi...@apache.org.
MARMOTTA-196: removed unnecesary configuration (now defined by annotations) in the webxml files of our launchers
Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/5ea9649d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/5ea9649d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/5ea9649d
Branch: refs/heads/develop
Commit: 5ea9649d968f2d6cf802e19edcf25ace89f5168f
Parents: bcccd8f
Author: Sergio Fernández <wi...@apache.org>
Authored: Mon Oct 14 15:31:17 2013 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Mon Oct 14 15:31:17 2013 +0200
----------------------------------------------------------------------
.../src/main/webapp/WEB-INF/web.xml | 92 ++++----------------
.../src/main/webapp/WEB-INF/web.xml | 91 ++-----------------
2 files changed, 25 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5ea9649d/launchers/marmotta-webapp-bigdata/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-webapp-bigdata/src/main/webapp/WEB-INF/web.xml b/launchers/marmotta-webapp-bigdata/src/main/webapp/WEB-INF/web.xml
index 6531907..f4d8824 100644
--- a/launchers/marmotta-webapp-bigdata/src/main/webapp/WEB-INF/web.xml
+++ b/launchers/marmotta-webapp-bigdata/src/main/webapp/WEB-INF/web.xml
@@ -18,26 +18,16 @@
limitations under the License.
-->
-<web-app version="2.5"
+<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <!-- enable custom JNDI implementation -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.jndi.MarmottaJndiListener</listener-class>
- </listener>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<!-- enable CDI / Weld for dependency injection -->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
- <!-- Initialise the KiWi system -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupListener</listener-class>
- </listener>
-
<!-- RESTeasy Webservices -->
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
@@ -48,68 +38,42 @@
<param-name>marmotta.home</param-name>
<param-value>/tmp/marmotta</param-value>
</context-param>
-
- <!-- handle OPTIONS requests -->
- <filter>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaOptionsFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- enables a cors filter and maps it to any request -->
+
+ <!-- enables a CORS filter and maps it to any request -->
<!-- for more fine grained configuration have a look at http://software.dzhuvinov.com/cors-filter-configuration.html -->
<filter>
<!-- The CORS filter with parameters -->
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
-
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, PUT, DELETE, OPTIONS</param-value>
</init-param>
-
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Origin, Accept, Content-Type</param-value>
</init-param>
-
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
- <!-- this filter performs startup configurations for first installation -->
- <filter>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- Serve static resources from file system and from .jar files of the respective modules -->
- <filter>
- <filter-name>MarmottaResourceFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter</filter-class>
- <init-param>
- <!-- cache resources loaded from module jar files? -->
- <param-name>kiwi.resourceCaching</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaResourceFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
+
+ <servlet>
+ <servlet-name>H2Console</servlet-name>
+ <servlet-class>org.h2.server.web.WebServlet</servlet-class>
+ <init-param> <param-name>webAllowOthers</param-name> <param-value>true</param-value> </init-param>
+ <!-- <init-param> <param-name>trace</param-name> <param-value></param-value> </init-param> -->
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>H2Console</servlet-name>
+ <url-pattern>/database/*</url-pattern>
+ </servlet-mapping>
<mime-mapping>
+ <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<extension>.xsl</extension>
- <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<mime-type>application/xslt+xml</mime-type>
</mime-mapping>
@@ -117,7 +81,6 @@
<servlet-name>ViewStatusMessages</servlet-name>
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet</servlet-class>
</servlet>
-
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logging/status</url-pattern>
@@ -125,15 +88,12 @@
<filter>
<filter-name>MarmottaWebservices</filter-name>
- <filter-class>
- org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
- </filter-class>
+ <filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.apache.marmotta.platform.core.webservices.CoreApplication</param-value>
</init-param>
</filter>
-
<filter-mapping>
<filter-name>MarmottaWebservices</filter-name>
<url-pattern>/*</url-pattern>
@@ -144,20 +104,4 @@
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
</context-param>
- <!--<context-param>
- <param-name>resteasy.providers</param-name>
- <param-value>org.apache.marmotta.platform.core.filters.CorsInterceptor</param-value>
- </context-param>-->
-
- <filter>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <filter-class>
- org.apache.marmotta.platform.core.servlet.MarmottaPostStartupFilter
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
</web-app>
http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/5ea9649d/launchers/marmotta-webapp/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/launchers/marmotta-webapp/src/main/webapp/WEB-INF/web.xml b/launchers/marmotta-webapp/src/main/webapp/WEB-INF/web.xml
index fd0e8be..f4d8824 100644
--- a/launchers/marmotta-webapp/src/main/webapp/WEB-INF/web.xml
+++ b/launchers/marmotta-webapp/src/main/webapp/WEB-INF/web.xml
@@ -18,26 +18,16 @@
limitations under the License.
-->
-<web-app version="2.5"
+<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-
- <!-- enable custom JNDI implementation -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.jndi.MarmottaJndiListener</listener-class>
- </listener>
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<!-- enable CDI / Weld for dependency injection -->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
- <!-- Initialise the KiWi system -->
- <listener>
- <listener-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupListener</listener-class>
- </listener>
-
<!-- RESTeasy Webservices -->
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
@@ -48,74 +38,27 @@
<param-name>marmotta.home</param-name>
<param-value>/tmp/marmotta</param-value>
</context-param>
-
- <!-- handle OPTIONS requests -->
- <filter>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaOptionsFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaOptionsFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- enables a cors filter and maps it to any request -->
+
+ <!-- enables a CORS filter and maps it to any request -->
<!-- for more fine grained configuration have a look at http://software.dzhuvinov.com/cors-filter-configuration.html -->
<filter>
<!-- The CORS filter with parameters -->
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
-
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, PUT, DELETE, OPTIONS</param-value>
</init-param>
-
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>Origin, Accept, Content-Type</param-value>
</init-param>
-
</filter>
<filter-mapping>
<filter-name>CORS</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
- <!-- this filter performs startup configurations for first installation -->
- <filter>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaPreStartupFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPreStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- Serve static resources from file system and from .jar files of the respective modules -->
- <filter>
- <filter-name>MarmottaResourceFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaResourceFilter</filter-class>
- <init-param>
- <!-- cache resources loaded from module jar files? -->
- <param-name>kiwi.resourceCaching</param-name>
- <param-value>true</param-value>
- </init-param>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaResourceFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
- <!-- H2 Configuration -->
- <filter>
- <filter-name>MarmottaH2ConsoleFilter</filter-name>
- <filter-class>org.apache.marmotta.platform.core.servlet.MarmottaH2ConsoleFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaH2ConsoleFilter</filter-name>
- <url-pattern>/database/*</url-pattern>
- </filter-mapping>
+
<servlet>
<servlet-name>H2Console</servlet-name>
<servlet-class>org.h2.server.web.WebServlet</servlet-class>
@@ -129,8 +72,8 @@
</servlet-mapping>
<mime-mapping>
+ <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<extension>.xsl</extension>
- <!-- per http://www.w3.org/TR/2006/PR-xslt20-20061121/ -->
<mime-type>application/xslt+xml</mime-type>
</mime-mapping>
@@ -138,7 +81,6 @@
<servlet-name>ViewStatusMessages</servlet-name>
<servlet-class>ch.qos.logback.classic.ViewStatusMessagesServlet</servlet-class>
</servlet>
-
<servlet-mapping>
<servlet-name>ViewStatusMessages</servlet-name>
<url-pattern>/logging/status</url-pattern>
@@ -146,15 +88,12 @@
<filter>
<filter-name>MarmottaWebservices</filter-name>
- <filter-class>
- org.jboss.resteasy.plugins.server.servlet.FilterDispatcher
- </filter-class>
+ <filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>org.apache.marmotta.platform.core.webservices.CoreApplication</param-value>
</init-param>
</filter>
-
<filter-mapping>
<filter-name>MarmottaWebservices</filter-name>
<url-pattern>/*</url-pattern>
@@ -165,20 +104,4 @@
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value>
</context-param>
- <!--<context-param>
- <param-name>resteasy.providers</param-name>
- <param-value>org.apache.marmotta.platform.core.filters.CorsInterceptor</param-value>
- </context-param>-->
-
- <filter>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <filter-class>
- org.apache.marmotta.platform.core.servlet.MarmottaPostStartupFilter
- </filter-class>
- </filter>
- <filter-mapping>
- <filter-name>MarmottaPostStartupFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
-
</web-app>