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 2016/09/02 12:10:35 UTC

[1/3] jena git commit: Reformat

Repository: jena
Updated Branches:
  refs/heads/master e91ee3ba0 -> 1d5f0dc68


Reformat

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

Branch: refs/heads/master
Commit: 171d471ff9494169d61a1c67bf49a3337ca259bc
Parents: e91ee3b
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Sep 2 10:18:04 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Sep 2 10:18:04 2016 +0100

----------------------------------------------------------------------
 .../jena/sparql/util/graph/GraphUtils.java      | 139 +++++++++----------
 1 file changed, 63 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/171d471f/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java
index eae8384..6ce823a 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/util/graph/GraphUtils.java
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.jena.sparql.util.graph;
+package org.apache.jena.sparql.util.graph ;
 
 import java.util.ArrayList ;
 import java.util.HashSet ;
@@ -39,13 +39,13 @@ import org.apache.jena.sparql.util.TypeNotUniqueException ;
 import org.apache.jena.util.iterator.ExtendedIterator ;
 import org.apache.jena.vocabulary.RDF ;
 
-/** Graph utilities.  See also GraphFactory. */ 
+/** Graph utilities. See also GraphFactory. */
 
-public class GraphUtils
-{
-    /** Convert an iterator of triples into quads for the default graph.
-     * This is {@link Quad#defaultGraphIRI}, not {@link Quad#defaultGraphNodeGenerated},
-     * which is for quads outside a dataset, usually the output of parsers. 
+public class GraphUtils {
+    /**
+     * Convert an iterator of triples into quads for the default graph. This is
+     * {@link Quad#defaultGraphIRI}, not {@link Quad#defaultGraphNodeGenerated}, which is
+     * for quads outside a dataset, usually the output of parsers.
      */
     public static Iterator<Quad> triples2quadsDftGraph(Iterator<Triple> iter) {
         return triples2quads(Quad.defaultGraphIRI, iter) ;
@@ -56,113 +56,104 @@ public class GraphUtils
         return Iter.iter(iter).map(t -> new Quad(graphNode, t)) ;
     }
 
-    public static List<String> multiValueString(Resource r, Property p)
-    {
+    public static List<String> multiValueString(Resource r, Property p) {
         List<RDFNode> nodes = multiValue(r, p) ;
         List<String> values = new ArrayList<>() ;
 
-        for ( RDFNode n : nodes )
-        {
-            if ( n.isLiteral() )
-            {
-                values.add( ( (Literal) n ).getString() );
+        for ( RDFNode n : nodes ) {
+            if ( n.isLiteral() ) {
+                values.add(((Literal)n).getString()) ;
             }
         }
         return values ;
     }
 
-    public static List<RDFNode> multiValue(Resource r, Property p)
-    {
+    public static List<RDFNode> multiValue(Resource r, Property p) {
         List<RDFNode> values = new ArrayList<>() ;
         StmtIterator sIter = r.listProperties(p) ;
-        while(sIter.hasNext())
-        {
+        while (sIter.hasNext()) {
             Statement s = sIter.nextStatement() ;
             values.add(s.getObject()) ;
         }
-        return values;
+        return values ;
     }
-    
-    public static List<Resource> multiValueResource(Resource r, Property p)
-    {
+
+    public static List<Resource> multiValueResource(Resource r, Property p) {
         List<RDFNode> nodes = multiValue(r, p) ;
         List<Resource> values = new ArrayList<>() ;
 
-        for ( RDFNode n : nodes )
-        {
-            if ( n.isResource() )
-            {
-                values.add( (Resource) n );
+        for ( RDFNode n : nodes ) {
+            if ( n.isResource() ) {
+                values.add((Resource)n) ;
             }
         }
         return values ;
     }
 
-    public static List<String> multiValueURI(Resource r, Property p)
-    {
+    public static List<String> multiValueURI(Resource r, Property p) {
         List<RDFNode> nodes = multiValue(r, p) ;
         List<String> values = new ArrayList<>() ;
 
-        for ( RDFNode n : nodes )
-        {
-            if ( n.isURIResource() )
-            {
-                values.add( ( (Resource) n ).getURI() );
+        for ( RDFNode n : nodes ) {
+            if ( n.isURIResource() ) {
+                values.add(((Resource)n).getURI()) ;
             }
         }
         return values ;
     }
 
-    public static boolean exactlyOneProperty(Resource r, Property p)
-    {
+    public static boolean exactlyOneProperty(Resource r, Property p) {
         StmtIterator sIter = r.listProperties(p) ;
         try {
-            if ( ! sIter.hasNext() )
+            if ( !sIter.hasNext() )
                 throw new PropertyRequiredException(r, p) ;
             sIter.next() ;
             if ( sIter.hasNext() )
                 throw new NotUniqueException(r, p) ;
-        } finally { sIter.close() ; } 
+        }
+        finally {
+            sIter.close() ;
+        }
         return true ;
     }
 
-    public static boolean atmostOneProperty(Resource r, Property p)
-    {
+    public static boolean atmostOneProperty(Resource r, Property p) {
         StmtIterator sIter = r.listProperties(p) ;
         try {
-            if ( ! sIter.hasNext() ) return true ;
+            if ( !sIter.hasNext() )
+                return true ;
             sIter.next() ;
             if ( sIter.hasNext() )
                 throw new NotUniqueException(r, p) ;
-        } finally { sIter.close() ; } 
+        }
+        finally {
+            sIter.close() ;
+        }
         return true ;
     }
 
-    public static String getStringValue(Resource r, Property p)
-    {
-        if ( ! atmostOneProperty(r, p) )
+    public static String getStringValue(Resource r, Property p) {
+        if ( !atmostOneProperty(r, p) )
             throw new NotUniqueException(r, p) ;
         Statement s = r.getProperty(p) ;
         if ( s == null )
             return null ;
-        return s.getString() ; 
+        return s.getString() ;
     }
 
-    public static String getAsStringValue(Resource r, Property p)
-    {
-        if ( ! atmostOneProperty(r, p) )
+    public static String getAsStringValue(Resource r, Property p) {
+        if ( !atmostOneProperty(r, p) )
             throw new NotUniqueException(r, p) ;
         Statement s = r.getProperty(p) ;
         if ( s == null )
             return null ;
         if ( s.getObject().isResource() )
             return s.getResource().getURI() ;
-        return s.getString() ; 
+        return s.getString() ;
     }
 
-    public static Resource getResourceValue(Resource r, Property p)
-    {
-        if ( ! atmostOneProperty(r, p) )
+    public static Resource getResourceValue(Resource r, Property p) {
+        if ( !atmostOneProperty(r, p) )
             throw new NotUniqueException(r, p) ;
         Statement s = r.getProperty(p) ;
         if ( s == null )
@@ -170,46 +161,42 @@ public class GraphUtils
         return s.getResource() ;
     }
 
-    public static Resource getResourceByType(Model model, Resource type)
-    {
-        // See also 
+    public static Resource getResourceByType(Model model, Resource type) {
+        // See also
         StmtIterator sIter = model.listStatements(null, RDF.type, type) ;
-        if ( ! sIter.hasNext() )
+        if ( !sIter.hasNext() )
             return null ;
         Resource r = sIter.nextStatement().getSubject() ;
         if ( sIter.hasNext() )
             throw new TypeNotUniqueException(r) ;
         return r ;
     }
-    
-    public static Resource findRootByType(Model model, Resource atype)
-    {
+
+    public static Resource findRootByType(Model model, Resource atype) {
         String s = StrUtils.strjoin("\n", 
-            "PREFIX  rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" ,
-            "PREFIX  rdfs:   <http://www.w3.org/2000/01/rdf-schema#>",
-            "SELECT DISTINCT ?root { { ?root rdf:type ?ATYPE } UNION { ?root rdf:type ?t . ?t rdfs:subClassOf ?ATYPE } }") ;
-        
+                                    "PREFIX  rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
+                                    "PREFIX  rdfs:   <http://www.w3.org/2000/01/rdf-schema#>",
+                                    "SELECT DISTINCT ?root { { ?root rdf:type ?ATYPE } UNION { ?root rdf:type ?t . ?t rdfs:subClassOf ?ATYPE } }") ;
+
         Query q = QueryFactory.create(s) ;
         QuerySolutionMap qsm = new QuerySolutionMap() ;
         qsm.add("ATYPE", atype) ;
 
-        QueryExecution qExec = QueryExecutionFactory.create(q, model, qsm);
+        QueryExecution qExec = QueryExecutionFactory.create(q, model, qsm) ;
         Resource r = (Resource)QueryExecUtils.getOne(qExec, "root") ;
-        return r;
+        return r ;
     }
-    
-    
-    public static String fmtURI(Resource r)
-    { return r.getModel().shortForm(r.getURI()) ;  }
-    
+
+    public static String fmtURI(Resource r) {
+        return r.getModel().shortForm(r.getURI()) ;
+    }
+
     /** All subjects and objects, no duplicates. */
-    public static Iterator<Node> allNodes(Graph graph)
-    {
+    public static Iterator<Node> allNodes(Graph graph) {
         Set<Node> x = new HashSet<>(1000) ;
         ExtendedIterator<Triple> iter = graph.find(Node.ANY, Node.ANY, Node.ANY) ;
-        for ( ; iter.hasNext() ; )
-        {
-            Triple t = iter.next();
+        for ( ; iter.hasNext() ; ) {
+            Triple t = iter.next() ;
             x.add(t.getSubject()) ;
             x.add(t.getObject()) ;
         }


[2/3] jena git commit: fuseki-core to depend directly on jena-cmds

Posted by an...@apache.org.
fuseki-core to depend directly on jena-cmds


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

Branch: refs/heads/master
Commit: 37d3ea911b792b185f51a70bdf2712953667870f
Parents: 171d471
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Sep 2 12:41:14 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Sep 2 12:41:14 2016 +0100

----------------------------------------------------------------------
 jena-fuseki2/jena-fuseki-core/pom.xml     |  7 +++++++
 jena-fuseki2/jena-fuseki-embedded/pom.xml | 24 ++++++++++++++++--------
 2 files changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/37d3ea91/jena-fuseki2/jena-fuseki-core/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/pom.xml b/jena-fuseki2/jena-fuseki-core/pom.xml
index dd8a538..47b7aa5 100644
--- a/jena-fuseki2/jena-fuseki-core/pom.xml
+++ b/jena-fuseki2/jena-fuseki-core/pom.xml
@@ -50,6 +50,13 @@
     </dependency>
 
     <dependency>
+      <groupId>org.apache.jena</groupId>
+      <artifactId>jena-cmds</artifactId>
+      <version>3.1.1-SNAPSHOT</version>
+      <type>pom</type>
+    </dependency>
+
+    <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
       <exclusions>

http://git-wip-us.apache.org/repos/asf/jena/blob/37d3ea91/jena-fuseki2/jena-fuseki-embedded/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-embedded/pom.xml b/jena-fuseki2/jena-fuseki-embedded/pom.xml
index 72fc04e..58429a1 100644
--- a/jena-fuseki2/jena-fuseki-embedded/pom.xml
+++ b/jena-fuseki2/jena-fuseki-embedded/pom.xml
@@ -39,16 +39,13 @@
       <version>2.4.1-SNAPSHOT</version>
       <!-- No specific logging - leave to the application -->
       <exclusions>
+
+        <!-- Parts of Jena not needed but picked up via jena-fuseki-core -->
         <exclusion>
-          <groupId>org.slf4j</groupId>
-          <artifactId>slf4j-log4j12</artifactId>
+          <groupId>org.apache.jena</groupId>
+          <artifactId>jena-cmds</artifactId>
         </exclusion>
         <exclusion>
-          <groupId>log4j</groupId>
-          <artifactId>log4j</artifactId>
-        </exclusion>
-        <!-- -->
-         <exclusion>
           <groupId>org.apache.jena</groupId>
           <artifactId>jena-text</artifactId>
         </exclusion>
@@ -56,6 +53,17 @@
           <groupId>org.apache.jena</groupId>
           <artifactId>jena-spatial</artifactId>
         </exclusion>
+        
+        <!-- Exclude choice of logging. Application responsibility. -->
+        <exclusion>
+          <groupId>org.slf4j</groupId>
+          <artifactId>slf4j-log4j12</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>log4j</groupId>
+          <artifactId>log4j</artifactId>
+        </exclusion>
+
       </exclusions>
     </dependency>
 
@@ -68,7 +76,7 @@
     </dependency>
     -->
 
-    <!-- Log4j
+    <!-- Log4j : need 2 dependencies.
     <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>


[3/3] jena git commit: Better environment setup : prepare for full server embeddability

Posted by an...@apache.org.
Better environment setup : prepare for full server embeddability


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

Branch: refs/heads/master
Commit: 1d5f0dc68452c65fb0aceb698ccab5d43c2a55d7
Parents: 37d3ea9
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Sep 2 12:42:57 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Sep 2 12:42:57 2016 +0100

----------------------------------------------------------------------
 .../main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java  | 11 +++++++----
 .../java/org/apache/jena/fuseki/jetty/JettyFuseki.java   |  1 +
 .../java/org/apache/jena/fuseki/server/FusekiEnv.java    |  6 +++++-
 3 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/1d5f0dc6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
index 304b1c5..b1db216 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/cmd/FusekiCmd.java
@@ -158,13 +158,14 @@ public class FusekiCmd {
 
         @Override
         protected void processModulesAndArgs() {
-            int x = 0 ;
-
             if ( super.isVerbose() || super.isDebug() ) {
                 jettyServerConfig.verboseLogging = true ;
                 // Output is still at level INFO (currently) 
             }
             
+            // Any final tinkering with FUSEKI_HOME and FUSEKI_BASE, e.g. arguments like --home, --base, then .... 
+            FusekiEnv.resetEnvironment() ;
+
             Logger log = Fuseki.serverLog ;
 
             if ( contains(argFusekiConfig) )
@@ -174,6 +175,7 @@ public class FusekiCmd {
 
             // ---- Datasets
             // Check one and only way is defined. 
+            int x = 0 ;
 
             if ( contains(argMem) )             
                 x++ ;
@@ -209,8 +211,9 @@ public class FusekiCmd {
             if ( cmdlineConfigPresent && getPositional().size() > 1 )
                 throw new CmdException("Multiple dataset path names given") ;
             
-            if ( ! cmdlineConfigPresent ) {
-                // In place config file. 
+            if ( ! cmdlineConfigPresent && cmdLineConfig.fusekiCmdLineConfigFile == null ) {
+                // Turn command line argument into an absolute file name.
+                FusekiEnv.setEnvironment();
                 Path cfg = FusekiEnv.FUSEKI_BASE.resolve(FusekiServer.DFT_CONFIG).toAbsolutePath() ;
                 if ( Files.exists(cfg) )
                     cmdLineConfig.fusekiServerConfigFile = cfg.toString() ;

http://git-wip-us.apache.org/repos/asf/jena/blob/1d5f0dc6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
index b8ca877..6580a81 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/jetty/JettyFuseki.java
@@ -242,6 +242,7 @@ public class JettyFuseki {
             security(webapp, serverConfig.authConfigFile) ;
     }
     
+    // This is now provided by Shiro.
     private static void security(ServletContextHandler context, String authfile) {
         Constraint constraint = new Constraint() ;
         constraint.setName(Constraint.__BASIC_AUTH) ;

http://git-wip-us.apache.org/repos/asf/jena/blob/1d5f0dc6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiEnv.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiEnv.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiEnv.java
index 6ff51f0..744b8b1 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiEnv.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/server/FusekiEnv.java
@@ -110,8 +110,12 @@ public class FusekiEnv {
     public static synchronized void setEnvironment() {
         if ( initialized )
             return ;
+        resetEnvironment();
+    }
+    
+    /** Reset environment - use with care and bfore server start up */ 
+    public static synchronized void resetEnvironment() {
         initialized = true ;
-        
         logInit("FusekiEnv:Start: ENV_FUSEKI_HOME = %s : ENV_FUSEKI_BASE = %s : MODE = %s", FUSEKI_HOME, FUSEKI_BASE, mode) ;
         
         if ( mode == null || mode == INIT.UNSET )