You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2013/12/22 18:48:36 UTC
svn commit: r1553008 - in /jena/branches/jena-fuseki-new-ui: ./ src-dev/dev/
src/main/java/org/apache/jena/fuseki/
src/main/java/org/apache/jena/fuseki/mgt/
src/main/java/org/apache/jena/fuseki/server/
src/main/java/org/apache/jena/fuseki/servlets/ src...
Author: andy
Date: Sun Dec 22 17:48:36 2013
New Revision: 1553008
URL: http://svn.apache.org/r1553008
Log:
Add ContentType constants in WebContent. Use as much as possible.
Added:
jena/branches/jena-fuseki-new-ui/CP
Modified:
jena/branches/jena-fuseki-new-ui/pom.xml
jena/branches/jena-fuseki-new-ui/src-dev/dev/PROJECT.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDescription.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SPARQLServer.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_GSP_RW.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/Upload.java
jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java
jena/branches/jena-fuseki-new-ui/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
Added: jena/branches/jena-fuseki-new-ui/CP
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/CP?rev=1553008&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/CP (added)
+++ jena/branches/jena-fuseki-new-ui/CP Sun Dec 22 17:48:36 2013
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry including="**/*.java" kind="src" path="src/test/java"/>
+ <classpathentry excluding="org/apache/jena/fuseki/fuseki-properties.xml|META-INF/NOTICE|META-INF/LICENSE|META-INF/DEPENDENCIES|**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry including="**/*.java" kind="src" path="src-dev"/>
+
+ <classpathentry kind="var" path="M2_REPO/org/apache/jena/jena-iri/1.0.1-SNAPSHOT/jena-iri-1.0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/apache/jena/jena-iri/1.0.1-SNAPSHOT/jena-iri-1.0.1-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-codec/commons-codec/1.5/commons-codec-1.5.jar" sourcepath="M2_REPO/commons-codec/commons-codec/1.5/commons-codec-1.5-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpclient/4.2.2/httpclient-4.2.2-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/httpcomponents/httpcore/4.2.3/httpcore-4.2.3.jar" sourcepath="M2_REPO/org/apache/httpcomponents/httpcore/4.2.3/httpcore-4.2.3-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.11/junit-4.11.jar" sourcepath="M2_REPO/junit/junit/4.11/junit-4.11-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.jar" sourcepath="M2_REPO/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2-sources.jar"/>
+
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-server/8.1.11.v20130520/jetty-server-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-server/8.1.11.v20130520/jetty-server-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar" sourcepath="M2_REPO/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-continuation/8.1.11.v20130520/jetty-continuation-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-continuation/8.1.11.v20130520/jetty-continuation-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-http/8.1.11.v20130520/jetty-http-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-http/8.1.11.v20130520/jetty-http-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-io/8.1.11.v20130520/jetty-io-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-io/8.1.11.v20130520/jetty-io-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-util/8.1.11.v20130520/jetty-util-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-util/8.1.11.v20130520/jetty-util-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-servlet/8.1.11.v20130520/jetty-servlet-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-servlet/8.1.11.v20130520/jetty-servlet-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-security/8.1.11.v20130520/jetty-security-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-security/8.1.11.v20130520/jetty-security-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-servlets/8.1.11.v20130520/jetty-servlets-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-servlets/8.1.11.v20130520/jetty-servlets-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-client/8.1.11.v20130520/jetty-client-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-client/8.1.11.v20130520/jetty-client-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-xml/8.1.11.v20130520/jetty-xml-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-xml/8.1.11.v20130520/jetty-xml-8.1.11.v20130520-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/eclipse/jetty/jetty-webapp/8.1.11.v20130520/jetty-webapp-8.1.11.v20130520.jar" sourcepath="M2_REPO/org/eclipse/jetty/jetty-webapp/8.1.11.v20130520/jetty-webapp-8.1.11.v20130520-sources.jar"/>
+
+ <classpathentry kind="var" path="M2_REPO/org/apache/velocity/velocity/1.7/velocity-1.7.jar" sourcepath="M2_REPO/org/apache/velocity/velocity/1.7/velocity-1.7-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4.jar" sourcepath="M2_REPO/org/slf4j/jcl-over-slf4j/1.6.4/jcl-over-slf4j-1.6.4-sources.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-arq"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-tdb"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jena-text"/>
+ <classpathentry kind="output" path="classes"/>
+</classpath>
Modified: jena/branches/jena-fuseki-new-ui/pom.xml
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/pom.xml?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/pom.xml (original)
+++ jena/branches/jena-fuseki-new-ui/pom.xml Sun Dec 22 17:48:36 2013
@@ -74,6 +74,8 @@
<assembly.soh.name>${this.root}</assembly.soh.name>
<assembly.zip.name>${this.root}</assembly.zip.name>
+ <!-- Switch to webapp deployment first -->
+ <!--<ver.jetty>9.1.0.v20131115</ver.jetty>-->
<ver.jetty>8.1.11.v20130520</ver.jetty>
<ver.velocity>1.7</ver.velocity>
@@ -155,52 +157,17 @@
<version>${ver.commons-fileupload}</version>
</dependency>
- <!-- ?? Use one of the combined artifacts for Jetty -->
- <!-- jetty-webapp + jetty-util -->
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-server</artifactId>
- <version>${ver.jetty}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>${ver.jetty}</version>
- </dependency>
-
- <!-- used ? - ->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${ver.jetty}</version>
</dependency>
- -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>${ver.jetty}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-xml</artifactId>
- <version>${ver.jetty}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-security</artifactId>
- <version>${ver.jetty}</version>
- </dependency>
-
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>${ver.jetty}</version>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
@@ -275,7 +242,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
<configuration>
<encoding>UTF-8</encoding>
<optimize>true</optimize>
@@ -289,7 +255,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -331,7 +296,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
<configuration>
<includes>
<include>**/TS_*.java</include>
@@ -428,7 +392,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
- <version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
Modified: jena/branches/jena-fuseki-new-ui/src-dev/dev/PROJECT.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src-dev/dev/PROJECT.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src-dev/dev/PROJECT.java (original)
+++ jena/branches/jena-fuseki-new-ui/src-dev/dev/PROJECT.java Sun Dec 22 17:48:36 2013
@@ -19,8 +19,16 @@
package dev;
public class PROJECT {
+
+ // WebConent tidying
+ // SPARQL_Update
+ // DEFs
+
// All TODO and XXX
- // Graph upload in ActionDatasets == Upload.
+ // Configuration and startup.
+ // Change to using a real webapp.
+
+ // WebContent.ctXYZ for each WebContent.contentTypeXYZ
// txn and nonTxn server set up for tests.
@@ -43,6 +51,6 @@ public class PROJECT {
// The whole X_Config thing
// Check compression enabled for UberServlet
- // In-memory system state.
+ // http://localhost:3030/$/optimize
}
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java Sun Dec 22 17:48:36 2013
@@ -24,9 +24,9 @@ import org.apache.jena.riot.WebContent ;
public class DEF
{
- public static final MediaType acceptRDFXML = MediaType.create(WebContent.contentTypeRDFXML) ;
- public static final MediaType acceptNQuads = MediaType.create(WebContent.contentTypeNQuads) ;
- public static final MediaType acceptRSXML = MediaType.create(WebContent.contentTypeResultsXML) ;
+ public static final MediaType acceptRDFXML = MediaType.create(WebContent.contentTypeRDFXML) ;
+ public static final MediaType acceptNQuads = MediaType.create(WebContent.contentTypeNQuads) ;
+ public static final MediaType acceptRSXML = MediaType.create(WebContent.contentTypeResultsXML) ;
private static final MediaType acceptTurtle1 = MediaType.create(WebContent.contentTypeTurtle) ;
private static final MediaType acceptTurtle2 = MediaType.create(WebContent.contentTypeTurtleAlt1) ;
@@ -39,7 +39,6 @@ public class DEF
private static final MediaType acceptRDFJSON = MediaType.create(WebContent.contentTypeRDFJSON) ;
private static final MediaType acceptNQuadsAlt1 = MediaType.create(WebContent.contentTypeNQuadsAlt1) ;
private static final MediaType acceptNQuadsAlt2 = MediaType.create(WebContent.contentTypeNQuadsAlt2) ;
-
public static final AcceptList rdfOffer = AcceptList.create(acceptTurtle1, acceptTurtle2, acceptTurtle3,
acceptNTriples, acceptNTriplesAlt,
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDescription.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDescription.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDescription.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDescription.java Sun Dec 22 17:48:36 2013
@@ -18,6 +18,9 @@
package org.apache.jena.fuseki.mgt;
+import static org.apache.jena.riot.WebContent.charsetUTF8 ;
+import static org.apache.jena.riot.WebContent.contentTypeJSON ;
+
import java.io.IOException ;
import javax.servlet.ServletOutputStream ;
@@ -31,7 +34,6 @@ import org.apache.jena.fuseki.Fuseki ;
import org.apache.jena.fuseki.server.DatasetRegistry ;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.riot.WebContent ;
import org.eclipse.jetty.server.Server ;
/** Description of datasets for a server */
@@ -57,8 +59,8 @@ public class ActionDescription extends A
private void description(HttpAction action) throws IOException {
ServletOutputStream out = action.response.getOutputStream() ;
- action.response.setContentType(WebContent.contentTypeJSON);
- action.response.setCharacterEncoding(WebContent.charsetUTF8) ;
+ action.response.setContentType(contentTypeJSON);
+ action.response.setCharacterEncoding(charsetUTF8) ;
JsonBuilder builder = new JsonBuilder() ;
builder.startObject() ;
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java Sun Dec 22 17:48:36 2013
@@ -31,7 +31,7 @@ import org.apache.jena.atlas.json.* ;
import org.apache.jena.fuseki.server.* ;
import org.apache.jena.fuseki.servlets.HttpAction ;
import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
public class ActionStats extends ActionCtl
{
@@ -56,8 +56,8 @@ public class ActionStats extends ActionC
try {
HttpServletResponse response = action.response ;
ServletOutputStream out = response.getOutputStream() ;
- response.setContentType(WebContent.contentTypeJSON);
- response.setCharacterEncoding(WebContent.charsetUTF8) ;
+ response.setContentType(contentTypeJSON);
+ response.setCharacterEncoding(charsetUTF8) ;
JSON.write(out, v) ;
out.println() ;
out.flush() ;
@@ -143,8 +143,8 @@ public class ActionStats extends ActionC
private void statsTxt(HttpServletResponse resp) throws IOException
{
ServletOutputStream out = resp.getOutputStream() ;
- resp.setContentType(WebContent.contentTypeTextPlain);
- resp.setCharacterEncoding(WebContent.charsetUTF8) ;
+ resp.setContentType(contentTypeTextPlain);
+ resp.setCharacterEncoding(charsetUTF8) ;
Iterator<String> iter = DatasetRegistry.get().keys().iterator() ;
while(iter.hasNext())
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SPARQLServer.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SPARQLServer.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SPARQLServer.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SPARQLServer.java Sun Dec 22 17:48:36 2013
@@ -39,7 +39,7 @@ import org.apache.jena.fuseki.validation
import org.apache.jena.fuseki.validation.IRIValidator ;
import org.apache.jena.fuseki.validation.QueryValidator ;
import org.apache.jena.fuseki.validation.UpdateValidator ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.eclipse.jetty.http.MimeTypes ;
import org.eclipse.jetty.security.* ;
import org.eclipse.jetty.security.authentication.BasicAuthenticator ;
@@ -142,7 +142,6 @@ public class SPARQLServer {
}
public int getPort() {
-
return server.getConnectors()[0].getPort() ;
}
@@ -162,6 +161,11 @@ public class SPARQLServer {
server = configServer(jettyConfig) ;
} else
server = defaultServerConfig(serverConfig.port, serverConfig.loopback) ;
+
+
+// WebAppContext app = new WebAppContext("Fuseki","/") ;
+// server.setHandler(app);
+
// Keep the server to a maximum number of threads.
// server.setThreadPool(new QueuedThreadPool(ThreadPoolSize)) ;
@@ -205,11 +209,11 @@ public class SPARQLServer {
// Constants. Add RDF types.
MimeTypes mt = new MimeTypes() ;
- mt.addMimeMapping("rdf", WebContent.contentTypeRDFXML + ";charset=utf-8") ;
- mt.addMimeMapping("ttl", WebContent.contentTypeTurtle + ";charset=utf-8") ;
- mt.addMimeMapping("nt", WebContent.contentTypeNTriples + ";charset=ascii") ;
- mt.addMimeMapping("nq", WebContent.contentTypeNQuads + ";charset=ascii") ;
- mt.addMimeMapping("trig", WebContent.contentTypeTriG + ";charset=utf-8") ;
+ mt.addMimeMapping("rdf", contentTypeRDFXML + ";charset=utf-8") ;
+ mt.addMimeMapping("ttl", contentTypeTurtle + ";charset=utf-8") ;
+ mt.addMimeMapping("nt", contentTypeNTriples + ";charset=utf-8") ;
+ mt.addMimeMapping("nq", contentTypeNQuads + ";charset=utf-8") ;
+ mt.addMimeMapping("trig", contentTypeTriG + ";charset=utf-8") ;
// mt.addMimeMapping("tpl", "text/html;charset=utf-8") ;
context.setMimeTypes(mt) ;
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java Sun Dec 22 17:48:36 2013
@@ -20,11 +20,8 @@ package org.apache.jena.fuseki.servlets;
import javax.servlet.http.HttpServletRequest ;
-import org.apache.jena.atlas.web.ContentType ;
-import org.apache.jena.fuseki.FusekiLib ;
import org.apache.jena.fuseki.server.DatasetRef ;
import org.apache.jena.fuseki.server.DatasetRegistry ;
-import org.apache.jena.riot.WebContent ;
/** Operations related to servlets */
@@ -134,12 +131,5 @@ public class ActionLib {
//log.info("removeContext: uri = "+uri+" contextPath="+contextPath+ "--> x="+x) ;
return x ;
}
-
- public static boolean isHTMLForm(HttpAction action ) {
- ContentType ct = FusekiLib.getContentType(action) ;
- String incoming = ct.getContentType() ;
- return WebContent.contentTypeForm.equalsIgnoreCase(incoming) ;
- }
-
}
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java Sun Dec 22 17:48:36 2013
@@ -33,7 +33,7 @@ import org.apache.jena.fuseki.conneg.Web
import org.apache.jena.riot.Lang ;
import org.apache.jena.riot.RDFDataMgr ;
import org.apache.jena.riot.RDFLanguages ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.web.HttpSC ;
import com.hp.hpl.jena.rdf.model.Model ;
@@ -51,11 +51,11 @@ public class ResponseModel
static {
// Some short names. keys are lowercase.
- ResponseOps.put(shortNamesModel, contentOutputJSON, WebContent.contentTypeRDFJSON) ;
- ResponseOps.put(shortNamesModel, contentOutputXML, WebContent.contentTypeRDFXML) ;
- ResponseOps.put(shortNamesModel, contentOutputText, WebContent.contentTypeTurtle) ;
- ResponseOps.put(shortNamesModel, contentOutputTTL, WebContent.contentTypeTurtle) ;
- ResponseOps.put(shortNamesModel, contentOutputNT, WebContent.contentTypeNTriples) ;
+ ResponseOps.put(shortNamesModel, contentOutputJSON, contentTypeRDFJSON) ;
+ ResponseOps.put(shortNamesModel, contentOutputXML, contentTypeRDFXML) ;
+ ResponseOps.put(shortNamesModel, contentOutputText, contentTypeTurtle) ;
+ ResponseOps.put(shortNamesModel, contentOutputTTL, contentTypeTurtle) ;
+ ResponseOps.put(shortNamesModel, contentOutputNT, contentTypeNTriples) ;
}
public static void doResponseModel(HttpAction action, Model model)
@@ -89,13 +89,13 @@ public class ResponseModel
}
String contentType = mimeType ;
- String charset = WebContent.charsetUTF8 ;
+ String charset = charsetUTF8 ;
String forceAccept = ResponseOps.paramForceAccept(request) ;
if ( forceAccept != null )
{
contentType = forceAccept ;
- charset = WebContent.charsetUTF8 ;
+ charset = charsetUTF8 ;
}
Lang lang = RDFLanguages.contentTypeToLang(contentType) ;
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java Sun Dec 22 17:48:36 2013
@@ -35,7 +35,7 @@ import org.apache.jena.atlas.web.MediaTy
import org.apache.jena.fuseki.DEF ;
import org.apache.jena.fuseki.FusekiException ;
import org.apache.jena.fuseki.conneg.ConNeg ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.web.HttpSC ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
@@ -61,12 +61,12 @@ public class ResponseResultSet
public static Map<String,String> shortNamesResultSet = new HashMap<String, String>() ;
static {
// Some short names. keys are lowercase.
- ResponseOps.put(shortNamesResultSet, contentOutputJSON, WebContent.contentTypeResultsJSON) ;
- ResponseOps.put(shortNamesResultSet, contentOutputSPARQL, WebContent.contentTypeResultsXML) ;
- ResponseOps.put(shortNamesResultSet, contentOutputXML, WebContent.contentTypeResultsXML) ;
- ResponseOps.put(shortNamesResultSet, contentOutputText, WebContent.contentTypeTextPlain) ;
- ResponseOps.put(shortNamesResultSet, contentOutputCSV, WebContent.contentTypeTextCSV) ;
- ResponseOps.put(shortNamesResultSet, contentOutputTSV, WebContent.contentTypeTextTSV) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputJSON, contentTypeResultsJSON) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputSPARQL, contentTypeResultsXML) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputXML, contentTypeResultsXML) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputText, contentTypeTextPlain) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputCSV, contentTypeTextCSV) ;
+ ResponseOps.put(shortNamesResultSet, contentOutputTSV, contentTypeTextTSV) ;
}
interface OutputContent { void output(ServletOutputStream out) ; }
@@ -124,24 +124,24 @@ public class ResponseResultSet
// Stylesheet - change to application/xml.
final String stylesheetURL = ResponseOps.paramStylesheet(request) ;
- if ( stylesheetURL != null && equal(serializationType,WebContent.contentTypeResultsXML) )
- contentType = WebContent.contentTypeXML ;
+ if ( stylesheetURL != null && equal(serializationType,contentTypeResultsXML) )
+ contentType = contentTypeXML ;
// Force to text/plain?
String forceAccept = ResponseOps.paramForceAccept(request) ;
if ( forceAccept != null )
- contentType = WebContent.contentTypeTextPlain ;
+ contentType = contentTypeTextPlain ;
// Better : dispatch on MediaType
- if ( equal(serializationType, WebContent.contentTypeResultsXML) )
+ if ( equal(serializationType, contentTypeResultsXML) )
sparqlXMLOutput(action, contentType, resultSet, stylesheetURL, booleanResult) ;
- else if ( equal(serializationType, WebContent.contentTypeResultsJSON) )
+ else if ( equal(serializationType, contentTypeResultsJSON) )
jsonOutput(action, contentType, resultSet, booleanResult) ;
- else if ( equal(serializationType, WebContent.contentTypeTextPlain) )
+ else if ( equal(serializationType, contentTypeTextPlain) )
textOutput(action, contentType, resultSet, qPrologue, booleanResult) ;
- else if ( equal(serializationType, WebContent.contentTypeTextCSV) )
+ else if ( equal(serializationType, contentTypeTextCSV) )
csvOutput(action, contentType, resultSet, booleanResult) ;
- else if (equal(serializationType, WebContent.contentTypeTextTSV) )
+ else if (equal(serializationType, contentTypeTextTSV) )
tsvOutput(action, contentType, resultSet, booleanResult) ;
else
ServletOps.errorBadRequest("Can't determine output serialization: "+serializationType) ;
@@ -172,9 +172,9 @@ public class ResponseResultSet
private static boolean isXML(String contentType)
{
- return contentType.equals(WebContent.contentTypeRDFXML)
- || contentType.equals(WebContent.contentTypeResultsXML)
- || contentType.equals(WebContent.contentTypeXML) ;
+ return contentType.equals(contentTypeRDFXML)
+ || contentType.equals(contentTypeResultsXML)
+ || contentType.equals(contentTypeXML) ;
}
private static void sparqlXMLOutput(HttpAction action, String contentType, final ResultSet resultSet, final String stylesheetURL, final Boolean booleanResult)
@@ -217,7 +217,7 @@ public class ResponseResultSet
out.println("(") ;
}
- output(action, contentType, WebContent.charsetUTF8, proc) ;
+ output(action, contentType, charsetUTF8, proc) ;
if ( callback != null )
out.println(")") ;
@@ -238,7 +238,7 @@ public class ResponseResultSet
}
};
- output(action, contentType, WebContent.charsetUTF8, proc) ;
+ output(action, contentType, charsetUTF8, proc) ;
}
private static void csvOutput(HttpAction action, String contentType, final ResultSet resultSet, final Boolean booleanResult) {
@@ -252,7 +252,7 @@ public class ResponseResultSet
ResultSetFormatter.outputAsCSV(out, booleanResult.booleanValue()) ;
}
} ;
- output(action, contentType, WebContent.charsetUTF8, proc) ;
+ output(action, contentType, charsetUTF8, proc) ;
}
private static void tsvOutput(HttpAction action, String contentType, final ResultSet resultSet, final Boolean booleanResult) {
@@ -266,7 +266,7 @@ public class ResponseResultSet
ResultSetFormatter.outputAsTSV(out, booleanResult.booleanValue()) ;
}
} ;
- output(action, contentType, WebContent.charsetUTF8, proc) ;
+ output(action, contentType, charsetUTF8, proc) ;
}
private static void output(HttpAction action, String contentType, String charset, OutputContent proc)
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_GSP_RW.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_GSP_RW.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_GSP_RW.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_GSP_RW.java Sun Dec 22 17:48:36 2013
@@ -22,7 +22,7 @@ import org.apache.jena.atlas.web.Content
import org.apache.jena.fuseki.FusekiLib ;
import org.apache.jena.fuseki.HttpNames ;
import org.apache.jena.riot.RiotException ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.riot.system.StreamRDF ;
import org.apache.jena.riot.system.StreamRDFLib ;
import org.apache.jena.web.HttpSC ;
@@ -77,7 +77,7 @@ public class SPARQL_GSP_RW extends SPARQ
if ( ct == null )
ServletOps.errorBadRequest("No Content-Type:") ;
- if ( WebContent.contentTypeMultiMixed.equals(ct.getContentType()) ) {
+ if ( matchContentType(ctMultipartMixed, ct) ) {
ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "multipart/mixed not supported") ;
}
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java Sun Dec 22 17:48:36 2013
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.apache.jena.fuseki.servlets;
+package org.apache.jena.fuseki.servlets ;
import static java.lang.String.format ;
import static org.apache.jena.fuseki.HttpNames.* ;
@@ -37,7 +37,7 @@ import org.apache.jena.atlas.web.Content
import org.apache.jena.fuseki.FusekiException ;
import org.apache.jena.fuseki.FusekiLib ;
import org.apache.jena.fuseki.HttpNames ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.riot.web.HttpOp ;
import org.apache.jena.web.HttpSC ;
@@ -46,37 +46,37 @@ import com.hp.hpl.jena.rdf.model.Model ;
import com.hp.hpl.jena.sparql.core.Prologue ;
import com.hp.hpl.jena.sparql.resultset.SPARQLResult ;
-public abstract class SPARQL_Query extends SPARQL_Protocol
-{
- public SPARQL_Query() { super() ; }
+public abstract class SPARQL_Query extends SPARQL_Protocol {
+ public SPARQL_Query() {
+ super() ;
+ }
// Choose REST verbs to support.
-
+
@Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- { doCommon(request, response) ; }
-
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) {
+ doCommon(request, response) ;
+ }
+
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- { doCommon(request, response) ; }
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) {
+ doCommon(request, response) ;
+ }
// HEAD
-
+
@Override
- protected void doOptions(HttpServletRequest request, HttpServletResponse response)
- {
- //response.setHeader(HttpNames.hAllow, "GET,HEAD,OPTIONS,POST");
+ protected void doOptions(HttpServletRequest request, HttpServletResponse response) {
+ // response.setHeader(HttpNames.hAllow, "GET,HEAD,OPTIONS,POST");
setCommonHeaders(response) ;
- response.setHeader(HttpNames.hAllow, "GET,OPTIONS,POST");
+ response.setHeader(HttpNames.hAllow, "GET,OPTIONS,POST") ;
response.setHeader(HttpNames.hContentLengh, "0") ;
}
-
+
@Override
- protected final void perform(HttpAction action)
- {
+ protected final void perform(HttpAction action) {
// GET
- if ( action.request.getMethod().equals(HttpNames.METHOD_GET) )
- {
+ if ( action.request.getMethod().equals(HttpNames.METHOD_GET) ) {
executeWithParameter(action) ;
return ;
}
@@ -84,136 +84,120 @@ public abstract class SPARQL_Query exten
ContentType ct = FusekiLib.getContentType(action) ;
String incoming = ct.getContentType() ;
- // POST application/sparql-query
- if ( WebContent.isHtmlForm(ct) )
- {
- executeBody(action) ;
- return ;
- }
// POST application/x-www-form-url
- if (ActionLib.isHTMLForm(action) )
- {
+ if ( isHtmlForm(ct) ) {
executeWithParameter(action) ;
return ;
}
- ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Bad content type: "+incoming) ;
+ // POST application/sparql-query
+ if ( matchContentType(ct, ctSPARQLQuery) ) {
+ executeBody(action) ;
+ return ;
+ }
+
+ ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Bad content type: " + incoming) ;
}
// All the params we support
- protected static List<String> allParams = Arrays.asList(paramQuery,
- paramDefaultGraphURI, paramNamedGraphURI,
- paramQueryRef,
- paramStyleSheet,
- paramAccept,
- paramOutput1, paramOutput2,
- paramCallback,
- paramForceAccept,
- paramTimeout) ;
-
+ protected static List<String> allParams = Arrays.asList(paramQuery, paramDefaultGraphURI, paramNamedGraphURI,
+ paramQueryRef, paramStyleSheet, paramAccept, paramOutput1,
+ paramOutput2, paramCallback, paramForceAccept, paramTimeout) ;
+
/** Called to validate arguments */
@Override
- protected void validate(HttpAction action)
- {
+ protected void validate(HttpAction action) {
String method = action.request.getMethod().toUpperCase(Locale.ROOT) ;
-
- if ( ! HttpNames.METHOD_POST.equals(method) && ! HttpNames.METHOD_GET.equals(method) )
+
+ if ( !HttpNames.METHOD_POST.equals(method) && !HttpNames.METHOD_GET.equals(method) )
ServletOps.errorMethodNotAllowed("Not a GET or POST request") ;
-
- if ( HttpNames.METHOD_GET.equals(method) && action.request.getQueryString() == null )
- {
- ServletOps.warning(action, "Service Description / SPARQL Query / "+action.request.getRequestURI()) ;
- ServletOps.errorNotFound("Service Description: "+action.request.getRequestURI()) ;
+
+ if ( HttpNames.METHOD_GET.equals(method) && action.request.getQueryString() == null ) {
+ ServletOps.warning(action, "Service Description / SPARQL Query / " + action.request.getRequestURI()) ;
+ ServletOps.errorNotFound("Service Description: " + action.request.getRequestURI()) ;
}
-
+
// Use of the dataset describing parameters is check later.
try {
validateParams(action, allParams) ;
- validateRequest(action) ;
- } catch (ActionErrorException ex) {
- throw ex ;
- }
+ validateRequest(action) ;
+ } catch (ActionErrorException ex) {
+ throw ex ;
+ }
// Query not yet parsed.
}
-
- /** Validate the request after checking HTTP method and HTTP Parameters */
+
+ /** Validate the request after checking HTTP method and HTTP Parameters */
protected abstract void validateRequest(HttpAction action) ;
-
+
/** Helper for validating request */
- protected void validateParams(HttpAction action, Collection<String> params)
- {
+ protected void validateParams(HttpAction action, Collection<String> params) {
HttpServletRequest request = action.request ;
ContentType ct = FusekiLib.getContentType(request) ;
boolean mustHaveQueryParam = true ;
- if ( ct != null )
- {
+ if ( ct != null ) {
String incoming = ct.getContentType() ;
-
- if ( WebContent.contentTypeSPARQLQuery.equals(incoming) )
- {
+
+ if ( matchContentType(ctSPARQLQuery, ct) ) {
mustHaveQueryParam = false ;
- //error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Unofficial "+WebContent.contentTypeSPARQLQuery+" not supported") ;
- }
- else if ( WebContent.contentTypeForm.equals(incoming) ) {}
+ } else if ( matchContentType(ctHTMLForm, ct))
+ {}
else
- ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Unsupported: "+incoming) ;
+ ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Unsupported: " + incoming) ;
}
-
+
// GET/POST of a form at this point.
-
- if ( mustHaveQueryParam )
- {
- int N = countParamOccurences(request, paramQuery) ;
-
- if ( N == 0 ) ServletOps.errorBadRequest("SPARQL Query: No 'query=' parameter") ;
- if ( N > 1 ) ServletOps.errorBadRequest("SPARQL Query: Multiple 'query=' parameters") ;
-
+
+ if ( mustHaveQueryParam ) {
+ int N = countParamOccurences(request, paramQuery) ;
+
+ if ( N == 0 )
+ ServletOps.errorBadRequest("SPARQL Query: No 'query=' parameter") ;
+ if ( N > 1 )
+ ServletOps.errorBadRequest("SPARQL Query: Multiple 'query=' parameters") ;
+
// application/sparql-query does not use a query param.
String queryStr = request.getParameter(HttpNames.paramQuery) ;
-
+
if ( queryStr == null )
ServletOps.errorBadRequest("SPARQL Query: No query specified (no 'query=' found)") ;
if ( queryStr.isEmpty() )
ServletOps.errorBadRequest("SPARQL Query: Empty query string") ;
}
- if ( params != null )
- {
+ if ( params != null ) {
Enumeration<String> en = request.getParameterNames() ;
- for ( ; en.hasMoreElements() ; )
- {
+ for (; en.hasMoreElements();) {
String name = en.nextElement() ;
- if ( ! params.contains(name) )
- ServletOps.warning(action, "SPARQL Query: Unrecognize request parameter (ignored): "+name) ;
+ if ( !params.contains(name) )
+ ServletOps.warning(action, "SPARQL Query: Unrecognize request parameter (ignored): " + name) ;
}
}
}
- private void executeWithParameter(HttpAction action)
- {
+ private void executeWithParameter(HttpAction action) {
String queryString = action.request.getParameter(paramQuery) ;
execute(queryString, action) ;
}
- private void executeBody(HttpAction action)
- {
+ private void executeBody(HttpAction action) {
String queryString = null ;
- try {
- InputStream input = action.request.getInputStream() ;
+ try {
+ InputStream input = action.request.getInputStream() ;
queryString = IO.readWholeFileAsUTF8(input) ;
+ } catch (IOException ex) {
+ ServletOps.errorOccurred(ex) ;
}
- catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
execute(queryString, action) ;
}
- private void execute(String queryString, HttpAction action)
- {
+ private void execute(String queryString, HttpAction action) {
String queryStringLog = ServletOps.formatForLog(queryString) ;
if ( action.verbose )
- action.log.info(format("[%d] Query = \n%s", action.id, queryString));
+ action.log.info(format("[%d] Query = \n%s", action.id, queryString)) ;
else
- action.log.info(format("[%d] Query = %s", action.id, queryStringLog));
+ action.log.info(format("[%d] Query = %s", action.id, queryStringLog)) ;
Query query = null ;
try {
@@ -232,119 +216,116 @@ public abstract class SPARQL_Query exten
catch (QueryException ex) {
ServletOps.errorBadRequest("Error: \n" + queryString + "\n\r" + ex.getMessage()) ;
}
-
- // Assumes finished whole thing by end of sendResult.
+
+ // Assumes finished whole thing by end of sendResult.
action.beginRead() ;
QueryExecution qExec = null ;
try {
- Dataset dataset = decideDataset(action, query, queryStringLog) ;
+ Dataset dataset = decideDataset(action, query, queryStringLog) ;
qExec = createQueryExecution(query, dataset) ;
SPARQLResult result = executeQuery(action, qExec, query, queryStringLog) ;
-
+
// Deals with exceptions itself.
sendResults(action, result, query.getPrologue()) ;
} catch (QueryCancelledException ex) {
// Additional counter information.
- incCounter(action.srvRef, QueryTimeouts) ;
- throw ex ;
- } catch (QueryExecException ex) {
+ incCounter(action.srvRef, QueryTimeouts) ;
+ throw ex ;
+ } catch (QueryExecException ex) {
// Additional counter information.
- incCounter(action.srvRef, QueryExecErrors) ;
- throw ex ;
- } finally {
+ incCounter(action.srvRef, QueryExecErrors) ;
+ throw ex ;
+ } finally {
if ( qExec != null )
qExec.close() ;
action.endRead() ;
}
}
- /** Check the query - if unacceptable, throw ActionErrorException or call super.error */
+ /**
+ * Check the query - if unacceptable, throw ActionErrorException or call
+ * super.error
+ */
protected abstract void validateQuery(HttpAction action, Query query) ;
- protected QueryExecution createQueryExecution(Query query, Dataset dataset)
- {
+ protected QueryExecution createQueryExecution(Query query, Dataset dataset) {
return QueryExecutionFactory.create(query, dataset) ;
}
- protected SPARQLResult executeQuery(HttpAction action, QueryExecution qExec, Query query, String queryStringLog)
- {
- setAnyTimeouts(qExec, action);
+ protected SPARQLResult executeQuery(HttpAction action, QueryExecution qExec, Query query, String queryStringLog) {
+ setAnyTimeouts(qExec, action) ;
- if ( query.isSelectType() )
- {
+ if ( query.isSelectType() ) {
ResultSet rs = qExec.execSelect() ;
-
+
// Force some query execution now.
//
- // If the timeout-first-row goes off, the output stream has not
- // been started so the HTTP error code is sent.
-
+ // If the timeout-first-row goes off, the output stream has not
+ // been started so the HTTP error code is sent.
+
rs.hasNext() ;
- // If we wanted perfect query time cancellation, we could consume the result now
- // to see if the timeout-end-of-query goes off.
-
- //rs = ResultSetFactory.copyResults(rs) ;
+ // If we wanted perfect query time cancellation, we could consume
+ // the result now
+ // to see if the timeout-end-of-query goes off.
+
+ // rs = ResultSetFactory.copyResults(rs) ;
action.log.info(format("[%d] exec/select", action.id)) ;
return new SPARQLResult(rs) ;
}
- if ( query.isConstructType() )
- {
+ if ( query.isConstructType() ) {
Model model = qExec.execConstruct() ;
action.log.info(format("[%d] exec/construct", action.id)) ;
return new SPARQLResult(model) ;
}
- if ( query.isDescribeType() )
- {
+ if ( query.isDescribeType() ) {
Model model = qExec.execDescribe() ;
- action.log.info(format("[%d] exec/describe",action.id)) ;
+ action.log.info(format("[%d] exec/describe", action.id)) ;
return new SPARQLResult(model) ;
}
- if ( query.isAskType() )
- {
+ if ( query.isAskType() ) {
boolean b = qExec.execAsk() ;
- action.log.info(format("[%d] exec/ask",action.id)) ;
+ action.log.info(format("[%d] exec/ask", action.id)) ;
return new SPARQLResult(b) ;
}
- ServletOps.errorBadRequest("Unknown query type - "+queryStringLog) ;
+ ServletOps.errorBadRequest("Unknown query type - " + queryStringLog) ;
return null ;
}
private void setAnyTimeouts(QueryExecution qexec, HttpAction action) {
- if (!(action.getDatasetRef().allowTimeoutOverride))
- return;
+ if ( !(action.getDatasetRef().allowTimeoutOverride) )
+ return ;
- long desiredTimeout = Long.MAX_VALUE;
- String timeoutHeader = action.request.getHeader("Timeout");
- String timeoutParameter = action.request.getParameter("timeout");
- if (timeoutHeader != null) {
+ long desiredTimeout = Long.MAX_VALUE ;
+ String timeoutHeader = action.request.getHeader("Timeout") ;
+ String timeoutParameter = action.request.getParameter("timeout") ;
+ if ( timeoutHeader != null ) {
try {
- desiredTimeout = (int) Float.parseFloat(timeoutHeader) * 1000;
+ desiredTimeout = (int)Float.parseFloat(timeoutHeader) * 1000 ;
} catch (NumberFormatException e) {
- throw new FusekiException("Timeout header must be a number", e);
+ throw new FusekiException("Timeout header must be a number", e) ;
}
- } else if (timeoutParameter != null) {
+ } else if ( timeoutParameter != null ) {
try {
- desiredTimeout = (int) Float.parseFloat(timeoutParameter) * 1000;
+ desiredTimeout = (int)Float.parseFloat(timeoutParameter) * 1000 ;
} catch (NumberFormatException e) {
- throw new FusekiException("timeout parameter must be a number", e);
+ throw new FusekiException("timeout parameter must be a number", e) ;
}
}
- desiredTimeout = Math.min(action.getDatasetRef().maximumTimeoutOverride, desiredTimeout);
- if (desiredTimeout != Long.MAX_VALUE)
- qexec.setTimeout(desiredTimeout);
+ desiredTimeout = Math.min(action.getDatasetRef().maximumTimeoutOverride, desiredTimeout) ;
+ if ( desiredTimeout != Long.MAX_VALUE )
+ qexec.setTimeout(desiredTimeout) ;
}
protected abstract Dataset decideDataset(HttpAction action, Query query, String queryStringLog) ;
- protected void sendResults(HttpAction action, SPARQLResult result, Prologue qPrologue)
- {
+ protected void sendResults(HttpAction action, SPARQLResult result, Prologue qPrologue) {
if ( result.isResultSet() )
ResponseResultSet.doResponseResultSet(action, result.getResultSet(), qPrologue) ;
else if ( result.isGraph() )
@@ -354,17 +335,15 @@ public abstract class SPARQL_Query exten
else
ServletOps.errorOccurred("Unknown or invalid result type") ;
}
-
- private String formatForLog(Query query)
- {
+
+ private String formatForLog(Query query) {
IndentedLineBuffer out = new IndentedLineBuffer() ;
out.setFlatMode(true) ;
query.serialize(out) ;
return out.asString() ;
}
-
- private String getRemoteString(String queryURI)
- {
+
+ private String getRemoteString(String queryURI) {
return HttpOp.execHttpGetString(queryURI) ;
}
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java Sun Dec 22 17:48:36 2013
@@ -32,7 +32,7 @@ import org.apache.jena.fuseki.HttpNames
import org.apache.jena.fuseki.conneg.ConNeg ;
import org.apache.jena.fuseki.server.DatasetRef ;
import org.apache.jena.fuseki.server.ServiceRef ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.web.HttpSC ;
/** This servlet can be attached to a dataset location
@@ -155,7 +155,6 @@ public abstract class SPARQL_UberServlet
boolean hasParamUpdate = request.getParameter(HttpNames.paramUpdate) != null || request.getParameter(HttpNames.paramRequest) != null ;
boolean hasParamGraph = request.getParameter(HttpNames.paramGraph) != null ;
boolean hasParamGraphDefault = request.getParameter(HttpNames.paramGraphDefault) != null ;
- boolean isForm = WebContent.contentTypeForm.equalsIgnoreCase(request.getContentType()) ;
String ct = request.getContentType() ;
String charset = request.getCharacterEncoding() ;
@@ -180,7 +179,7 @@ public abstract class SPARQL_UberServlet
if ( ! hasTrailing )
{
// Has params of some kind.
- if ( hasParamQuery || WebContent.contentTypeSPARQLQuery.equalsIgnoreCase(ct) )
+ if ( hasParamQuery || contentTypeSPARQLQuery.equalsIgnoreCase(ct) )
{
// SPARQL Query
if ( ! allowQuery(action))
@@ -189,7 +188,7 @@ public abstract class SPARQL_UberServlet
return ;
}
- if ( hasParamUpdate || WebContent.contentTypeSPARQLUpdate.equalsIgnoreCase(ct) )
+ if ( hasParamUpdate || contentTypeSPARQLUpdate.equalsIgnoreCase(ct) )
{
// SPARQL Update
if ( ! allowQuery(action))
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java Sun Dec 22 17:48:36 2013
@@ -44,7 +44,7 @@ import org.apache.jena.atlas.web.Content
import org.apache.jena.fuseki.FusekiLib ;
import org.apache.jena.fuseki.HttpNames ;
import org.apache.jena.iri.IRI ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.riot.system.IRIResolver ;
import org.apache.jena.web.HttpSC ;
@@ -96,17 +96,17 @@ public class SPARQL_Update extends SPARQ
{
ContentType ct = FusekiLib.getContentType(action) ;
if ( ct == null )
- ctStr = WebContent.contentTypeSPARQLUpdate ;
+ ctStr = contentTypeSPARQLUpdate ;
else
ctStr = ct.getContentType() ;
}
- if (WebContent.contentTypeSPARQLUpdate.equals(ctStr))
+ if (contentTypeSPARQLUpdate.equals(ctStr))
{
executeBody(action) ;
return ;
}
- if (WebContent.contentTypeForm.equals(ctStr))
+ if (contentTypeHTMLForm.equals(ctStr))
{
executeForm(action) ;
return ;
@@ -127,19 +127,19 @@ public class SPARQL_Update extends SPARQ
ServletOps.errorMethodNotAllowed("SPARQL Update : use POST") ;
ContentType incoming = FusekiLib.getContentType(action) ;
- String ctStr = ( incoming == null ) ? WebContent.contentTypeSPARQLUpdate : incoming.getContentType() ;
+ String ctStr = ( incoming == null ) ? contentTypeSPARQLUpdate : incoming.getContentType() ;
// ----
- if ( WebContent.contentTypeSPARQLUpdate.equals(ctStr) )
+ if ( contentTypeSPARQLUpdate.equals(ctStr) )
{
String charset = request.getCharacterEncoding() ;
- if ( charset != null && ! charset.equalsIgnoreCase(WebContent.charsetUTF8) )
+ if ( charset != null && ! charset.equalsIgnoreCase(charsetUTF8) )
ServletOps.errorBadRequest("Bad charset: "+charset) ;
validate(action, paramsPOST) ;
return ;
}
- if ( WebContent.contentTypeForm.equals(ctStr) )
+ if ( contentTypeHTMLForm.equals(ctStr) )
{
int x = countParamOccurences(request, paramUpdate) + countParamOccurences(request, paramRequest) ;
if ( x == 0 )
@@ -156,7 +156,7 @@ public class SPARQL_Update extends SPARQ
return ;
}
- ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Must be "+WebContent.contentTypeSPARQLUpdate+" or "+WebContent.contentTypeForm+" (got "+ctStr+")") ;
+ ServletOps.error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Must be "+contentTypeSPARQLUpdate+" or "+contentTypeHTMLForm+" (got "+ctStr+")") ;
}
protected void validate(HttpAction action, Collection<String> params)
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/Upload.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/Upload.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/Upload.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/Upload.java Sun Dec 22 17:48:36 2013
@@ -19,6 +19,8 @@
package org.apache.jena.fuseki.servlets;
import static java.lang.String.format ;
+import static org.apache.jena.riot.WebContent.ctMultipartFormData ;
+import static org.apache.jena.riot.WebContent.matchContentType ;
import java.io.IOException ;
import java.io.InputStream ;
@@ -30,7 +32,10 @@ import org.apache.commons.fileupload.ser
import org.apache.jena.atlas.io.IO ;
import org.apache.jena.atlas.web.ContentType ;
import org.apache.jena.fuseki.FusekiLib ;
-import org.apache.jena.riot.* ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RDFLanguages ;
+import org.apache.jena.riot.RiotParseException ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.riot.lang.StreamRDFCounting ;
import org.apache.jena.riot.system.StreamRDF ;
import org.apache.jena.riot.system.StreamRDFLib ;
@@ -39,7 +44,7 @@ public class Upload {
public static void incomingData(HttpAction action, StreamRDF dest, boolean isGraph) {
ContentType ct = FusekiLib.getContentType(action) ;
- if ( WebContent.contentTypeMultipartFormData.equalsIgnoreCase(ct.getContentType()) ) {
+ if ( matchContentType(ctMultipartFormData, ct) ) {
fileUploadWorker(action, dest, isGraph) ;
return ;
}
@@ -95,7 +100,7 @@ public class Upload {
String contentTypeHeader = fileStream.getContentType() ;
ContentType ct = ContentType.create(contentTypeHeader) ;
Lang lang = null ;
- if ( ! WebContent.contentTypeTextPlain.equals(ct.getContentType()) )
+ if ( ! matchContentType(ctTextPlain, ct) )
lang = RDFLanguages.contentTypeToLang(ct.getContentType()) ;
if ( lang == null ) {
Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java Sun Dec 22 17:48:36 2013
@@ -34,7 +34,7 @@ import org.apache.jena.fuseki.servlets.A
import org.apache.jena.fuseki.servlets.ActionLib ;
import org.apache.jena.fuseki.servlets.ServletBase ;
import org.apache.jena.fuseki.servlets.ServletOps ;
-import org.apache.jena.riot.WebContent ;
+import static org.apache.jena.riot.WebContent.* ;
import org.apache.jena.web.HttpSC ;
import org.slf4j.Logger ;
@@ -77,8 +77,8 @@ public abstract class ValidatorBaseJson
JsonObject obj = execute(action) ;
action.statusCode = HttpSC.OK_200 ;
action.message = "OK" ;
- response.setCharacterEncoding(WebContent.charsetUTF8);
- response.setContentType(WebContent.contentTypeJSON);
+ response.setCharacterEncoding(charsetUTF8);
+ response.setContentType(contentTypeJSON);
//response.setContentType(WebContent.contentTypeTextPlain);
action.response.setStatus(HttpSC.OK_200) ;
OutputStream out = response.getOutputStream() ;
@@ -164,8 +164,8 @@ public abstract class ValidatorBaseJson
protected void setHeaders(HttpServletResponse httpResponse)
{
- httpResponse.setCharacterEncoding(WebContent.charsetUTF8) ;
- httpResponse.setContentType(WebContent.contentTypeJSON) ;
+ httpResponse.setCharacterEncoding(charsetUTF8) ;
+ httpResponse.setContentType(contentTypeJSON) ;
httpResponse.setHeader(respService, "Jena Fuseki Validator / "+validatorName()+": http://jena.apache.org/") ;
}
Modified: jena/branches/jena-fuseki-new-ui/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java?rev=1553008&r1=1553007&r2=1553008&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/test/java/org/apache/jena/fuseki/TS_Fuseki.java Sun Dec 22 17:48:36 2013
@@ -40,6 +40,7 @@ import org.junit.runners.Suite ;
, TestAuth.class
, TestDatasetOps.class
, TestFileUpload.class
+ , TestAdmin.class
})
public class TS_Fuseki extends ServerTest
{