jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [16/19] jena git commit: Fixes up based on comments on PR#463
Date Mon, 20 Aug 2018 07:39:15 GMT
Fixes up based on comments on PR#463


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/08ef457a
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/08ef457a
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/08ef457a

Branch: refs/heads/master
Commit: 08ef457a44e6f8491bdea84c798c7af5c73925d9
Parents: 3b153d5
Author: Andy Seaborne <andy@apache.org>
Authored: Fri Aug 17 13:22:53 2018 +0100
Committer: Andy Seaborne <andy@apache.org>
Committed: Fri Aug 17 13:22:53 2018 +0100

----------------------------------------------------------------------
 .../org/apache/jena/sparql/util/NodeUtils.java  |  14 +-
 .../jena/fuseki/servlets/ServiceRouter.java     |   2 +-
 .../jena/fuseki/embedded/FusekiServer.java      | 170 ++++++++++---------
 3 files changed, 99 insertions(+), 87 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/08ef457a/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java
index 5dd1d6f..a505c8f 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/NodeUtils.java
@@ -18,7 +18,11 @@
 
 package org.apache.jena.sparql.util;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
 
 import org.apache.jena.atlas.lib.ListUtils;
 import org.apache.jena.atlas.lib.StrUtils ;
@@ -102,7 +106,7 @@ public class NodeUtils
         Iterator<String> conv = new MapFilterIterator<>(mapper, eIter) ;
         return conv ;
     }
-    
+
     /** Convert a collection of strings to a collection of {@link Node Nodes}. */ 
     public static Collection<Node> convertToNodes(Collection<String> namedGraphs)
{
         List<Node> nodes = ListUtils.toList(
@@ -118,7 +122,7 @@ public class NodeUtils
             );
         return nodes;
     }
