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 2017/12/17 19:33:41 UTC
[09/28] jena git commit: JENA-1435: Refactoring, renaming,
and clearing up
JENA-1435: Refactoring, renaming, and clearing up
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/1533ade6
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/1533ade6
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/1533ade6
Branch: refs/heads/master
Commit: 1533ade629199625e9f74b2240e2c18c5f5b5e35
Parents: 5ec56a6
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Nov 24 17:14:34 2017 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Mon Dec 11 14:56:08 2017 +0000
----------------------------------------------------------------------
.../apache/jena/fuseki/cmds/FusekiBasicCmd.java | 4 +-
.../apache/jena/fuseki/build/FusekiBuilder.java | 64 ++-
.../org/apache/jena/fuseki/mgt/ActionStats.java | 36 +-
.../apache/jena/fuseki/mgt/JsonDescription.java | 14 +-
.../org/apache/jena/fuseki/package-info.java | 61 ++
.../fuseki/server/DataAccessPointRegistry.java | 6 +-
.../apache/jena/fuseki/server/DataService.java | 22 +-
.../org/apache/jena/fuseki/server/Endpoint.java | 16 +-
.../apache/jena/fuseki/server/FusekiInfo.java | 4 +-
.../server/FusekiServerEnvironmentInit.java | 2 +-
.../apache/jena/fuseki/server/Operation.java | 95 +++
.../jena/fuseki/server/OperationName.java | 93 ---
.../apache/jena/fuseki/servlets/ActionLib.java | 6 +-
.../apache/jena/fuseki/servlets/ActionREST.java | 2 +-
.../jena/fuseki/servlets/ActionSPARQL.java | 246 --------
.../jena/fuseki/servlets/ActionService.java | 268 +++++++++
.../apache/jena/fuseki/servlets/Dispatch.java | 52 +-
.../jena/fuseki/servlets/FusekiFilter.java | 2 +-
.../apache/jena/fuseki/servlets/HttpAction.java | 2 +-
.../jena/fuseki/servlets/SPARQL_Protocol.java | 2 +-
.../servlets/SPARQL_UberServlet_Original.java | 68 +--
.../jena/fuseki/servlets/SPARQL_Upload.java | 2 +-
.../jena/fuseki/servlets/ServiceRouter.java | 382 +++++++++++++
.../fuseki/servlets/ServiceRouterServlet.java | 573 -------------------
.../jena/fuseki/servlets/package-info.java | 61 --
.../fuseki/embedded/TestEmbeddedFuseki.java | 16 +-
26 files changed, 968 insertions(+), 1131 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-basic/src/main/java/org/apache/jena/fuseki/cmds/FusekiBasicCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-basic/src/main/java/org/apache/jena/fuseki/cmds/FusekiBasicCmd.java b/jena-fuseki2/jena-fuseki-basic/src/main/java/org/apache/jena/fuseki/cmds/FusekiBasicCmd.java
index 4c219dd..ad68979 100644
--- a/jena-fuseki2/jena-fuseki-basic/src/main/java/org/apache/jena/fuseki/cmds/FusekiBasicCmd.java
+++ b/jena-fuseki2/jena-fuseki-basic/src/main/java/org/apache/jena/fuseki/cmds/FusekiBasicCmd.java
@@ -476,8 +476,8 @@ public class FusekiBasicCmd {
List<String> endpoints = new ArrayList<>();
desc.put(ds, endpoints);
DataService dSrv = dap.getDataService();
- dSrv.getOperations().forEach((opName)->{
- dSrv.getOperation(opName).forEach(ep-> {
+ dSrv.getOperations().forEach((op)->{
+ dSrv.getEndpoints(op).forEach(ep-> {
String x = ep.getEndpoint();
if ( x.isEmpty() )
x = "quads";
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiBuilder.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiBuilder.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiBuilder.java
index 9eb3b4a..9a177fb 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiBuilder.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/build/FusekiBuilder.java
@@ -18,10 +18,17 @@
package org.apache.jena.fuseki.build;
-import static org.apache.jena.fuseki.server.FusekiVocab.* ;
import static java.lang.String.format ;
import static org.apache.jena.fuseki.FusekiLib.nodeLabel ;
import static org.apache.jena.fuseki.FusekiLib.query ;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceQueryEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceReadGraphStoreEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceReadQuadsEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceReadWriteGraphStoreEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceReadWriteQuadsEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceUpdateEP;
+import static org.apache.jena.fuseki.server.FusekiVocab.pServiceUploadEP;
+
import org.apache.jena.assembler.Assembler ;
import org.apache.jena.datatypes.xsd.XSDDatatype ;
import org.apache.jena.fuseki.Fuseki ;
@@ -29,8 +36,7 @@ import org.apache.jena.fuseki.FusekiConfigException ;
import org.apache.jena.fuseki.FusekiLib ;
import org.apache.jena.fuseki.server.DataAccessPoint ;
import org.apache.jena.fuseki.server.DataService ;
-import org.apache.jena.fuseki.server.Endpoint ;
-import org.apache.jena.fuseki.server.OperationName ;
+import org.apache.jena.fuseki.server.Operation ;
import org.apache.jena.query.Dataset ;
import org.apache.jena.query.QuerySolution ;
import org.apache.jena.query.ResultSet ;
@@ -42,6 +48,7 @@ import org.apache.jena.sparql.core.DatasetGraph ;
import org.apache.jena.sparql.util.FmtUtils ;
import org.apache.jena.vocabulary.RDF ;
import org.slf4j.Logger ;
+
public class FusekiBuilder
{
private static Logger log = Fuseki.builderLog ;
@@ -72,26 +79,26 @@ public class FusekiBuilder
// In case the assembler included ja:contents
DataService dataService = new DataService(ds.asDatasetGraph()) ;
- addServiceEP(dataService, OperationName.Query, svc, pServiceQueryEP) ;
- addServiceEP(dataService, OperationName.Update, svc, pServiceUpdateEP) ;
- addServiceEP(dataService, OperationName.Upload, svc, pServiceUploadEP);
- addServiceEP(dataService, OperationName.GSP_R, svc, pServiceReadGraphStoreEP) ;
- addServiceEP(dataService, OperationName.GSP_RW, svc, pServiceReadWriteGraphStoreEP) ;
+ addServiceEP(dataService, Operation.Query, svc, pServiceQueryEP) ;
+ addServiceEP(dataService, Operation.Update, svc, pServiceUpdateEP) ;
+ addServiceEP(dataService, Operation.Upload, svc, pServiceUploadEP);
+ addServiceEP(dataService, Operation.GSP_R, svc, pServiceReadGraphStoreEP) ;
+ addServiceEP(dataService, Operation.GSP_RW, svc, pServiceReadWriteGraphStoreEP) ;
- addServiceEP(dataService, OperationName.Quads_R, svc, pServiceReadQuadsEP) ;
- addServiceEP(dataService, OperationName.Quads_RW, svc, pServiceReadWriteQuadsEP) ;
+ addServiceEP(dataService, Operation.Quads_R, svc, pServiceReadQuadsEP) ;
+ addServiceEP(dataService, Operation.Quads_RW, svc, pServiceReadWriteQuadsEP) ;
// Quads - actions directly on the dataset URL are different.
// In the config file they are also implicit when using GSP.
- if ( ! dataService.getOperation(OperationName.GSP_RW).isEmpty() || ! dataService.getOperation(OperationName.Quads_RW).isEmpty() ) {
+ if ( ! dataService.getEndpoints(Operation.GSP_RW).isEmpty() || ! dataService.getEndpoints(Operation.Quads_RW).isEmpty() ) {
// ReadWrite available.
// Dispatch needs introspecting on the HTTP request.
- dataService.addEndpoint(OperationName.DatasetRequest_RW, "") ;
- } else if ( ! dataService.getOperation(OperationName.GSP_R).isEmpty() || ! dataService.getOperation(OperationName.Quads_R).isEmpty() ) {
+ dataService.addEndpoint(Operation.DatasetRequest_RW, "") ;
+ } else if ( ! dataService.getEndpoints(Operation.GSP_R).isEmpty() || ! dataService.getEndpoints(Operation.Quads_R).isEmpty() ) {
// Read-only available.
// Dispatch needs introspecting on the HTTP request.
- dataService.addEndpoint(OperationName.DatasetRequest_R, "") ;
+ dataService.addEndpoint(Operation.DatasetRequest_R, "") ;
}
// XXX
@@ -125,24 +132,24 @@ public class FusekiBuilder
/** Build a DataService starting at Resource svc, with the standard (default) set of services */
public static DataService buildDataServiceStd(DatasetGraph dsg, boolean allowUpdate) {
DataService dataService = new DataService(dsg) ;
- addServiceEP(dataService, OperationName.Query, "query") ;
- addServiceEP(dataService, OperationName.Query, "sparql") ;
+ addServiceEP(dataService, Operation.Query, "query") ;
+ addServiceEP(dataService, Operation.Query, "sparql") ;
if ( ! allowUpdate ) {
- addServiceEP(dataService, OperationName.GSP_R, "data") ;
- addServiceEP(dataService, OperationName.DatasetRequest_R, "") ;
+ addServiceEP(dataService, Operation.GSP_R, "data") ;
+ addServiceEP(dataService, Operation.DatasetRequest_R, "") ;
return dataService ;
}
- addServiceEP(dataService, OperationName.GSP_RW, "data") ;
- addServiceEP(dataService, OperationName.GSP_R, "get") ;
- addServiceEP(dataService, OperationName.Update, "update") ;
- addServiceEP(dataService, OperationName.Upload, "upload") ;
+ addServiceEP(dataService, Operation.GSP_RW, "data") ;
+ addServiceEP(dataService, Operation.GSP_R, "get") ;
+ addServiceEP(dataService, Operation.Update, "update") ;
+ addServiceEP(dataService, Operation.Upload, "upload") ;
// Dispatch needs introspecting on the HTTP request.
- addServiceEP(dataService, OperationName.DatasetRequest_RW, "") ;
+ addServiceEP(dataService, Operation.DatasetRequest_RW, "") ;
return dataService ;
}
- private static void addServiceEP(DataService dataService, OperationName opName, String epName) {
- dataService.addEndpoint(opName, epName) ;
+ private static void addServiceEP(DataService dataService, Operation operation, String epName) {
+ dataService.addEndpoint(operation, epName) ;
}
public static RDFNode getOne(Resource svc, String property) {
@@ -156,15 +163,14 @@ public class FusekiBuilder
return x ;
}
- private static void addServiceEP(DataService dataService, OperationName opName, Resource svc, Property property) {
+ private static void addServiceEP(DataService dataService, Operation operation, Resource svc, Property property) {
String p = "<"+property.getURI()+">" ;
ResultSet rs = query("SELECT * { ?svc " + p + " ?ep}", svc.getModel(), "svc", svc) ;
for ( ; rs.hasNext() ; ) {
QuerySolution soln = rs.next() ;
String epName = soln.getLiteral("ep").getLexicalForm() ;
- Endpoint operation = new Endpoint(opName, epName) ;
- addServiceEP(dataService, opName, epName);
- //log.info(" " + opName.name + " = " + dataAccessPoint.getName() + "/" + epName) ;
+ addServiceEP(dataService, operation, epName);
+ //log.info(" " + operation.name + " = " + dataAccessPoint.getName() + "/" + epName) ;
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
index 079488e..072b604 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
@@ -97,8 +97,8 @@ public class ActionStats extends ActionContainerItem
builder.key(JsonConst.endpoints).startObject("endpoints") ;
- for ( OperationName operName : dSrv.getOperations() ) {
- List<Endpoint> endpoints = access.getDataService().getOperation(operName) ;
+ for ( Operation operName : dSrv.getOperations() ) {
+ List<Endpoint> endpoints = access.getDataService().getEndpoints(operName) ;
for ( Endpoint endpoint : endpoints ) {
// Endpoint names are unique for a given service.
@@ -150,23 +150,23 @@ public class ActionStats extends ActionContainerItem
out.println(" Bad = "+dSrv.getCounters().value(CounterName.RequestsBad)) ;
out.println(" SPARQL Query:") ;
- out.println(" Request = "+counter(dSrv, OperationName.Query, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, OperationName.Query, CounterName.RequestsGood)) ;
- out.println(" Bad requests = "+counter(dSrv, OperationName.Query, CounterName.RequestsBad)) ;
- out.println(" Timeouts = "+counter(dSrv, OperationName.Query, CounterName.QueryTimeouts)) ;
- out.println(" Bad exec = "+counter(dSrv, OperationName.Query, CounterName.QueryExecErrors)) ;
- out.println(" IO Errors = "+counter(dSrv, OperationName.Query, CounterName.QueryIOErrors)) ;
+ out.println(" Request = "+counter(dSrv, Operation.Query, CounterName.Requests)) ;
+ out.println(" Good = "+counter(dSrv, Operation.Query, CounterName.RequestsGood)) ;
+ out.println(" Bad requests = "+counter(dSrv, Operation.Query, CounterName.RequestsBad)) ;
+ out.println(" Timeouts = "+counter(dSrv, Operation.Query, CounterName.QueryTimeouts)) ;
+ out.println(" Bad exec = "+counter(dSrv, Operation.Query, CounterName.QueryExecErrors)) ;
+ out.println(" IO Errors = "+counter(dSrv, Operation.Query, CounterName.QueryIOErrors)) ;
out.println(" SPARQL Update:") ;
- out.println(" Request = "+counter(dSrv, OperationName.Update, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, OperationName.Update, CounterName.RequestsGood)) ;
- out.println(" Bad requests = "+counter(dSrv, OperationName.Update, CounterName.RequestsBad)) ;
- out.println(" Bad exec = "+counter(dSrv, OperationName.Update, CounterName.UpdateExecErrors)) ;
+ out.println(" Request = "+counter(dSrv, Operation.Update, CounterName.Requests)) ;
+ out.println(" Good = "+counter(dSrv, Operation.Update, CounterName.RequestsGood)) ;
+ out.println(" Bad requests = "+counter(dSrv, Operation.Update, CounterName.RequestsBad)) ;
+ out.println(" Bad exec = "+counter(dSrv, Operation.Update, CounterName.UpdateExecErrors)) ;
out.println(" Upload:") ;
- out.println(" Requests = "+counter(dSrv, OperationName.Upload, CounterName.Requests)) ;
- out.println(" Good = "+counter(dSrv, OperationName.Upload, CounterName.RequestsGood)) ;
- out.println(" Bad = "+counter(dSrv, OperationName.Upload, CounterName.RequestsBad)) ;
+ out.println(" Requests = "+counter(dSrv, Operation.Upload, CounterName.Requests)) ;
+ out.println(" Good = "+counter(dSrv, Operation.Upload, CounterName.RequestsGood)) ;
+ out.println(" Bad = "+counter(dSrv, Operation.Upload, CounterName.RequestsBad)) ;
out.println(" SPARQL Graph Store Protocol:") ;
out.println(" GETs = "+gspValue(dSrv, CounterName.HTTPget)+ " (good="+gspValue(dSrv, CounterName.HTTPgetGood)+"/bad="+gspValue(dSrv, CounterName.HTTPGetBad)+")") ;
@@ -176,13 +176,13 @@ public class ActionStats extends ActionContainerItem
out.println(" HEADs = "+gspValue(dSrv, CounterName.HTTPhead)+ " (good="+gspValue(dSrv, CounterName.HTTPheadGood)+"/bad="+gspValue(dSrv, CounterName.HTTPheadBad)+")") ;
}
- private long counter(DataService dSrv, OperationName opName, CounterName cName) {
+ private long counter(DataService dSrv, Operation operation, CounterName cName) {
return 0 ;
}
private long gspValue(DataService dSrv, CounterName cn) {
- return counter(dSrv, OperationName.GSP_RW, cn) +
- counter(dSrv, OperationName.GSP_R, cn) ;
+ return counter(dSrv, Operation.GSP_RW, cn) +
+ counter(dSrv, Operation.GSP_R, cn) ;
}
// We shouldn't get here - no doPost above.
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
index 6c4c11d..c4158d7 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/mgt/JsonDescription.java
@@ -24,7 +24,7 @@ import org.apache.jena.atlas.json.JsonBuilder ;
import org.apache.jena.fuseki.server.DataAccessPoint ;
import org.apache.jena.fuseki.server.DataAccessPointRegistry ;
import org.apache.jena.fuseki.server.Endpoint ;
-import org.apache.jena.fuseki.server.OperationName ;
+import org.apache.jena.fuseki.server.Operation ;
/** Create a description of a service */
public class JsonDescription {
@@ -47,19 +47,19 @@ public class JsonDescription {
builder.key(JsonConst.dsService) ;
builder.startArray() ;
- for ( OperationName opName : access.getDataService().getOperations() ) {
- List<Endpoint> endpoints = access.getDataService().getOperation(opName) ;
- describe(builder, opName, endpoints) ;
+ for ( Operation operation : access.getDataService().getOperations() ) {
+ List<Endpoint> endpoints = access.getDataService().getEndpoints(operation) ;
+ describe(builder, operation, endpoints) ;
}
builder.finishArray() ;
builder.finishObject() ;
}
- private static void describe(JsonBuilder builder, OperationName opName, List<Endpoint> endpoints) {
+ private static void describe(JsonBuilder builder, Operation operation, List<Endpoint> endpoints) {
builder.startObject() ;
- builder.key(JsonConst.srvType).value(opName.getName()) ;
- builder.key(JsonConst.srvDescription).value(opName.getDescription()) ;
+ builder.key(JsonConst.srvType).value(operation.getName()) ;
+ builder.key(JsonConst.srvDescription).value(operation.getDescription()) ;
builder.key(JsonConst.srvEndpoints) ;
builder.startArray() ;
for ( Endpoint endpoint : endpoints )
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/package-info.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/package-info.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/package-info.java
new file mode 100644
index 0000000..34d6339
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/package-info.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/** Documentation for dispatch-execute.
+ * <p>
+ * <b>Classes</b>
+ * <ul>
+ * <li><em>DataAccessPointRegistry</em> :: Per server registry of {@code DataAccessPoint}s</li>
+ * <li><em>DataAccessPoint</em> :: Name to DataService binding</li>
+ * <li><em>DataService</em> :: RDF Dataset, counters, endpoints</li>
+ * <li><em>Operation</em> :: Internal name of a service, not the name used in a configuration file.</li>
+ * <li><em>Endpoint</em> :: Instance of an operation, toether with its counters.</li>
+ * <li><em>DataAccessPointRegistry</em> :: Per server registry of DataAccessPoint</li>
+ * </ul>
+ * <p>
+ * <li><b>Servlets</b>
+ * <p>
+ * <ul>
+ * <li><em>FusekiFilter</em> :: Routes requests to Fuseki (handles the dynamic nature dataset naming) by calling ServiceRouter.</li>
+ * <li><em>ServiceRouterServlet</em> :: Routes requests to the appropriate service (i.e. implementing servlet).</li>
+ * <li><em>ActionBase</em> :: Creates a basic {@code HttpAction} and defines {@code execCommonWorker}.</li>
+ * <li><em>ActionService</em> :: Fills in {@code HttpAction} with dataset and endpoint. Calls {@code setRequest} on an {@code HttpAction}.
+ * It implements {@code execCommonWorker} as a lifecycle => {@code executeAction} => {@code executeLifecycle} => {@code validate - perform}
+ * <li><em>ServiceRouter</em> :: Routing of request to the cocrete servlet implementations.
+ * </ul>
+ * <p>
+ * <pre>
+ * ServiceDispatchServlet < ActionService < ActionBase
+ * Services < ActionService < ActionBase
+ * Admin operations < ActionCtl < ActionBase
+ * Task management < ActionTasks < ActionBase
+ * </pre>
+ * <p>
+ * <b>Registries</b>
+ * <p>Located in {@code FusekiRegistries}.
+ * <p>
+ * <ul>
+ * <li><em>ContentTypeToOperation</em>:: Map<content-type, Operation></li>
+ * <li><em>ContentTypeToOperation</em>:: Map<String, Operation></li>
+ * <li><em>Dispatch</em> :: Map<Operation, ActionService</li>
+ * </ul>
+ * <p>
+ */
+
+package org.apache.jena.fuseki;
+
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
index 50b1f4d..5e63132 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataAccessPointRegistry.java
@@ -43,9 +43,9 @@ public class DataAccessPointRegistry extends Registry<String, DataAccessPoint>
System.out.println("== "+string) ;
this.forEach((k,ref)->{
System.out.printf(" (key=%s, ref=%s)\n", k, ref.getName()) ;
- ref.getDataService().getOperations().forEach((opName)->{
- ref.getDataService().getOperation(opName).forEach(ep->{
- System.out.printf(" %s : %s\n", opName, ep.getEndpoint()) ;
+ ref.getDataService().getOperations().forEach((op)->{
+ ref.getDataService().getEndpoints(op).forEach(ep->{
+ System.out.printf(" %s : %s\n", op, ep.getEndpoint()) ;
});
});
}) ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataService.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataService.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataService.java
index d191272..2644b87 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataService.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/DataService.java
@@ -45,13 +45,13 @@ public class DataService { //implements DatasetMXBean {
static {
DatasetGraph dsg = new DatasetGraphReadOnly(DatasetGraphFactory.create()) ;
dummy = new DataService(dsg) ;
- dummy.addEndpoint(OperationName.Query, DEF.ServiceQuery) ;
- dummy.addEndpoint(OperationName.Query, DEF.ServiceQueryAlt) ;
+ dummy.addEndpoint(Operation.Query, DEF.ServiceQuery) ;
+ dummy.addEndpoint(Operation.Query, DEF.ServiceQueryAlt) ;
}
private DatasetGraph dataset ;
- private ListMultimap<OperationName, Endpoint> operations = ArrayListMultimap.create() ;
+ private ListMultimap<Operation, Endpoint> operations = ArrayListMultimap.create() ;
private Map<String, Endpoint> endpoints = new HashMap<>() ;
private volatile DatasetStatus state = UNINITIALIZED ;
@@ -86,27 +86,27 @@ public class DataService { //implements DatasetMXBean {
return dataset ;
}
- public void addEndpoint(OperationName operationName, String endpointName) {
- Endpoint endpoint = new Endpoint(operationName, endpointName) ;
+ public void addEndpoint(Operation operation, String endpointName) {
+ Endpoint endpoint = new Endpoint(operation, endpointName) ;
endpoints.put(endpointName, endpoint) ;
- operations.put(operationName, endpoint);
+ operations.put(operation, endpoint);
}
public Endpoint getEndpoint(String endpointName) {
return endpoints.get(endpointName) ;
}
- public List<Endpoint> getOperation(OperationName opName) {
- List<Endpoint> x = operations.get(opName) ;
+ public List<Endpoint> getEndpoints(Operation operation) {
+ List<Endpoint> x = operations.get(operation) ;
if ( x == null )
x = Collections.emptyList() ;
return x ;
}
- /** Return the OperationNames available here.
- * @see #getOperation(OperationName) to get the endpoint list
+ /** Return the operations available here.
+ * @see #getEndpoints(Operation) to get the endpoint list
*/
- public Collection<OperationName> getOperations() {
+ public Collection<Operation> getOperations() {
return operations.keySet() ;
}
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java
index 6de7062..c54309d 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Endpoint.java
@@ -22,15 +22,15 @@ import org.apache.jena.atlas.lib.InternalErrorException ;
public class Endpoint implements Counters {
- public final OperationName opName ;
+ public final Operation operation ;
public final String endpointName ;
// Endpoint-level counters.
private final CounterSet counters = new CounterSet() ;
- public Endpoint(OperationName opName, String endpointName) {
- this.opName = opName ;
- if ( opName == null )
- throw new InternalErrorException("opName is null") ;
+ public Endpoint(Operation operation, String endpointName) {
+ this.operation = operation ;
+ if ( operation == null )
+ throw new InternalErrorException("operation is null") ;
this.endpointName = endpointName ;
// Standard counters - there may be others
counters.add(CounterName.Requests) ;
@@ -42,11 +42,11 @@ public class Endpoint implements Counters {
public CounterSet getCounters() { return counters ; }
//@Override
- public OperationName getOperationName() { return opName ; }
+ public Operation getOperation() { return operation ; }
//@Override
- public boolean isType(OperationName operationName) {
- return opName.equals(operationName) ;
+ public boolean isType(Operation operation) {
+ return operation.equals(operation) ;
}
public String getEndpoint() { return endpointName ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiInfo.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiInfo.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiInfo.java
index 754f358..7a5643a 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiInfo.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiInfo.java
@@ -72,8 +72,8 @@ public class FusekiInfo {
List<String> endpoints = new ArrayList<>();
desc.put(ds, endpoints);
DataService dSrv = dap.getDataService();
- dSrv.getOperations().forEach((opName)->{
- dSrv.getOperation(opName).forEach(ep-> {
+ dSrv.getOperations().forEach((op)->{
+ dSrv.getEndpoints(op).forEach(ep-> {
String x = ep.getEndpoint();
if ( x.isEmpty() )
x = "quads";
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServerEnvironmentInit.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServerEnvironmentInit.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServerEnvironmentInit.java
index 434abf3..cc1fd5c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServerEnvironmentInit.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiServerEnvironmentInit.java
@@ -43,7 +43,7 @@ public class FusekiServerEnvironmentInit implements ServletContextListener {
public void contextDestroyed(ServletContextEvent sce) {
// Stop handling requests.
- // ActionSPARQL uses DataAccessPointRegistry to map URI to services (DataAccessPoint)
+ // ActionService uses DataAccessPointRegistry to map URI to services (DataAccessPoint)
// DataService -> DataService
// DataAccessPointRegistry.shutdown() ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
new file mode 100644
index 0000000..1a136e4
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/Operation.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.fuseki.server;
+
+import org.apache.jena.fuseki.servlets.Dispatch;
+
+/**
+ * Operations are symbol to look up in the {@link Dispatch#operationToHandler} map. The name
+ * of an {@code Operation} is not related to the service name used to invoke the operation
+ * which is determined by the {@link Endpoint}.
+ */
+public class Operation {
+
+ // Create intern'ed symbols.
+ static private NameMgr<Operation> mgr = new NameMgr<>();
+ static public Operation register(String name, String description) { return mgr.register(name, (x)->new Operation(x, description)); }
+
+ public static final Operation Query = register("Query", "SPARQL Query");
+ public static final Operation Update = register("Update", "SPARQL Update");
+ public static final Operation Upload = register("Upload", "File Upload");
+ public static final Operation GSP_R = register("GSP_R", "Graph Store Protocol (Read)");
+ public static final Operation GSP_RW = register("GSP_RW", "Graph Store Protocol");
+ public static final Operation Quads_R = register("Quads_R", "HTTP Quads (Read)");
+ public static final Operation Quads_RW = register("Quads_RW", "HTTP Quads");
+
+ // Plain REST operations on the datset URL
+ public static final Operation DatasetRequest_R = Quads_R;
+ public static final Operation DatasetRequest_RW = Quads_RW;
+
+ private final String description ;
+ private final String name ;
+
+ private Operation(String name, String description) {
+ this.name = name;
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ // Could be this == obj
+ // because we intern'ed the object
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( this == obj )
+ return true;
+ if ( obj == null )
+ return false;
+ if ( getClass() != obj.getClass() )
+ return false;
+ Operation other = (Operation)obj;
+ if ( name == null ) {
+ if ( other.name != null )
+ return false;
+ } else if ( !name.equals(other.name) )
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/OperationName.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/OperationName.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/OperationName.java
deleted file mode 100644
index c18b0a8..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/OperationName.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.server;
-
-/**
- * Names (symbols) for operations.
- * An {@code OperationName} is not related to the service name used to invoke the operation.
- * That is determined by the {@link Endpoint}.
- */
-public class OperationName {
-
- // Create intern'ed symbols.
- static private NameMgr<OperationName> mgr = new NameMgr<>();
- static public OperationName register(String name, String description) { return mgr.register(name, (x)->new OperationName(x, description)); }
-
- public static final OperationName Query = register("Query", "SPARQL Query");
- public static final OperationName Update = register("Update", "SPARQL Update");
- public static final OperationName Upload = register("Upload", "File Upload");
- public static final OperationName GSP_RW = register("GSP_RW", "Graph Store Protocol");
- public static final OperationName GSP_R = register("GSP_R", "Graph Store Protocol (Read)");
- public static final OperationName Quads_RW = register("Quads_RW", "HTTP Quads");
- public static final OperationName Quads_R = register("Quads_R", "HTTP Quads (Read)");
-
- // Dummy "operation" used to mark that datasets accept request made directly on them.
- public static final OperationName DatasetRequest_RW = Quads_RW; //register("Dataset", "HTTP Request");
- public static final OperationName DatasetRequest_R = Quads_R; //register("Dataset", "HTTP Request");
-
- private final String description ;
- private final String name ;
-
- private OperationName(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- // Could be this == obj
- // because we intern'ed the object
-
- @Override
- public boolean equals(Object obj) {
- if ( this == obj )
- return true;
- if ( obj == null )
- return false;
- if ( getClass() != obj.getClass() )
- return false;
- OperationName other = (OperationName)obj;
- if ( name == null ) {
- if ( other.name != null )
- return false;
- } else if ( !name.equals(other.name) )
- return false;
- return true;
- }
-
- @Override
- public String toString() {
- return name;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
index 49e25eb..e81b7ab 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionLib.java
@@ -42,7 +42,7 @@ import org.apache.jena.riot.system.StreamRDF;
public class ActionLib {
/**
- * A possible implementation for {@link ActionSPARQL#mapRequestToDataset}
+ * A possible implementation for {@link ActionService#mapRequestToDataset}
* that assumes the form /dataset/service.
* @param action the request
* @return the dataset
@@ -169,8 +169,7 @@ public class ActionLib {
}
/** Negotiate the content-type and set the response headers */
- public static MediaType contentNegotation(HttpAction action, AcceptList myPrefs,
- MediaType defaultMediaType) {
+ public static MediaType contentNegotation(HttpAction action, AcceptList myPrefs, MediaType defaultMediaType) {
MediaType mt = ConNeg.chooseContentType(action.request, myPrefs, defaultMediaType) ;
if ( mt == null )
return null ;
@@ -190,7 +189,6 @@ public class ActionLib {
public static MediaType contentNegotationQuads(HttpAction action) {
return contentNegotation(action, DEF.quadsOffer, DEF.acceptNQuads) ;
}
-
/**
* Parse RDF content
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionREST.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionREST.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionREST.java
index 13ed6ea..4304399 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionREST.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionREST.java
@@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse ;
import org.apache.jena.fuseki.server.CounterName ;
/** Common point for operations that are "REST"ish (use GET/PUT etc as operations). */
-public abstract class ActionREST extends ActionSPARQL
+public abstract class ActionREST extends ActionService
{
public ActionREST()
{ super() ; }
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java
deleted file mode 100644
index 677e882..0000000
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.jena.fuseki.servlets;
-
-import static java.lang.String.format;
-import static org.apache.jena.fuseki.server.CounterName.Requests ;
-import static org.apache.jena.fuseki.server.CounterName.RequestsBad ;
-import static org.apache.jena.fuseki.server.CounterName.RequestsGood ;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-
-import org.apache.jena.atlas.RuntimeIOException ;
-import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.server.* ;
-import org.apache.jena.query.QueryCancelledException ;
-import org.apache.jena.web.HttpSC;
-
-/** SPARQL request lifecycle */
-public abstract class ActionSPARQL extends ActionBase
-{
- protected ActionSPARQL() { super(Fuseki.actionLog) ; }
-
- protected abstract void validate(HttpAction action) ;
- protected abstract void perform(HttpAction action) ;
-
- /**
- * Executes common tasks, including mapping the request to the right dataset, setting the dataset into the HTTP
- * action, and retrieving the service for the dataset requested. Finally, it calls the
- * {@link #executeAction(HttpAction)} method, which executes the HTTP Action life cycle.
- * @param action HTTP Action
- */
- @Override
- protected void execCommonWorker(HttpAction action) {
- DataAccessPoint dataAccessPoint ;
- DataService dSrv ;
-
- String datasetUri = mapRequestToDataset(action) ;
- if ( datasetUri != null ) {
- dataAccessPoint = action.getDataAccessPointRegistry().get(datasetUri) ;
- if ( dataAccessPoint == null ) {
- ServletOps.errorNotFound("No dataset for URI: "+datasetUri) ;
- return ;
- }
- dSrv = dataAccessPoint.getDataService() ;
- if ( ! dSrv.isAcceptingRequests() ) {
- ServletOps.error(HttpSC.SERVICE_UNAVAILABLE_503, "Dataset not currently active");
- return ;
- }
- } else {
- dataAccessPoint = null ;
- dSrv = DataService.serviceOnlyDataService() ;
- }
-
- action.setRequest(dataAccessPoint, dSrv) ;
- String endpointName = mapRequestToOperation(action, dataAccessPoint) ;
-
- if ( true ) {
- // New dispatch
- OperationName opName = null;
- if ( ! endpointName.isEmpty() ) {
- opName = chooseEndpoint(action, dSrv, endpointName);
- if ( opName == null )
- ServletOps.errorNotFound(format("dataset=%s, service=%s", dataAccessPoint.getName(), endpointName));
-
- } else {
- opName = chooseEndpoint(action, dSrv);
- if ( opName == null )
- ServletOps.errorBadRequest(format("dataset=%s", dataAccessPoint.getName()));
- }
-
- ActionSPARQL handler = Dispatch.OpNameToHandler.get(opName);
- // XXX -- replace action.setEndpoint
- Endpoint ep = dSrv.getEndpoint(endpointName) ;
- //List<Endpoint> endpoints = dSrv.getOperation(opName);
- action.setEndpoint(ep, endpointName);
- handler.executeLifecycle(action);
- return ;
- }
-
- // Old dispatch via SPARQL_UberServlet.executeAction override.
- Endpoint op = dSrv.getEndpoint(endpointName) ;
- action.setEndpoint(op, endpointName);
- executeAction(action) ;
- }
-
- // These are overridden by the ServiceRouterServlet.
- protected OperationName chooseEndpoint(HttpAction action, DataService dataService, String serviceName) {
- Endpoint ep = dataService.getEndpoint(serviceName) ;
- OperationName opName = ep.getOperationName();
- return opName;
- }
-
- protected OperationName chooseEndpoint(HttpAction action, DataService dataService) {
- // No default implementation for directly bound services operation servlets.
- return null;
- }
-
- private void executeRequest(HttpAction action, ActionSPARQL servlet) {
- if ( true ) {
- // Execute an ActionSPARQL.
- // Bypasses HttpServlet.service to doMethod dispatch.
- servlet.executeLifecycle(action) ;
- return ;
- }
- if ( false ) {
- // Execute by calling the whole servlet mechanism.
- // This causes HttpServlet.service to call the appropriate doMethod.
- // but the action, and the id, are not passed on and a ne one is created.
- try { servlet.service(action.request, action.response) ; }
- catch (ServletException | IOException e) {
- ServletOps.errorOccurred(e);
- }
- }
- }
-
-
- /** Execute a SPARQL request. Statistics have not been adjusted at this point.
- *
- * @param action
- */
- protected void executeAction(HttpAction action) {
- executeLifecycle(action) ;
- }
-
- /**
- * Standard execution lifecycle for a SPARQL Request.
- * <ul>
- * <li>{@link #startRequest(HttpAction)}</li>
- * <li>initial statistics,</li>
- * <li>{@link #validate(HttpAction)} request,</li>
- * <li>{@link #perform(HttpAction)} request,</li>
- * <li>completion/error statistics,</li>
- * <li>{@link #finishRequest(HttpAction)}
- * </ul>
- *
- * @param action
- */
- // This is the service request lifecycle.
- final
- protected void executeLifecycle(HttpAction action) {
- startRequest(action) ;
- // And also HTTP counter
- CounterSet csService = action.getDataService().getCounters() ;
- CounterSet csOperation = null ;
- if ( action.getEndpoint() != null )
- // Direct naming GSP does not have an "endpoint".
- csOperation = action.getEndpoint().getCounters() ;
-
- incCounter(csService, Requests) ;
- incCounter(csOperation, Requests) ;
- try {
- // Either exit this via "bad request" on validation
- // or in execution in perform.
- try {
- validate(action) ;
- } catch (ActionErrorException ex) {
- incCounter(csOperation, RequestsBad) ;
- incCounter(csService, RequestsBad) ;
- throw ex ;
- }
-
- try {
- perform(action) ;
- // Success
- incCounter(csOperation, RequestsGood) ;
- incCounter(csService, RequestsGood) ;
- } catch (ActionErrorException | QueryCancelledException | RuntimeIOException ex) {
- incCounter(csOperation, RequestsBad) ;
- incCounter(csService, RequestsBad) ;
- throw ex ;
- }
- } finally {
- finishRequest(action) ;
- }
- }
-
- /**
- * Map request {@link HttpAction} to uri in the registry.
- * A return of {@code null} means no mapping done (passthrough).
- * @param uri the URI
- * @return the dataset
- */
- protected String mapRequestToDataset(HttpAction action) {
- return ActionLib.mapRequestToDataset(action) ;
- }
-
- /**
- * Map request to uri in the registry. {@code null} means no mapping done
- * (passthrough).
- */
- protected String mapRequestToOperation(HttpAction action, DataAccessPoint dataAccessPoint) {
- return ActionLib.mapRequestToOperation(action, dataAccessPoint) ;
- }
-
- /** Increment counter */
- protected static void incCounter(Counters counters, CounterName name) {
- if ( counters == null ) return ;
- incCounter(counters.getCounters(), name) ;
- }
-
- /** Decrement counter */
- protected static void decCounter(Counters counters, CounterName name) {
- if ( counters == null ) return ;
- decCounter(counters.getCounters(), name) ;
- }
-
- protected static void incCounter(CounterSet counters, CounterName name) {
- if ( counters == null )
- return ;
- try {
- if ( counters.contains(name) )
- counters.inc(name) ;
- } catch (Exception ex) {
- Fuseki.serverLog.warn("Exception on counter inc", ex) ;
- }
- }
-
- protected static void decCounter(CounterSet counters, CounterName name) {
- if ( counters == null )
- return ;
- try {
- if ( counters.contains(name) )
- counters.dec(name) ;
- } catch (Exception ex) {
- Fuseki.serverLog.warn("Exception on counter dec", ex) ;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionService.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionService.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionService.java
new file mode 100644
index 0000000..0994096
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ActionService.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.fuseki.servlets;
+
+import static java.lang.String.format;
+import static org.apache.jena.fuseki.server.CounterName.Requests;
+import static org.apache.jena.fuseki.server.CounterName.RequestsBad;
+import static org.apache.jena.fuseki.server.CounterName.RequestsGood;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+
+import org.apache.jena.atlas.RuntimeIOException;
+import org.apache.jena.fuseki.Fuseki;
+import org.apache.jena.fuseki.server.*;
+import org.apache.jena.query.QueryCancelledException;
+import org.apache.jena.web.HttpSC;
+
+/** SPARQL request lifecycle */
+public abstract class ActionService extends ActionBase {
+ protected ActionService() {
+ super(Fuseki.actionLog);
+ }
+
+ protected abstract void validate(HttpAction action);
+
+ protected abstract void perform(HttpAction action);
+
+ /**
+ * Executes common tasks, including mapping the request to the right dataset, setting
+ * the dataset into the HTTP action, and retrieving the service for the dataset
+ * requested. Finally, it calls the {@link #executeAction(HttpAction)} method, which
+ * executes the HTTP Action life cycle.
+ *
+ * @param action
+ * HTTP Action
+ */
+ @Override
+ protected void execCommonWorker(HttpAction action) {
+ DataAccessPoint dataAccessPoint;
+ DataService dSrv;
+
+ String datasetUri = mapRequestToDataset(action);
+ if ( datasetUri != null ) {
+ dataAccessPoint = action.getDataAccessPointRegistry().get(datasetUri);
+ if ( dataAccessPoint == null ) {
+ ServletOps.errorNotFound("No dataset for URI: " + datasetUri);
+ return;
+ }
+ dSrv = dataAccessPoint.getDataService();
+ if ( !dSrv.isAcceptingRequests() ) {
+ ServletOps.error(HttpSC.SERVICE_UNAVAILABLE_503, "Dataset not currently active");
+ return;
+ }
+ } else {
+ dataAccessPoint = null;
+ dSrv = DataService.serviceOnlyDataService();
+ }
+
+ action.setRequest(dataAccessPoint, dSrv);
+ String endpointName = mapRequestToOperation(action, dataAccessPoint);
+
+ if ( false ) {
+ // DELETE when SPARQL_UberServlet goes.
+ // Old dispatch via SPARQL_UberServlet.executeAction override.
+ SPARQL_UberServlet_Original dummy = null;
+ Endpoint op = dSrv.getEndpoint(endpointName);
+ action.setEndpoint(op, endpointName);
+ executeAction(action);
+ return;
+ }
+
+ // ServiceRouter dispatch
+ Operation operation = null;
+ if ( !endpointName.isEmpty() ) {
+ operation = chooseOperation(action, dSrv, endpointName);
+ if ( operation == null )
+ ServletOps.errorNotFound(format("dataset=%s, service=%s", dataAccessPoint.getName(), endpointName));
+
+ } else {
+ operation = chooseOperation(action, dSrv);
+ if ( operation == null )
+ ServletOps.errorBadRequest(format("dataset=%s", dataAccessPoint.getName()));
+ }
+
+ ActionService handler = Dispatch.operationToHandler.get(operation);
+ if ( handler == null )
+ ServletOps.errorBadRequest(format("dataset=%s: op=%s", dataAccessPoint.getName(), operation.getName()));
+ // XXX -- replace action.setEndpoint
+ Endpoint ep = dSrv.getEndpoint(endpointName);
+ action.setEndpoint(ep, endpointName);
+ handler.executeLifecycle(action);
+ return;
+ }
+
+ // Overridden by the ServiceRouter.
+ protected Operation chooseOperation(HttpAction action, DataService dataService, String serviceName) {
+ // This default implementation is plain service name to operation based on the
+ // DataService as would be used by operation servlets bound by web.xml.
+ Endpoint ep = dataService.getEndpoint(serviceName);
+ Operation operation = ep.getOperation();
+ return operation;
+ }
+
+ // Overridden by the ServiceRouter.
+ protected Operation chooseOperation(HttpAction action, DataService dataService) {
+ // No default implementation for directly bound services operation servlets.
+ return null;
+ }
+
+ private void executeRequest(HttpAction action, ActionService servlet) {
+ if ( true ) {
+ // Execute an ActionService.
+ // Bypasses HttpServlet.service to doMethod dispatch.
+ servlet.executeLifecycle(action);
+ return;
+ }
+ if ( false ) {
+ // Execute by calling the whole servlet mechanism.
+ // This causes HttpServlet.service to call the appropriate doMethod.
+ // but the action, and the id, are not passed on and a ne one is created.
+ try {
+ servlet.service(action.request, action.response);
+ }
+ catch (ServletException | IOException e) {
+ ServletOps.errorOccurred(e);
+ }
+ }
+ }
+
+ /**
+ * Execute a SPARQL request. Statistics have not been adjusted at this point.
+ *
+ * @param action
+ */
+ protected void executeAction(HttpAction action) {
+ executeLifecycle(action);
+ }
+
+ /**
+ * Standard execution lifecycle for a SPARQL Request.
+ * <ul>
+ * <li>{@link #startRequest(HttpAction)}</li>
+ * <li>initial statistics,</li>
+ * <li>{@link #validate(HttpAction)} request,</li>
+ * <li>{@link #perform(HttpAction)} request,</li>
+ * <li>completion/error statistics,</li>
+ * <li>{@link #finishRequest(HttpAction)}
+ * </ul>
+ *
+ * @param action
+ */
+ // This is the service request lifecycle.
+ final protected void executeLifecycle(HttpAction action) {
+ startRequest(action);
+ // And also HTTP counter
+ CounterSet csService = action.getDataService().getCounters();
+ CounterSet csOperation = null;
+ if ( action.getEndpoint() != null )
+ // Direct naming GSP does not have an "endpoint".
+ csOperation = action.getEndpoint().getCounters();
+
+ incCounter(csService, Requests);
+ incCounter(csOperation, Requests);
+ try {
+ // Either exit this via "bad request" on validation
+ // or in execution in perform.
+ try {
+ validate(action);
+ }
+ catch (ActionErrorException ex) {
+ incCounter(csOperation, RequestsBad);
+ incCounter(csService, RequestsBad);
+ throw ex;
+ }
+
+ try {
+ perform(action);
+ // Success
+ incCounter(csOperation, RequestsGood);
+ incCounter(csService, RequestsGood);
+ }
+ catch (ActionErrorException | QueryCancelledException | RuntimeIOException ex) {
+ incCounter(csOperation, RequestsBad);
+ incCounter(csService, RequestsBad);
+ throw ex;
+ }
+ }
+ finally {
+ finishRequest(action);
+ }
+ }
+
+ /**
+ * Map request {@link HttpAction} to uri in the registry. A return of {@code null}
+ * means no mapping done (passthrough).
+ *
+ * @param uri
+ * the URI
+ * @return the dataset
+ */
+ protected String mapRequestToDataset(HttpAction action) {
+ return ActionLib.mapRequestToDataset(action);
+ }
+
+ /**
+ * Map request to uri in the registry. {@code null} means no mapping done
+ * (passthrough).
+ */
+ protected String mapRequestToOperation(HttpAction action, DataAccessPoint dataAccessPoint) {
+ return ActionLib.mapRequestToOperation(action, dataAccessPoint);
+ }
+
+ /** Increment counter */
+ protected static void incCounter(Counters counters, CounterName name) {
+ if ( counters == null )
+ return;
+ incCounter(counters.getCounters(), name);
+ }
+
+ /** Decrement counter */
+ protected static void decCounter(Counters counters, CounterName name) {
+ if ( counters == null )
+ return;
+ decCounter(counters.getCounters(), name);
+ }
+
+ protected static void incCounter(CounterSet counters, CounterName name) {
+ if ( counters == null )
+ return;
+ try {
+ if ( counters.contains(name) )
+ counters.inc(name);
+ }
+ catch (Exception ex) {
+ Fuseki.serverLog.warn("Exception on counter inc", ex);
+ }
+ }
+
+ protected static void decCounter(CounterSet counters, CounterName name) {
+ if ( counters == null )
+ return;
+ try {
+ if ( counters.contains(name) )
+ counters.dec(name);
+ }
+ catch (Exception ex) {
+ Fuseki.serverLog.warn("Exception on counter dec", ex);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/Dispatch.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/Dispatch.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/Dispatch.java
index d0a4cf4..2d66909 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/Dispatch.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/Dispatch.java
@@ -22,41 +22,41 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.jena.fuseki.server.DataService;
-import org.apache.jena.fuseki.server.OperationName;
+import org.apache.jena.fuseki.server.Operation;
import org.apache.jena.riot.WebContent;
-/** The global mapping of content-type to OperationName. */
+/** The global mapping of content-type to Operation. */
public class Dispatch {
- /** Map ContentType (lowercase, no charset) to the {@code OperationName} for handling it. */
- public static Map<String, OperationName> contentTypeToOpName = new ConcurrentHashMap<>();
+ /** Map ContentType (lowercase, no charset) to the {@code Operation} for handling it. */
+ public static Map<String, Operation> contentTypeToOperation = new ConcurrentHashMap<>();
static {
- contentTypeToOpName.put(WebContent.contentTypeSPARQLQuery, OperationName.Query);
- contentTypeToOpName.put(WebContent.contentTypeSPARQLUpdate, OperationName.Update);
+ contentTypeToOperation.put(WebContent.contentTypeSPARQLQuery, Operation.Query);
+ contentTypeToOperation.put(WebContent.contentTypeSPARQLUpdate, Operation.Update);
}
- /** Map {@link OperationName} to servlet handler.
- * {@code OperartionNames} are the internal symbol identifying an operation,
- * not the name used in the configuration file, which is mapped by {@link DataService#getOperation}.
- *
- * */
- public static Map<OperationName, ActionSPARQL> OpNameToHandler = new ConcurrentHashMap<>();
+ /** Map {@link Operation} to servlet handler.
+ * {@code Operation}s are the internal symbol identifying an operation,
+ * not the name used in the configuration file,
+ * which is mapped by {@link DataService#getEndpoint(String)}.
+ */
+ public static Map<Operation, ActionService> operationToHandler = new ConcurrentHashMap<>();
- public static final ActionSPARQL queryServlet = new SPARQL_QueryDataset() ;
- public static final ActionSPARQL updateServlet = new SPARQL_Update() ;
- public static final ActionSPARQL uploadServlet = new SPARQL_Upload() ;
- public static final ActionSPARQL gspServlet_R = new SPARQL_GSP_R() ;
- public static final ActionSPARQL gspServlet_RW = new SPARQL_GSP_RW() ;
- public static final ActionSPARQL restQuads_R = new REST_Quads_R() ;
- public static final ActionSPARQL restQuads_RW = new REST_Quads_RW() ;
+ public static final ActionService queryServlet = new SPARQL_QueryDataset() ;
+ public static final ActionService updateServlet = new SPARQL_Update() ;
+ public static final ActionService uploadServlet = new SPARQL_Upload() ;
+ public static final ActionService gspServlet_R = new SPARQL_GSP_R() ;
+ public static final ActionService gspServlet_RW = new SPARQL_GSP_RW() ;
+ public static final ActionService restQuads_R = new REST_Quads_R() ;
+ public static final ActionService restQuads_RW = new REST_Quads_RW() ;
static {
- OpNameToHandler.put(OperationName.Query, queryServlet);
- OpNameToHandler.put(OperationName.Update, updateServlet);
- OpNameToHandler.put(OperationName.Upload, uploadServlet);
- OpNameToHandler.put(OperationName.GSP_R, gspServlet_R);
- OpNameToHandler.put(OperationName.GSP_RW, gspServlet_RW);
- OpNameToHandler.put(OperationName.Quads_R, restQuads_R);
- OpNameToHandler.put(OperationName.Quads_RW, restQuads_RW);
+ operationToHandler.put(Operation.Query, queryServlet);
+ operationToHandler.put(Operation.Update, updateServlet);
+ operationToHandler.put(Operation.Upload, uploadServlet);
+ operationToHandler.put(Operation.GSP_R, gspServlet_R);
+ operationToHandler.put(Operation.GSP_RW, gspServlet_RW);
+ operationToHandler.put(Operation.Quads_R, restQuads_R);
+ operationToHandler.put(Operation.Quads_RW, restQuads_RW);
}
}
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/FusekiFilter.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/FusekiFilter.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/FusekiFilter.java
index 44ab013..e13fc04 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/FusekiFilter.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/FusekiFilter.java
@@ -35,7 +35,7 @@ import org.slf4j.Logger ;
*/
public class FusekiFilter implements Filter {
private static Logger log = Fuseki.serverLog ;
- private static ServiceRouterServlet routerServlet = new ServiceRouterServlet.AccessByConfig() ;
+ private static ServiceRouter routerServlet = new ServiceRouter.AccessByConfig() ;
@Override
public void init(FilterConfig filterConfig) {
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
index 6dfb1ee..55e32c2 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
@@ -41,7 +41,7 @@ import org.slf4j.Logger ;
/**
* HTTP action that represents the user request lifecycle. Its state is handled in the
- * {@link ActionSPARQL#executeAction(HttpAction)} method.
+ * {@link ActionService#executeAction(HttpAction)} method.
*/
public class HttpAction
{
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
index 05143fd..ae5ef8f 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
@@ -37,7 +37,7 @@ import org.apache.jena.sparql.core.DatasetDescription ;
/**
* Support for the SPARQL protocol (SPARQL Query, SPARQL Update)
*/
-public abstract class SPARQL_Protocol extends ActionSPARQL {
+public abstract class SPARQL_Protocol extends ActionService {
protected SPARQL_Protocol() {
super() ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet_Original.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet_Original.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet_Original.java
index e10b908..142ba0c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet_Original.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet_Original.java
@@ -47,7 +47,7 @@ import org.apache.jena.riot.web.HttpNames ;
* indirect naming, quads operations on a dataset and
* ?query and ?update directly on a dataset.)
*/
-public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
+public abstract class SPARQL_UberServlet_Original extends ActionService
{
protected abstract boolean allowQuery(HttpAction action) ;
protected abstract boolean allowUpdate(HttpAction action) ;
@@ -58,7 +58,7 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
public static class ReadOnly extends SPARQL_UberServlet_Original
{
- public ReadOnly() { super() ; }
+ public ReadOnly() { super() ; }
@Override protected boolean allowQuery(HttpAction action) { return true ; }
@Override protected boolean allowUpdate(HttpAction action) { return false ; }
@Override protected boolean allowREST_R(HttpAction action) { return true ; }
@@ -69,7 +69,7 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
public static class ReadWrite extends SPARQL_UberServlet_Original
{
- public ReadWrite() { super() ; }
+ public ReadWrite() { super() ; }
@Override protected boolean allowQuery(HttpAction action) { return true ; }
@Override protected boolean allowUpdate(HttpAction action) { return true ; }
@Override protected boolean allowREST_R(HttpAction action) { return true ; }
@@ -80,23 +80,23 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
public static class AccessByConfig extends SPARQL_UberServlet_Original
{
- public AccessByConfig() { super() ; }
- @Override protected boolean allowQuery(HttpAction action) { return isEnabled(action, OperationName.Query) ; }
- @Override protected boolean allowUpdate(HttpAction action) { return isEnabled(action, OperationName.Update) ; }
- @Override protected boolean allowREST_R(HttpAction action) { return isEnabled(action, OperationName.GSP_R) || isEnabled(action, OperationName.GSP_RW) ; }
- @Override protected boolean allowREST_W(HttpAction action) { return isEnabled(action, OperationName.GSP_RW) ; }
- @Override protected boolean allowQuadsR(HttpAction action) { return isEnabled(action, OperationName.Quads_R) || isEnabled(action, OperationName.Quads_RW) ; }
- @Override protected boolean allowQuadsW(HttpAction action) { return isEnabled(action, OperationName.Quads_RW) ; }
+ public AccessByConfig() { super() ; }
+ @Override protected boolean allowQuery(HttpAction action) { return isEnabled(action, Operation.Query) ; }
+ @Override protected boolean allowUpdate(HttpAction action) { return isEnabled(action, Operation.Update) ; }
+ @Override protected boolean allowREST_R(HttpAction action) { return isEnabled(action, Operation.GSP_R) || isEnabled(action, Operation.GSP_RW) ; }
+ @Override protected boolean allowREST_W(HttpAction action) { return isEnabled(action, Operation.GSP_RW) ; }
+ @Override protected boolean allowQuadsR(HttpAction action) { return isEnabled(action, Operation.Quads_R) || isEnabled(action, Operation.Quads_RW) ; }
+ @Override protected boolean allowQuadsW(HttpAction action) { return isEnabled(action, Operation.Quads_RW) ; }
// Test whether there is a configuration that allows this action as the operation given.
// Ignores the operation in the action (set due to parsing - it might be "quads"
// which is the generic operation when just the dataset is specificed.
- private boolean isEnabled(HttpAction action, OperationName opName) {
+ private boolean isEnabled(HttpAction action, Operation operation) {
// Disregard the operation name of the action
DataService dSrv = action.getDataService() ;
if ( dSrv == null )
return false;
- return ! dSrv.getOperation(opName).isEmpty() ;
+ return ! dSrv.getEndpoints(operation).isEmpty() ;
}
}
@@ -106,13 +106,13 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
* This takes precedence over direct naming.
*/
- private final ActionSPARQL queryServlet = new SPARQL_QueryDataset() ;
- private final ActionSPARQL updateServlet = new SPARQL_Update() ;
- private final ActionSPARQL uploadServlet = new SPARQL_Upload() ;
- private final ActionSPARQL gspServlet_R = new SPARQL_GSP_R() ;
- private final ActionSPARQL gspServlet_RW = new SPARQL_GSP_RW() ;
- private final ActionSPARQL restQuads_R = new REST_Quads_R() ;
- private final ActionSPARQL restQuads_RW = new REST_Quads_RW() ;
+ private final ActionService queryServlet = new SPARQL_QueryDataset() ;
+ private final ActionService updateServlet = new SPARQL_Update() ;
+ private final ActionService uploadServlet = new SPARQL_Upload() ;
+ private final ActionService gspServlet_R = new SPARQL_GSP_R() ;
+ private final ActionService gspServlet_RW = new SPARQL_GSP_RW() ;
+ private final ActionService restQuads_R = new REST_Quads_R() ;
+ private final ActionService restQuads_RW = new REST_Quads_RW() ;
public SPARQL_UberServlet_Original() { super(); }
@@ -264,19 +264,19 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
// There is a trailing part.
// Check it's not the same name as a registered service.
// If so, dispatch to that service.
- if ( serviceDispatch(action, OperationName.Query, queryServlet) ) return ;
- if ( serviceDispatch(action, OperationName.Update, updateServlet) ) return ;
- if ( serviceDispatch(action, OperationName.Upload, uploadServlet) ) return ;
+ if ( serviceDispatch(action, Operation.Query, queryServlet) ) return ;
+ if ( serviceDispatch(action, Operation.Update, updateServlet) ) return ;
+ if ( serviceDispatch(action, Operation.Upload, uploadServlet) ) return ;
if ( hasParams ) {
- if ( serviceDispatch(action, OperationName.GSP_R, gspServlet_R) ) return ;
- if ( serviceDispatch(action, OperationName.GSP_RW, gspServlet_RW) ) return ;
+ if ( serviceDispatch(action, Operation.GSP_R, gspServlet_R) ) return ;
+ if ( serviceDispatch(action, Operation.GSP_RW, gspServlet_RW) ) return ;
} else {
// No parameters - do as a quads operation on the dataset.
- if ( serviceDispatch(action, OperationName.GSP_R, restQuads_R) ) return ;
- if ( serviceDispatch(action, OperationName.GSP_RW, restQuads_RW) ) return ;
+ if ( serviceDispatch(action, Operation.GSP_R, restQuads_R) ) return ;
+ if ( serviceDispatch(action, Operation.GSP_RW, restQuads_RW) ) return ;
}
- if ( serviceDispatch(action, OperationName.Quads_RW, restQuads_RW) ) return ;
- if ( serviceDispatch(action, OperationName.Quads_R, restQuads_R) ) return ;
+ if ( serviceDispatch(action, Operation.Quads_RW, restQuads_RW) ) return ;
+ if ( serviceDispatch(action, Operation.Quads_R, restQuads_R) ) return ;
}
// There is a trailing part - params are illegal by this point.
if ( hasParams )
@@ -296,11 +296,11 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
/** See if the operation is enabled for this setup.
* Return true if dispatched
*/
- private boolean serviceDispatch(HttpAction action, OperationName opName, ActionSPARQL servlet) {
- Endpoint operation = action.getEndpoint() ;
- if ( operation == null )
+ private boolean serviceDispatch(HttpAction action, Operation operation, ActionService servlet) {
+ Endpoint endpoint = action.getEndpoint() ;
+ if ( endpoint == null )
return false ;
- if ( ! operation.isType(opName) )
+ if ( ! endpoint.isType(operation) )
return false ;
// Handle OPTIONS specially.
// if ( action.getRequest().getMethod().equals(HttpNames.METHOD_OPTIONS) ) {
@@ -345,9 +345,9 @@ public abstract class SPARQL_UberServlet_Original extends ActionSPARQL
return ;
}
- private void executeRequest(HttpAction action, ActionSPARQL servlet) {
+ private void executeRequest(HttpAction action, ActionService servlet) {
if ( true ) {
- // Execute an ActionSPARQL.
+ // Execute an ActionService.
// Bypasses HttpServlet.service to doMethod dispatch.
servlet.executeLifecycle(action) ;
return ;
http://git-wip-us.apache.org/repos/asf/jena/blob/1533ade6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
index e369f3a..14d4095 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
@@ -49,7 +49,7 @@ import org.apache.jena.sparql.core.DatasetGraphFactory ;
import org.apache.jena.sparql.core.Quad ;
import org.apache.jena.web.HttpSC ;
-public class SPARQL_Upload extends ActionSPARQL
+public class SPARQL_Upload extends ActionService
{
public SPARQL_Upload() {
super() ;