-    
+
     /** Compare two Nodes, based on their RDF terms forms, not value */
     public static int compareRDFTerms(Node node1, Node node2) {
         if ( node1 == null ) {
@@ -200,7 +204,7 @@ public class NodeUtils
      *  <li> Datatypes by URI
      *  </ol>
      */
-    
+
     private static int compareLiteralsBySyntax(Node node1, Node node2) {
         if ( node1 == null || !node1.isLiteral() || node2 == null || !node2.isLiteral() )
             throw new ARQInternalErrorException("compareLiteralsBySyntax called with non-literal:
(" + node1 + "," + node2 + ")") ;
@@ -248,7 +252,7 @@ public class NodeUtils
         // Two datatypes.
         return StrUtils.strCompare(dt1, dt2) ;
     }
-    
+
     /**
      * A Node is a simple string if: 
      * <li>(RDF 1.0) No datatype and no language tag

http://git-wip-us.apache.org/repos/asf/jena/blob/08ef457a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServiceRouter.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServiceRouter.java
b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServiceRouter.java
index c54a69b..9a3a2b2 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServiceRouter.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ServiceRouter.java
@@ -124,7 +124,7 @@ public abstract class ServiceRouter extends ActionService {
          * Test whether there is a configuration that allows this action as the operation
          * given. Ignores the operation in the action which is set due to parsing - it
          * might be "quads" which is the generic operation when just the dataset is
-         * specificed.
+         * specified.
          */
         private boolean isEnabled(HttpAction action, Operation operation) {
             // Disregard the operation name of the action

http://git-wip-us.apache.org/repos/asf/jena/blob/08ef457a/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiServer.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiServer.java
b/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiServer.java
index 9d68be0..3c84fd3 100644
--- a/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiServer.java
+++ b/jena-fuseki2/jena-fuseki-embedded/src/main/java/org/apache/jena/fuseki/embedded/FusekiServer.java
@@ -20,7 +20,11 @@ package org.apache.jena.fuseki.embedded;
 
 import static java.util.Objects.requireNonNull;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 import javax.servlet.Filter;
 import javax.servlet.ServletContext;
@@ -35,7 +39,11 @@ import org.apache.jena.fuseki.build.FusekiConfig;
 import org.apache.jena.fuseki.ctl.ActionPing;
 import org.apache.jena.fuseki.ctl.ActionStats;
 import org.apache.jena.fuseki.jetty.FusekiErrorHandler1;
-import org.apache.jena.fuseki.server.*;
+import org.apache.jena.fuseki.server.DataAccessPoint;
+import org.apache.jena.fuseki.server.DataAccessPointRegistry;
+import org.apache.jena.fuseki.server.DataService;
+import org.apache.jena.fuseki.server.FusekiVocab;
+import org.apache.jena.fuseki.server.Operation;
 import org.apache.jena.fuseki.servlets.ActionService;
 import org.apache.jena.fuseki.servlets.FusekiFilter;
 import org.apache.jena.fuseki.servlets.ServiceDispatchRegistry;
@@ -57,7 +65,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
 
 /**
- * Embedded Fuseki server. This is a Fuseki server running with a preconfigured set of
+ * Embedded Fuseki server. This is a Fuseki server running with a pre-configured set of
  * datasets and services. There is no admin UI and no security.
  * <p>
  * To create a embedded sever, use {@link FusekiServer} ({@link #make} is a
@@ -65,7 +73,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
  * responding to localhost only).
  * <p>
  * The application should call {@link #start()} to actually start the server
- * (it wil run in the background : see {@link #join}).
+ * (it will run in the background : see {@link #join}).
  * <p>Example:
  * <pre>
  *      DatasetGraph dsg = ...;
@@ -79,13 +87,13 @@ import org.eclipse.jetty.servlet.ServletHolder;
  * <pre>
  *    FusekiServer.make(1234, "/ds", dsg).start();
  * </pre>
- * 
+ *
  */
 public class FusekiServer {
     /** Construct a Fuseki server for one dataset.
-     * It only responds to localhost. 
-     * The returned server has not been started. 
-     */ 
+     * It only responds to localhost.
+     * The returned server has not been started.
+     */
     static public FusekiServer make(int port, String name, DatasetGraph dsg) {
         return create()
             .port(port)
@@ -93,60 +101,60 @@ public class FusekiServer {
             .add(name, dsg)
             .build();
     }
-    
+
     public static Builder create() {
         return new Builder();
     }
-    
+
     public final Server server;
     private int port;
-    
+
     private FusekiServer(int port, Server server) {
         this.server = server;
         // This should be the same.
         //this.port = ((ServerConnector)server.getConnectors()[0]).getPort();
         this.port = port;
     }
-    
-    /** 
-     * Return the port begin used.  
+
+    /**
+     * Return the port begin used.
      * This will be the give port, which defaults to 3330, or
      * the one actually allocated if the port was 0 ("choose a free port").
      */
     public int getPort() {
-        return port; 
+        return port;
     }
 
-    /** Get the underlying Jetty server which has also been set up. */ 
+    /** Get the underlying Jetty server which has also been set up. */
     public Server getJettyServer() {
-        return server; 
+        return server;
     }
-    
+
     /** Get the {@link ServletContext}.
      * Adding new servlets is possible with care.
-     */ 
+     */
     public ServletContext getServletContext() {
         return ((ServletContextHandler)server.getHandler()).getServletContext();
     }
 
     /** Get the {@link DataAccessPointRegistry}.
      * This method is intended for inspecting the registry.
-     */ 
+     */
     public DataAccessPointRegistry getDataAccessPointRegistry() {
         return DataAccessPointRegistry.get(getServletContext());
     }
 
     /** Get the {@link DataAccessPointRegistry}.
      * This method is intended for inspecting the registry.
-     */ 
+     */
     public ServiceDispatchRegistry getServiceDispatchRegistry() {
         return ServiceDispatchRegistry.get(getServletContext());
     }
 
     /** Start the server - the server continues to run after this call returns.
-     *  To synchronise with the server stopping, call {@link #join}.  
+     *  To synchronise with the server stopping, call {@link #join}.
      */
-    public FusekiServer start() { 
+    public FusekiServer start() {
         try { server.start(); }
         catch (Exception e) { throw new FusekiException(e); }
         if ( port == 0 )
@@ -156,18 +164,18 @@ public class FusekiServer {
     }
 
     /** Stop the server. */
-    public void stop() { 
+    public void stop() {
         Fuseki.serverLog.info("Stop Fuseki (port="+port+")");
         try { server.stop(); }
         catch (Exception e) { throw new FusekiException(e); }
     }
-    
+
     /** Wait for the server to exit. This call is blocking. */
     public void join() {
         try { server.join(); }
         catch (Exception e) { throw new FusekiException(e); }
     }
-    
+
     /** FusekiServer.Builder */
     public static class Builder {
         private DataAccessPointRegistry  dataAccessPoints   = new DataAccessPointRegistry();
@@ -188,39 +196,39 @@ public class FusekiServer {
         private Map<String, Object>      servletAttr        = new HashMap<>();
 
         /** Set the port to run on.
-         * @deprecated Use {@link #port}. 
+         * @deprecated Use {@link #port}.
          */
         @Deprecated
         public Builder setPort(int port) {
             return port(port);
         }
-        
-        /** Set the port to run on. */ 
+
+        /** Set the port to run on. */
         public Builder port(int port) {
             if ( port < 0 )
                 throw new IllegalArgumentException("Illegal port="+port+" : Port must be
greater than or equal to zero.");
             this.port = port;
             return this;
         }
-        
+
         /** Context path to Fuseki.  If it's "/" then Fuseki URL look like
-         * "http://host:port/dataset/query" else "http://host:port/path/dataset/query" 
-         * @deprecated Use {@link #contextPath}. 
+         * "http://host:port/dataset/query" else "http://host:port/path/dataset/query"
+         * @deprecated Use {@link #contextPath}.
          */
         @Deprecated
         public Builder setContextPath(String path) {
             return contextPath(path);
         }
-        
+
         /** Context path to Fuseki.  If it's "/" then Fuseki URL look like
-         * "http://host:port/dataset/query" else "http://host:port/path/dataset/query" 
+         * "http://host:port/dataset/query" else "http://host:port/path/dataset/query"
          */
         public Builder contextPath(String path) {
             requireNonNull(path, "path");
             this.contextPath = path;
             return this;
         }
-        
+
         /** Restrict the server to only responding to the localhost interface.
          *  @deprecated Use {@link #loopback}.
          */
@@ -229,7 +237,7 @@ public class FusekiServer {
             return loopback(loopback);
         }
 
-        /** Restrict the server to only responding to the localhost interface. */ 
+        /** Restrict the server to only responding to the localhost interface. */
         public Builder loopback(boolean loopback) {
             this.loopback = loopback;
             return this;
@@ -242,8 +250,8 @@ public class FusekiServer {
         public Builder setStaticFileBase(String directory) {
             return staticFileBase(directory);
         }
-        
-        /** Set the location (filing system directory) to serve static file from. */ 
+
+        /** Set the location (filing system directory) to serve static file from. */
         public Builder staticFileBase(String directory) {
             requireNonNull(directory, "directory");
             this.staticContentDir = directory;
@@ -259,25 +267,25 @@ public class FusekiServer {
         public Builder setSecurityHandler(SecurityHandler securityHandler) {
             return securityHandler(securityHandler);
         }
-        
+
         /** Set a Jetty SecurityHandler.
          * <p>
          *  By default, the server runs with no security.
          *  This is more for using the basic server for testing.
          *  The full Fuseki server provides security with Apache Shiro
          *  and a defensive reverse proxy (e.g. Apache httpd) in front of the Jetty server
-         *  can also be used, which provides a wide variety of proven security options. 
 
+         *  can also be used, which provides a wide variety of proven security options.
          */
         public Builder securityHandler(SecurityHandler securityHandler) {
             requireNonNull(securityHandler, "securityHandler");
             this.securityHandler = securityHandler;
             return this;
         }
-        
 
-        /** Set verbose logging 
+        /** Set verbose logging
          *  @deprecated Use {@link #verbose(boolean)}.
          */
+        @Deprecated
         public Builder setVerbose(boolean verbose) {
             return verbose(verbose);
         }
@@ -290,57 +298,57 @@ public class FusekiServer {
 
         /** Add the "/$/stats" servlet that responds with stats about the server,
          * including counts of all calls made.
-         */ 
+         */
         public Builder enableStats(boolean withStats) {
             this.withStats = withStats;
             return this;
         }
 
         /** Add the "/$/ping" servlet that responds to HTTP very efficiently.
-         * This is useful for testing whether a server is alive, for example, from a load
balancer.  
-         */ 
+         * This is useful for testing whether a server is alive, for example, from a load
balancer.
+         */
         public Builder enablePing(boolean withPing) {
             this.withPing = withPing;
             return this;
         }
-        /** Add the dataset with given name and a default set of services including update
*/  
+        /** Add the dataset with given name and a default set of services including update
*/
         public Builder add(String name, Dataset dataset) {
             requireNonNull(name, "name");
             requireNonNull(dataset, "dataset");
             return add(name, dataset.asDatasetGraph());
         }
 
-        /** Add the dataset with given name and a default set of services including update
*/  
+        /** Add the dataset with given name and a default set of services including update
*/
         public Builder add(String name, DatasetGraph dataset) {
             requireNonNull(name, "name");
             requireNonNull(dataset, "dataset");
             return add(name, dataset, true);
         }
 
-        /** Add the dataset with given name and a default set of services. */  
+        /** Add the dataset with given name and a default set of services. */
         public Builder add(String name, Dataset dataset, boolean allowUpdate) {
             requireNonNull(name, "name");
             requireNonNull(dataset, "dataset");
             return add(name, dataset.asDatasetGraph(), allowUpdate);
         }
-        
-        /** Add the dataset with given name and a default set of services. */  
+
+        /** Add the dataset with given name and a default set of services. */
         public Builder add(String name, DatasetGraph dataset, boolean allowUpdate) {
             requireNonNull(name, "name");
             requireNonNull(dataset, "dataset");
-            DataService dSrv = FusekiBuilder.buildDataServiceStd(dataset, allowUpdate); 
+            DataService dSrv = FusekiBuilder.buildDataServiceStd(dataset, allowUpdate);
             return add(name, dSrv);
         }
-        
+
         /** Add a data service that includes dataset and service names.
          * A {@link DataService} allows for choices of the various endpoint names.
-         */  
+         */
         public Builder add(String name, DataService dataService) {
             requireNonNull(name, "name");
             requireNonNull(dataService, "dataService");
-            return add$(name, dataService); 
+            return add$(name, dataService);
         }
-        
+
         private Builder add$(String name, DataService dataService) {
             name = DataAccessPoint.canonical(name);
             if ( dataAccessPoints.isRegistered(name) )
@@ -354,18 +362,18 @@ public class FusekiServer {
          *  <p>
          *  The application is responsible for ensuring a correct classpath. For example,
          *  including a dependency on {@code jena-text} if the configuration file
-         *  includes a text index.     
+         *  includes a text index.
          */
         public Builder parseConfigFile(String filename) {
             requireNonNull(filename, "filename");
             Model model = AssemblerUtils.readAssemblerFile(filename);
-            
+
             // Process server context
             Resource server = GraphUtils.getResourceByType(model, FusekiVocab.tServer);
             if ( server != null )
                 AssemblerUtils.setContext(server, Fuseki.getContext()) ;
 
-            // Process services, whether via server ja:services or, if absent, by finding
by type. 
+            // Process services, whether via server ja:services or, if absent, by finding
by type.
             List<DataAccessPoint> x = FusekiConfig.servicesAndDatasets(model);
             // Unbundle so that they accumulate.
             x.forEach(dap->add(dap.getName(), dap.getDataService()));
@@ -383,11 +391,11 @@ public class FusekiServer {
             servlets.add(Pair.create(pathSpec, servlet));
             return this;
         }
-        
+
         /**
          * Add a servlet attribute. Pass a value of null to remove any existing binding.
          */
-        
+
         public Builder addServletAttribute(String attrName, Object value) {
             requireNonNull(attrName, "attrName");
             if ( value != null )
@@ -396,7 +404,7 @@ public class FusekiServer {
                 servletAttr.remove(attrName);
             return this;
         }
-        
+
         /**
          * Add a filter with the pathSpec.
          */
@@ -406,13 +414,13 @@ public class FusekiServer {
             filters.add(Pair.create(pathSpec, filter));
             return this;
         }
-        
+
         /**
          * Add an operation and handler to the server. This does not enable it for any dataset.
          * <p>
          * To associate an operation with a dataset, call {@link #addOperation} after adding
the dataset.
-         * 
-         * @see #addOperation 
+         *
+         * @see #addOperation
          */
         public Builder registerOperation(Operation operation, ActionService handler) {
             registerOperation(operation, null, handler);
@@ -422,9 +430,9 @@ public class FusekiServer {
         /**
          * Add an operation to the server, together with its triggering Content-Type (may
be null) and servlet handler.
          * <p>
-         * To associate an operation with a dataset, call {@link #addOperation} after adding
the dataset. 
+         * To associate an operation with a dataset, call {@link #addOperation} after adding
the dataset.
          *
-         * @see #addOperation 
+         * @see #addOperation
          */
         public Builder registerOperation(Operation operation, String contentType, ActionService
handler) {
             Objects.requireNonNull(operation, "operation");
@@ -434,21 +442,21 @@ public class FusekiServer {
             serviceDispatch.register(operation, contentType, handler);
             return this;
         }
-        
-        /** 
-         * Create an endpoint on the dataset. 
+
+        /**
+         * Create an endpoint on the dataset.
          * The operation must already be registered with the builder.
-         * @see #registerOperation(Operation, ActionService) 
+         * @see #registerOperation(Operation, ActionService)
          */
         public Builder addOperation(String datasetName, String endpointName, Operation operation)
{
             Objects.requireNonNull(datasetName, "datasetName");
             Objects.requireNonNull(endpointName, "endpointName");
-            
+
             String name = DataAccessPoint.canonical(datasetName);
-            
+
             if ( ! serviceDispatch.isRegistered(operation) )
                 throw new FusekiConfigException("Operation not registered: "+operation.getName());
-            
+
             if ( ! dataAccessPoints.isRegistered(name) )
                 throw new FusekiConfigException("Dataset not registered: "+datasetName);
             DataAccessPoint dap = dataAccessPoints.get(name);
@@ -465,16 +473,16 @@ public class FusekiServer {
             ServletContext cxt = handler.getServletContext();
             Fuseki.setVerbose(cxt, verbose);
             servletAttr.forEach((n,v)->cxt.setAttribute(n, v));
-            // Clone to isolate from any future changes. 
+            // Clone to isolate from any future changes.
             ServiceDispatchRegistry.set(cxt, new ServiceDispatchRegistry(serviceDispatch));
             DataAccessPointRegistry.set(cxt, new DataAccessPointRegistry(dataAccessPoints));
 
             // Start services.
             DataAccessPointRegistry.get(cxt).forEach((name, dap)->dap.getDataService().goActive());
-            
+
             setMimeTypes(handler);
             servlets(handler);
-            
+
             Server server = jettyServer(port, loopback);
             server.setHandler(handler);
             return new FusekiServer(port, server);
@@ -492,10 +500,10 @@ public class FusekiServer {
             context.setContextPath(contextPath);
             if ( securityHandler != null )
                 context.setSecurityHandler(securityHandler);
-            
+
             return context;
         }
-        
+
         private static void setMimeTypes(ServletContextHandler context) {
             MimeTypes mimeTypes = new MimeTypes();
             // RDF syntax
@@ -530,12 +538,12 @@ public class FusekiServer {
             // This goes as the filter at the end of any filter chaining.
             FusekiFilter ff = new FusekiFilter();
             addFilter(context, "/*", ff);
-            
+
             if ( withStats )
                 addServlet(context, "/$/stats", new ActionStats());
             if ( withPing )
                 addServlet(context, "/$/ping", new ActionPing());
-            
+
             servlets.forEach(p->addServlet(context, p.getLeft(), p.getRight()));
             filters.forEach (p-> addFilter(context, p.getLeft(), p.getRight()));
 
@@ -546,7 +554,7 @@ public class FusekiServer {
                 context.addServlet(staticContent, "/");
             }
         }
-        
+
         private static void addServlet(ServletContextHandler context, String pathspec, HttpServlet
httpServlet) {
             ServletHolder sh = new ServletHolder(httpServlet);
             context.addServlet(sh, pathspec);


Mime
View raw message