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 2018/11/01 20:04:01 UTC

[1/8] jena git commit: JENA-1620: Support N, M (in seconds) in the HTTP protocol setting.

Repository: jena
Updated Branches:
  refs/heads/master 289a9a905 -> f0ac03914


JENA-1620: Support N,M (in seconds) in the HTTP protocol setting.


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

Branch: refs/heads/master
Commit: 7d2213079c5f86a5c0b2ec5a8490c227e8232299
Parents: d664528
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 15:35:27 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:32:53 2018 +0100

----------------------------------------------------------------------
 .../apache/jena/sparql/engine/EngineLib.java    | 82 ++++++++++++++++++++
 .../jena/sparql/engine/QueryExecutionBase.java  | 47 ++++-------
 .../jena/sparql/engine/iterator/QueryIter.java  |  2 +-
 .../jena/sparql/pfunction/library/splitIRI.java | 11 ++-
 .../jena/fuseki/servlets/ResponseResultSet.java |  7 +-
 .../jena/fuseki/servlets/SPARQL_Query.java      | 70 +++--------------
 6 files changed, 121 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-arq/src/main/java/org/apache/jena/sparql/engine/EngineLib.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/EngineLib.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/EngineLib.java
new file mode 100644
index 0000000..19a2483
--- /dev/null
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/EngineLib.java
@@ -0,0 +1,82 @@
+/*
+ * 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.sparql.engine;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.jena.atlas.logging.Log;
+import org.apache.jena.query.QueryBuildException;
+import org.apache.jena.query.QueryExecution;
+
+/** Misc query engine related functions */
+public class EngineLib {
+
+    /**
+     * Parse string in the format "number" or "number,number" and apply this to the
+     * {@code QueryExecution} object.
+     */
+    public static void parseSetTimeout(QueryExecution qExec, String str, TimeUnit unit, boolean merge) {
+        if ( str == null )
+            return;
+        try {
+            if ( str.contains(",") ) {
+                String[] a = str.split(",");
+                if ( a.length > 2 ) {
+                    Log.warn(qExec, "Can't interpret string for timeout: " + str);
+                    throw new QueryBuildException();
+                }
+                long x1 = Long.parseLong(a[0]);
+                x1 = unit.toMillis(x1);
+                long x2 = Long.parseLong(a[1]);
+                x2 = unit.toMillis(x2);
+                if ( merge )
+                    mergeTimeouts(qExec, x1, x2);
+                else
+                    qExec.setTimeout(x1, x2);
+            } else {
+                long x = Long.parseLong(str);
+                x = unit.toMillis(x);
+                if ( merge )
+                    mergeTimeouts(qExec, -1, x);
+                else
+                    qExec.setTimeout(x);
+            }
+        } catch (RuntimeException ex) {
+            Log.warn(qExec, "Can't interpret string for timeout: " + str);
+        }
+    }
+
+    /** Merge in query timeouts - that is respect settings in qExec already there. */
+    private static void mergeTimeouts(QueryExecution qExec, long timeout1, long timeout2) {
+        // Bound timeout if the QueryExecution alredy has a setting
+        if ( timeout1 >= 0 ) {
+            if ( qExec.getTimeout1() != -1 )
+                timeout1 = Math.min(qExec.getTimeout1(), timeout1);
+        } else
+            timeout1 = qExec.getTimeout1();
+
+        if ( timeout2 >= 0 ) {
+            if ( qExec.getTimeout2() != -1 )
+                timeout2 = Math.min(qExec.getTimeout2(), timeout2);
+        } else
+            timeout2 = qExec.getTimeout2();
+        qExec.setTimeout(timeout1, timeout2);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
index 4fe235e..de9700e 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
@@ -88,6 +88,7 @@ public class QueryExecutionBase implements QueryExecution
     private long                     timeout1         = TIMEOUT_UNSET;
     private long                     timeout2         = TIMEOUT_UNSET;
     private final AlarmClock         alarmClock       = AlarmClock.get();
+    private long                     queryStartTime;
 
     public QueryExecutionBase(Query query, Dataset dataset, Context context, QueryEngineFactory qeFactory) {
         this(query, dataset, null, context, qeFactory);
@@ -140,34 +141,12 @@ public class QueryExecutionBase implements QueryExecution
                 setTimeout(x);
             } else if ( obj instanceof String ) {
                 String str = obj.toString();
-                parseSetTimeout(this, str, TimeUnit.MILLISECONDS);
+                // Set, not merge.
+                EngineLib.parseSetTimeout(this, str, TimeUnit.MILLISECONDS, false);
             } else
                 Log.warn(this, "Can't interpret timeout: " + obj);
         }
-    }
-    
-    /** Parse string in the format "number" or "number,number" and apply this to the {@code QueryExecution} object. */ 
-    private static void parseSetTimeout(QueryExecution qExec, String str, TimeUnit unit) {
-        if ( str == null )
-            return ;
-        try {
-            if ( str.contains(",") ) {
-                String[] a = str.split(",");
-                if ( a.length > 2 ) {
-                    Log.warn(qExec, "Can't interpret string for timeout: " + str);
-                    throw new QueryBuildException();
-                }
-                long x1 = Long.parseLong(a[0]);
-                long x2 = Long.parseLong(a[1]);
-                qExec.setTimeout(x1, x2);
-            } else {
-                long x = Long.parseLong(str);
-                qExec.setTimeout(x);
-            }
-        }
-        catch (RuntimeException ex) {
-            Log.warn(qExec, "Can't interpret string for timeout: " + str);
-        }
+        queryStartTime = System.currentTimeMillis();
     }
     
     @Override
@@ -511,7 +490,7 @@ public class QueryExecutionBase implements QueryExecution
                     // This cause timeout1 not to call .abort and hence not set isCancelled 
 
                     // But if timeout1 went off after moveToNextBinding, before expectedCallback is set,
-                    // then forget the row and cacnel the query. 
+                    // then forget the row and cancel the query. 
                     if ( isCancelled.get() )
                         // timeout1 went off after the binding was yielded but 
                         // before we got here.
@@ -523,9 +502,8 @@ public class QueryExecutionBase implements QueryExecution
 
                     // Now arm the second timeout, if any.
                     if ( timeout2 > 0 ) {
-                        long t = timeout2;
-                        if ( timeout1 > 0 )
-                            t = t - timeout1;
+                        // Set to time remaining.
+                        long t = timeout2 - (System.currentTimeMillis()-queryStartTime);
                         // Not first timeout - finite second timeout for remaining time. 
                         timeout2Alarm = alarmClock.add(callback, t) ;
                     }
@@ -569,6 +547,7 @@ public class QueryExecutionBase implements QueryExecution
         }
 
         if ( !isTimeoutSet(timeout1) && isTimeoutSet(timeout2) ) {
+            // Case -1,N
             // Single overall timeout.
             TimeoutCallback callback = new TimeoutCallback() ; 
             expectedCallback.set(callback) ; 
@@ -579,6 +558,8 @@ public class QueryExecutionBase implements QueryExecution
             return ;
         }
 
+        // Case N,-1 
+        // Case N,M 
         // Case isTimeoutSet(timeout1)
         //   Whether timeout2 is set is determined by QueryIteratorTimer2
         //   Subcase 2: ! isTimeoutSet(timeout2)
@@ -592,12 +573,12 @@ public class QueryExecutionBase implements QueryExecution
         // it might be necessary)
         queryIterator = getPlan().iterator() ;
         
-        // Add the timeout1 resetter wrapper.
+        // Add the timeout1->timeout2 resetter wrapper.
         queryIterator = new QueryIteratorTimer2(queryIterator) ;
 
-        // Minor optimization - the first call of hasNext() or next() will
-        // throw QueryCancelledExcetion anyway.  This just makes it a bit earlier
-        // in the case when the timeout (timoeut1) is so short it's gone off already.
+        // Minor optimization - timeout has already occurred. The first call of hasNext() or next()
+        // will throw QueryCancelledExcetion anyway. This just makes it a bit earlier
+        // in the case when the timeout (timeout1) is so short it's gone off already.
         
         if ( isCancelled.get() )
             queryIterator.cancel() ;

http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIter.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIter.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIter.java
index ca02fe1..6f98ac9 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIter.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIter.java
@@ -27,7 +27,7 @@ import org.apache.jena.sparql.engine.QueryIterator ;
 import org.apache.jena.sparql.serializer.SerializationContext ;
 
 /**
- * This class provides the general machinary for iterators. */
+ * This class provides the general machinery for iterators. */
 public abstract class QueryIter extends QueryIteratorBase
 {
     // Volatile just to make it safe to concurrent updates

http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/library/splitIRI.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/library/splitIRI.java b/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/library/splitIRI.java
index ead385a..8c10206 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/library/splitIRI.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/pfunction/library/splitIRI.java
@@ -18,6 +18,8 @@
 
 package org.apache.jena.sparql.pfunction.library;
 
+import java.util.Objects;
+
 import org.apache.jena.atlas.lib.Lib ;
 import org.apache.jena.atlas.logging.Log ;
 import org.apache.jena.graph.Node ;
@@ -36,7 +38,7 @@ import org.apache.jena.sparql.pfunction.PropertyFunctionEval ;
 import org.apache.jena.sparql.util.IterLib ;
 import org.apache.jena.sparql.util.NodeUtils ;
 
-public class splitIRI extends PropertyFunctionEval //PropertyFunctionBase
+public class splitIRI extends PropertyFunctionEval
 {
     public splitIRI()
     {
@@ -98,12 +100,13 @@ public class splitIRI extends PropertyFunctionEval //PropertyFunctionBase
         if ( Var.isVar(namespaceNode) || Var.isVar(localnameNode) )
             b = BindingFactory.create(binding) ;
         
-        if ( Var.isVar(namespaceNode) ) // .isVariable() )
+        if ( Var.isVar(namespaceNode) )
         {
             b.add(Var.alloc(namespaceNode), NodeFactory.createURI(namespace)) ;
             // Check for the case of (?x ?x) (very unlikely - and even more unlikely to cause a match)
             // but it's possible for strange URI schemes.
-            if ( localnameNode.isVariable() && namespaceNode.getName() == localnameNode.getName() )
+            if ( localnameNode.isVariable() && Objects.equals(namespaceNode, localnameNode) )
+                // Set localnameNode to a constant which will get checked below.
                 localnameNode = NodeFactory.createURI(namespace) ;
         }
         else
@@ -130,7 +133,7 @@ public class splitIRI extends PropertyFunctionEval //PropertyFunctionBase
         }
         
         Binding b2 = ( b == null ) ? binding : b ;
-        return IterLib.result(b, execCxt) ;
+        return IterLib.result(b2, execCxt) ;
     }
 
     private QueryIterator subjectIsVariable(Node arg, PropFuncArg argObject, ExecutionContext execCxt)

http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
index 9bc1a0b..665b9a6 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
@@ -225,8 +225,11 @@ public class ResponseResultSet
                 proc.output(out) ;
                 out.flush() ;
             } catch (QueryCancelledException ex) {
-                // Bother.  Status code 200 already sent.
-                action.log.info(format("[%d] Query Cancelled - results truncated (but 200 already sent)", action.id)) ;
+                // Status code 200 may have already been sent.
+                // We can try to set the HTTP response code anyway.
+                // Breaking the results is the best we can do to indicate the timeout. 
+                action.response.setStatus(HttpSC.BAD_REQUEST_400);
+                action.log.info(format("[%d] Query Cancelled - results truncated (but 200 may have already been sent)", action.id)) ;
                 out.println() ;
                 out.println("##  Query cancelled due to timeout during execution   ##") ;
                 out.println("##  ****          Incomplete results           ****   ##") ;

http://git-wip-us.apache.org/repos/asf/jena/blob/7d221307/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
index c6513bd..cb6424e 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
@@ -24,21 +24,12 @@ import static org.apache.jena.riot.WebContent.ctHTMLForm ;
 import static org.apache.jena.riot.WebContent.ctSPARQLQuery ;
 import static org.apache.jena.riot.WebContent.isHtmlForm ;
 import static org.apache.jena.riot.WebContent.matchContentType ;
-import static org.apache.jena.riot.web.HttpNames.paramAccept ;
-import static org.apache.jena.riot.web.HttpNames.paramCallback ;
-import static org.apache.jena.riot.web.HttpNames.paramDefaultGraphURI ;
-import static org.apache.jena.riot.web.HttpNames.paramForceAccept ;
-import static org.apache.jena.riot.web.HttpNames.paramNamedGraphURI ;
-import static org.apache.jena.riot.web.HttpNames.paramOutput1 ;
-import static org.apache.jena.riot.web.HttpNames.paramOutput2 ;
-import static org.apache.jena.riot.web.HttpNames.paramQuery ;
-import static org.apache.jena.riot.web.HttpNames.paramQueryRef ;
-import static org.apache.jena.riot.web.HttpNames.paramStyleSheet ;
-import static org.apache.jena.riot.web.HttpNames.paramTimeout ;
+import static org.apache.jena.riot.web.HttpNames.*;
 
 import java.io.IOException ;
 import java.io.InputStream ;
 import java.util.* ;
+import java.util.concurrent.TimeUnit;
 
 import javax.servlet.http.HttpServletRequest ;
 import javax.servlet.http.HttpServletResponse ;
@@ -48,13 +39,13 @@ import org.apache.jena.atlas.io.IndentedLineBuffer ;
 import org.apache.jena.atlas.json.JsonObject;
 import org.apache.jena.atlas.web.ContentType ;
 import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.FusekiException ;
 import org.apache.jena.fuseki.system.FusekiNetLib;
 import org.apache.jena.query.* ;
 import org.apache.jena.rdf.model.Model ;
 import org.apache.jena.riot.web.HttpNames ;
 import org.apache.jena.riot.web.HttpOp ;
 import org.apache.jena.sparql.core.Prologue ;
+import org.apache.jena.sparql.engine.EngineLib;
 import org.apache.jena.sparql.resultset.SPARQLResult ;
 import org.apache.jena.web.HttpSC ;
 
@@ -387,55 +378,18 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
         return null ;
     }
 
-    private void setAnyProtocolTimeouts(QueryExecution qexec, HttpAction action) {
-        //        if ( !(action.getDataService().allowTimeoutOverride) )
-        //            return ;
-        // See also QueryExecutionBase.setTimeouts to parse and process N,M form.
-        // ?? Set only if lower than any settings from the dataset or global contexts already in
-        // the QueryExecution.
-        long desiredTimeout = Long.MAX_VALUE ;
-        
+    private void setAnyProtocolTimeouts(QueryExecution qExec, HttpAction action) {
+        // The timeout string in the protocol is in seconds, not milliseconds.
+        String desiredTimeoutStr = null;
         String timeoutHeader = action.request.getHeader("Timeout") ;
         String timeoutParameter = action.request.getParameter("timeout") ;
-        if ( timeoutHeader != null ) {
-            try {
-                desiredTimeout = (long)(Float.parseFloat(timeoutHeader) * 1000) ;
-            } catch (NumberFormatException e) {
-                throw new FusekiException("Timeout header must be a number", e) ;
-            }
-        } else if ( timeoutParameter != null ) {
-            try {
-                desiredTimeout = (long)(Float.parseFloat(timeoutParameter) * 1000) ;
-            } catch (NumberFormatException e) {
-                throw new FusekiException("timeout parameter must be a number", e) ;
-            }
-        }
-        
-        if ( desiredTimeout == Long.MAX_VALUE )
-           return;
+        if ( timeoutHeader != null ) 
+            desiredTimeoutStr = timeoutHeader;
+        if ( timeoutParameter != null )
+            desiredTimeoutStr = timeoutParameter;
         
-        if ( qexec.getTimeout1() != -1 )
-            desiredTimeout = Math.min(qexec.getTimeout2(), desiredTimeout) ;
-        mergeTimeouts(qexec, -1, desiredTimeout) ;
-    }
-    
-    // Times in millseconds.
-    private static void mergeTimeouts(QueryExecution qexec, long timeout1, long timeout2) {
-        // Bound timeout if the QueryExecution alredy has a setting
-        if ( timeout1 >= 0 ) { 
-            if ( qexec.getTimeout1() != -1 ) 
-                timeout1 = Math.min(qexec.getTimeout1(), timeout1) ;
-        }
-        else
-            timeout1 = qexec.getTimeout1();
-            
-        if ( timeout2 >= 0 ) { 
-            if ( qexec.getTimeout2() != -1 ) 
-                timeout2 = Math.min(qexec.getTimeout2(), timeout2) ;
-        }
-        else
-            timeout2 = qexec.getTimeout2();
-        qexec.setTimeout(timeout1, timeout2);
+        // Merge (new timeoutw can't be greater than current settings for qExec
+        EngineLib.parseSetTimeout(qExec, desiredTimeoutStr, TimeUnit.SECONDS, true);
     }
 
     /** Choose the dataset for this SPARQL Query request.


[2/8] jena git commit: JENA-1620: Clean up timeout processing.

Posted by an...@apache.org.
JENA-1620: Clean up timeout processing.

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

Branch: refs/heads/master
Commit: d6645286a01d680b1572dab5b015dcdccedf7041
Parents: c3027d6
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 15:00:32 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:32:53 2018 +0100

----------------------------------------------------------------------
 .../jena/sparql/engine/QueryExecutionBase.java  | 104 ++++++++++++-------
 .../jena/fuseki/servlets/ResponseResultSet.java |   2 +-
 .../jena/fuseki/servlets/SPARQL_Query.java      |  37 +++++--
 .../fuseki/servlets/SPARQL_QueryGeneral.java    |  18 +++-
 4 files changed, 111 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/d6645286/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
index 16aea26..4fe235e 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/QueryExecutionBase.java
@@ -21,8 +21,11 @@ package org.apache.jena.sparql.engine;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.jena.atlas.json.JsonArray;
 import org.apache.jena.atlas.json.JsonObject;
@@ -72,9 +75,9 @@ public class QueryExecutionBase implements QueryExecution
     private QuerySolution            initialBinding   = null;
 
     // Set if QueryIterator.cancel has been called
-    private volatile boolean         isCancelled      = false;
+    private AtomicBoolean            isCancelled      = new AtomicBoolean(false);
     private boolean                  closed;
-    private volatile TimeoutCallback expectedCallback = null;
+    private AtomicReference<TimeoutCallback> expectedCallback = new AtomicReference<>(null);
     private Alarm                    timeout1Alarm    = null;
     private Alarm                    timeout2Alarm    = null;
 
@@ -136,26 +139,37 @@ public class QueryExecutionBase implements QueryExecution
                 long x = ((Number)obj).longValue();
                 setTimeout(x);
             } else if ( obj instanceof String ) {
-                try {
-                    String str = obj.toString();
-                    if ( str.contains(",") ) {
-                        String[] a = str.split(",");
-                        long x1 = Long.parseLong(a[0]);
-                        long x2 = Long.parseLong(a[1]);
-                        setTimeout(x1, x2);
-                    } else {
-                        long x = Long.parseLong(str);
-                        setTimeout(x);
-                    }
-                }
-                catch (RuntimeException ex) {
-                    Log.warn(this, "Can't interpret string for timeout: " + obj);
-                }
+                String str = obj.toString();
+                parseSetTimeout(this, str, TimeUnit.MILLISECONDS);
             } else
                 Log.warn(this, "Can't interpret timeout: " + obj);
         }
     }
     
+    /** Parse string in the format "number" or "number,number" and apply this to the {@code QueryExecution} object. */ 
+    private static void parseSetTimeout(QueryExecution qExec, String str, TimeUnit unit) {
+        if ( str == null )
+            return ;
+        try {
+            if ( str.contains(",") ) {
+                String[] a = str.split(",");
+                if ( a.length > 2 ) {
+                    Log.warn(qExec, "Can't interpret string for timeout: " + str);
+                    throw new QueryBuildException();
+                }
+                long x1 = Long.parseLong(a[0]);
+                long x2 = Long.parseLong(a[1]);
+                qExec.setTimeout(x1, x2);
+            } else {
+                long x = Long.parseLong(str);
+                qExec.setTimeout(x);
+            }
+        }
+        catch (RuntimeException ex) {
+            Log.warn(qExec, "Can't interpret string for timeout: " + str);
+        }
+    }
+    
     @Override
     public void close() {
         closed = true;
@@ -182,17 +196,17 @@ public class QueryExecutionBase implements QueryExecution
     @Override
     public void abort() {
         synchronized (lockTimeout) {
+            isCancelled.set(true);
             // This is called asynchronously to the execution.
             // synchronized is for coordination with other calls of
             // .abort and with the timeout2 reset code.
             if ( queryIterator != null )
-                                        // we notify the chain of iterators,
-                                        // however, we do *not* close the
-                                        // iterators.
-                                        // That happens after the cancellation
-                                        // is properly over.
-                                        queryIterator.cancel();
-            isCancelled = true;
+                // we notify the chain of iterators,
+                // however, we do *not* close the
+                // iterators.
+                // That happens after the cancellation
+                // is properly over.
+                queryIterator.cancel();
         }
     }
     
@@ -361,7 +375,15 @@ public class QueryExecutionBase implements QueryExecution
             throw new QueryExecException("Attempt to have boolean from a " + labelForQuery(query) + " query");
 
         startQueryIterator();
-        boolean r = queryIterator.hasNext();
+        
+        boolean r;
+        try {
+            // Not has next because setting timeout1 which applies to getting
+            // the first result, not testing for it.
+            queryIterator.next();
+            r = true;
+        } catch (NoSuchElementException ex) { r = false; }
+        
         this.close();
         return r;
     }
@@ -418,6 +440,11 @@ public class QueryExecutionBase implements QueryExecution
     }
 
     @Override
+    public void setTimeout(long timeout1, long timeout2) {
+        setTimeout(timeout1, TimeUnit.MILLISECONDS, timeout2, TimeUnit.MILLISECONDS);
+    }
+
+    @Override
     public void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2) {
         // Two timeouts.
         long x1 = asMillis(timeout1, timeUnit1);
@@ -429,11 +456,6 @@ public class QueryExecutionBase implements QueryExecution
             this.timeout2 = x2;
     }
 
-    @Override
-    public void setTimeout(long timeout1, long timeout2) {
-        setTimeout(timeout1, TimeUnit.MILLISECONDS, timeout2, TimeUnit.MILLISECONDS);
-    }
-
     private static long asMillis(long duration, TimeUnit timeUnit) {
         return (duration < 0) ? duration : timeUnit.toMillis(duration);
     }
@@ -456,7 +478,7 @@ public class QueryExecutionBase implements QueryExecution
                 // callback,
                 // it still may go off so it needs to check here it's still
                 // wanted.
-                if ( expectedCallback == this )
+                if ( expectedCallback.get() == this )
                     QueryExecutionBase.this.abort();
             }
         }
@@ -482,15 +504,15 @@ public class QueryExecutionBase implements QueryExecution
                 synchronized(lockTimeout)
                 {
                     TimeoutCallback callback = new TimeoutCallback() ;
-                    expectedCallback = callback ;
+                    expectedCallback.set(callback) ;
                     // Lock against calls of .abort() or of timeout1Callback. 
                     
                     // Update/check the volatiles in a careful order.
                     // This cause timeout1 not to call .abort and hence not set isCancelled 
 
                     // But if timeout1 went off after moveToNextBinding, before expectedCallback is set,
-                    // then formget the row and cacnel the query. 
-                    if ( isCancelled )
+                    // then forget the row and cacnel the query. 
+                    if ( isCancelled.get() )
                         // timeout1 went off after the binding was yielded but 
                         // before we got here.
                         throw new QueryCancelledException() ;
@@ -501,8 +523,11 @@ public class QueryExecutionBase implements QueryExecution
 
                     // Now arm the second timeout, if any.
                     if ( timeout2 > 0 ) {
-                        // Not first timeout - finite second timeout. 
-                        timeout2Alarm = alarmClock.add(callback, timeout2) ;
+                        long t = timeout2;
+                        if ( timeout1 > 0 )
+                            t = t - timeout1;
+                        // Not first timeout - finite second timeout for remaining time. 
+                        timeout2Alarm = alarmClock.add(callback, t) ;
                     }
                     resetDone = true ;
                 }
@@ -546,7 +571,7 @@ public class QueryExecutionBase implements QueryExecution
         if ( !isTimeoutSet(timeout1) && isTimeoutSet(timeout2) ) {
             // Single overall timeout.
             TimeoutCallback callback = new TimeoutCallback() ; 
-            expectedCallback = callback ; 
+            expectedCallback.set(callback) ; 
             timeout2Alarm = alarmClock.add(callback, timeout2) ;
             // Start the query.
             queryIterator = getPlan().iterator() ;
@@ -560,7 +585,7 @@ public class QueryExecutionBase implements QueryExecution
         // Add timeout to first row.
         TimeoutCallback callback = new TimeoutCallback() ; 
         timeout1Alarm = alarmClock.add(callback, timeout1) ;
-        expectedCallback = callback ;
+        expectedCallback.set(callback) ;
 
         // We don't know if getPlan().iterator() does a lot of work or not
         // (ideally it shouldn't start executing the query but in some sub-systems 
@@ -574,7 +599,8 @@ public class QueryExecutionBase implements QueryExecution
         // throw QueryCancelledExcetion anyway.  This just makes it a bit earlier
         // in the case when the timeout (timoeut1) is so short it's gone off already.
         
-        if ( isCancelled ) queryIterator.cancel() ;
+        if ( isCancelled.get() )
+            queryIterator.cancel() ;
     }
     
     private ResultSet execResultSet() {

http://git-wip-us.apache.org/repos/asf/jena/blob/d6645286/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
index 8771629..9bc1a0b 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
@@ -207,7 +207,7 @@ public class ResponseResultSet
             }
             if ( resultSet != null )
                 rw.write(out, resultSet) ;
-            if (  booleanResult != null )
+            if ( booleanResult != null )
                 rw.write(out, booleanResult.booleanValue()) ;
             if ( callback != null )
                 out.println(")") ;

http://git-wip-us.apache.org/repos/asf/jena/blob/d6645286/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
index 6bee41d..c6513bd 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
@@ -393,28 +393,49 @@ public abstract class SPARQL_Query extends SPARQL_Protocol
         // See also QueryExecutionBase.setTimeouts to parse and process N,M form.
         // ?? Set only if lower than any settings from the dataset or global contexts already in
         // the QueryExecution.
-        // Add context setting for "allow increases".
-        // Documentation.
         long desiredTimeout = Long.MAX_VALUE ;
+        
         String timeoutHeader = action.request.getHeader("Timeout") ;
         String timeoutParameter = action.request.getParameter("timeout") ;
         if ( timeoutHeader != null ) {
             try {
-                desiredTimeout = (int)(Float.parseFloat(timeoutHeader) * 1000) ;
+                desiredTimeout = (long)(Float.parseFloat(timeoutHeader) * 1000) ;
             } catch (NumberFormatException e) {
                 throw new FusekiException("Timeout header must be a number", e) ;
             }
         } else if ( timeoutParameter != null ) {
             try {
-                desiredTimeout = (int)(Float.parseFloat(timeoutParameter) * 1000) ;
+                desiredTimeout = (long)(Float.parseFloat(timeoutParameter) * 1000) ;
             } catch (NumberFormatException e) {
                 throw new FusekiException("timeout parameter must be a number", e) ;
             }
         }
-
-//        desiredTimeout = Math.min(action.getDataService().maximumTimeoutOverride, desiredTimeout) ;
-        if ( desiredTimeout != Long.MAX_VALUE )
-            qexec.setTimeout(desiredTimeout) ;
+        
+        if ( desiredTimeout == Long.MAX_VALUE )
+           return;
+        
+        if ( qexec.getTimeout1() != -1 )
+            desiredTimeout = Math.min(qexec.getTimeout2(), desiredTimeout) ;
+        mergeTimeouts(qexec, -1, desiredTimeout) ;
+    }
+    
+    // Times in millseconds.
+    private static void mergeTimeouts(QueryExecution qexec, long timeout1, long timeout2) {
+        // Bound timeout if the QueryExecution alredy has a setting
+        if ( timeout1 >= 0 ) { 
+            if ( qexec.getTimeout1() != -1 ) 
+                timeout1 = Math.min(qexec.getTimeout1(), timeout1) ;
+        }
+        else
+            timeout1 = qexec.getTimeout1();
+            
+        if ( timeout2 >= 0 ) { 
+            if ( qexec.getTimeout2() != -1 ) 
+                timeout2 = Math.min(qexec.getTimeout2(), timeout2) ;
+        }
+        else
+            timeout2 = qexec.getTimeout2();
+        qexec.setTimeout(timeout1, timeout2);
     }
 
     /** Choose the dataset for this SPARQL Query request.

http://git-wip-us.apache.org/repos/asf/jena/blob/d6645286/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
index 3cf0d0d..d19b85c 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
@@ -23,6 +23,8 @@ import static java.lang.String.format ;
 import java.util.List ;
 
 import org.apache.jena.atlas.lib.InternalErrorException ;
+import org.apache.jena.fuseki.server.DataService;
+import org.apache.jena.fuseki.server.Operation;
 import org.apache.jena.fuseki.system.GraphLoadUtils;
 import org.apache.jena.query.Dataset ;
 import org.apache.jena.query.DatasetFactory ;
@@ -31,6 +33,7 @@ import org.apache.jena.rdf.model.Model ;
 import org.apache.jena.rdf.model.ModelFactory ;
 import org.apache.jena.riot.RiotException ;
 import org.apache.jena.sparql.core.DatasetDescription ;
+import org.apache.jena.sparql.core.DatasetGraphZero;
 
 public class SPARQL_QueryGeneral extends SPARQL_Query {
     final static int MaxTriples = 100 * 1000 ;
@@ -49,14 +52,25 @@ public class SPARQL_QueryGeneral extends SPARQL_Query {
     protected String mapRequestToDataset(HttpAction action) {
         return null ;
     }
+    
+    /** SPARQL_QueryGeneral is a servlet to be called directly.
+     * It declares it is own {@code Operation} to fit into {@link ActionService#execCommonWorker}.
+     * The Fuseki service handling continues; 
+     * {@link SPARQL_Query} will ask for a dataset which will return the fixed, empty dataset.
+     * 
+     */
+    @Override
+    protected Operation chooseOperation(HttpAction action, DataService dataService) {
+        return Operation.Query;
+    }
 
+    private static Dataset ds = DatasetFactory.wrap(new DatasetGraphZero());
     @Override
     protected Dataset decideDataset(HttpAction action, Query query, String queryStringLog) {
         DatasetDescription datasetDesc = getDatasetDescription(action, query) ;
         if ( datasetDesc == null )
             //ServletOps.errorBadRequest("No dataset description in protocol request or in the query string") ;
-            // Hope the query has something in it!
-            return DatasetFactory.createTxnMem();
+            return ds;
         return datasetFromDescriptionWeb(action, datasetDesc) ;
     }
 


[7/8] jena git commit: JENA-1620: Merge commit 'refs/pull/483/head' of https://github.com/apache/jena

Posted by an...@apache.org.
JENA-1620: Merge commit 'refs/pull/483/head' of https://github.com/apache/jena

This closes #483.


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

Branch: refs/heads/master
Commit: 33c7df7e7005fb00802e643b0ee804289eca6991
Parents: 289a9a9 7d22130
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Nov 1 19:56:57 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Nov 1 19:56:57 2018 +0000

----------------------------------------------------------------------
 .../apache/jena/sparql/engine/EngineLib.java    | 82 +++++++++++++++++
 .../jena/sparql/engine/QueryExecutionBase.java  | 93 +++++++++++---------
 .../jena/sparql/engine/iterator/QueryIter.java  |  2 +-
 .../jena/sparql/pfunction/library/splitIRI.java | 11 ++-
 .../jena/fuseki/servlets/ResponseResultSet.java |  9 +-
 .../jena/fuseki/servlets/SPARQL_Query.java      | 51 +++--------
 .../fuseki/servlets/SPARQL_QueryGeneral.java    | 18 +++-
 7 files changed, 175 insertions(+), 91 deletions(-)
----------------------------------------------------------------------



[4/8] jena git commit: Add comment.

Posted by an...@apache.org.
Add comment.

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

Branch: refs/heads/master
Commit: 6e81f9fdc009b387ed64ddca56f40802ece70245
Parents: c3027d6
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 14:56:53 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:36:39 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/6e81f9fd/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java
index b550e53..09edf8b 100644
--- a/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java
+++ b/jena-fuseki2/jena-fuseki-main/src/main/java/org/apache/jena/fuseki/main/cmds/FusekiMain.java
@@ -390,6 +390,7 @@ public class FusekiMain extends CmdARQ {
             builder.loopback(serverConfig.loopback);
             
             if ( serverConfig.addGeneral != null )
+                // Add SPARQL_QueryGeneral as a general servlet, not reached by the service router. 
                 builder.addServlet(serverConfig.addGeneral,  new SPARQL_QueryGeneral());
             
             if ( serverConfig.validators ) {


[6/8] jena git commit: Simplify dump servlet; dft to not added to a server

Posted by an...@apache.org.
Simplify dump servlet; dft to not added to a server


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

Branch: refs/heads/master
Commit: 59d1c0d6e17b4b39b8a17c36b3f60402f63665e3
Parents: 85be62d
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 14:44:16 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:36:39 2018 +0100

----------------------------------------------------------------------
 .../jena/fuseki/ctl/ActionDumpRequest.java      | 272 +++++++++++++++++
 .../org/apache/jena/fuseki/mgt/DumpServlet.java | 300 -------------------
 .../src/main/webapp/WEB-INF/web.xml             |  10 -
 3 files changed, 272 insertions(+), 310 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/59d1c0d6/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionDumpRequest.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionDumpRequest.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionDumpRequest.java
new file mode 100644
index 0000000..88bbdc7
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/ctl/ActionDumpRequest.java
@@ -0,0 +1,272 @@
+/*
+ * 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.
+ */
+
+/** A servlet that dumps its request
+ */
+
+// Could be neater - much, much neater!
+
+package org.apache.jena.fuseki.ctl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.jena.atlas.io.IO;
+import org.apache.jena.ext.com.google.common.collect.Multimap;
+import org.apache.jena.fuseki.system.FusekiNetLib;
+
+/** Dump the HTTP request */
+public class ActionDumpRequest extends HttpServlet {
+    public ActionDumpRequest() {}
+
+    @Override
+    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
+        doPrintInformation(req, resp);
+    }
+    
+    @Override
+    public void doPost(HttpServletRequest req, HttpServletResponse resp) {
+        doPrintInformation(req, resp);
+    }
+
+    public void doPrintInformation(HttpServletRequest req, HttpServletResponse resp) {
+        try {
+            PrintWriter out = resp.getWriter();
+            resp.setContentType("text/html");
+
+            String now = new Date().toString();
+
+            // HEAD
+            out.println("<html>");
+            out.println("<head>");
+            out.println("<Title>Dump @ " + now + "</Title>");
+            // Reduce the desire to cache it.
+            out.println("<meta CONTENT=now HTTP-EQUIV=expires>");
+            out.println("</head>");
+
+            // BODY
+            out.println("<body>");
+            out.println("<pre>");
+
+            out.println("Dump : " + now);
+            out.println();
+            out.println("==== Request");
+            out.println();
+            printRequest(out, req);
+            out.println();
+
+            out.println(">>>> Body");
+            out.println();
+            printBody(out, req);
+            out.println("<<<< Body");
+
+//            out.println("==== ServletContext");
+//            out.println();
+//            printServletContext(out, req);
+//            out.println();
+//
+//            out.println("==== Environment");
+//            out.println();
+//            printEnvironment(out, req);
+//            out.println();
+
+            out.println("</pre>");
+
+            out.println("</body>");
+            out.println("</html>");
+            out.flush();
+        } catch (IOException e) {}
+    }
+
+    // ---- Library of things to report on.
+    
+    static public void printRequest(PrintWriter pw, HttpServletRequest req) {
+        // ----Standard environment
+        pw.println("Method:                 " + req.getMethod());
+        pw.println("getContentLength:       " + Long.toString(req.getContentLengthLong()));
+        pw.println("getContentType:         " + req.getContentType());
+        pw.println("getRequestURI:          " + req.getRequestURI());
+        pw.println("getRequestURL:          " + req.getRequestURL());
+        pw.println("getContextPath:         " + req.getContextPath());
+        pw.println("getServletPath:         " + req.getServletPath());
+        pw.println("getPathInfo:            " + req.getPathInfo());
+        pw.println("getPathTranslated:      " + req.getPathTranslated());
+        pw.println("getQueryString:         " + req.getQueryString());
+        pw.println("getProtocol:            " + req.getProtocol());
+        pw.println("getScheme:              " + req.getScheme());
+        pw.println("getServerName:          " + req.getServerName());
+        pw.println("getServerPort:          " + req.getServerPort());
+        pw.println("getRemoteUser:          " + req.getRemoteUser());
+        pw.println("getRemoteAddr:          " + req.getRemoteAddr());
+        pw.println("getRemoteHost:          " + req.getRemoteHost());
+        pw.println("getRequestedSessionId:  " + req.getRequestedSessionId());
+    }
+    
+    // ---- Library of things to report on.
+    
+    static void printBody(PrintWriter pw, HttpServletRequest req) throws IOException {
+        // Destructive read of the request body.
+        BufferedReader in = req.getReader();
+        while (true) {
+            String x = in.readLine();
+            if ( x == null )
+                break;
+            x = x.replaceAll("&", "&amp;");
+            x = x.replaceAll("<", "&lt;");
+            x = x.replaceAll(">", "&gt;");
+            pw.println(x);
+        }
+    }
+
+    static void printCookies(PrintWriter pw, HttpServletRequest req) {
+        Cookie c[] = req.getCookies();
+        if ( c == null )
+            pw.println("getCookies:            <none>");
+        else {
+            for ( int i = 0 ; i < c.length ; i++ ) {
+                pw.println();
+                pw.println("Cookie:        " + c[i].getName());
+                pw.println("    value:     " + c[i].getValue());
+                pw.println("    version:   " + c[i].getVersion());
+                pw.println("    comment:   " + c[i].getComment());
+                pw.println("    domain:    " + c[i].getDomain());
+                pw.println("    maxAge:    " + c[i].getMaxAge());
+                pw.println("    path:      " + c[i].getPath());
+                pw.println("    secure:    " + c[i].getSecure());
+            }
+        }
+    }
+
+    static void printHeaders(PrintWriter pw, HttpServletRequest req) {
+        Enumeration<String> en = req.getHeaderNames();
+
+        for ( ; en.hasMoreElements() ; ) {
+            String name = en.nextElement();
+            String value = req.getHeader(name);
+            pw.println("Head: " + name + " = " + value);
+        }
+    }
+
+    // Note that doing this on a form causes the forms content (body) to be read
+    // and parsed as form variables.
+    static void printParameters(PrintWriter pw, HttpServletRequest req) {
+        Enumeration<String> en = req.getParameterNames() ;
+        for ( ; en.hasMoreElements() ; )
+        {
+            String name = en.nextElement() ;
+            String value = req.getParameter(name) ;
+            pw.println("Param: "+name + " = " + value) ;
+        }
+    }
+    
+    static void printQueryString(PrintWriter pw, HttpServletRequest req) {
+        Multimap<String, String> map = FusekiNetLib.parseQueryString(req) ;
+        for ( String name : map.keys() )
+            for ( String value : map.get(name) )
+                pw.println("Param: "+name + " = " + value) ;
+    }
+    
+    static void printLocales(PrintWriter pw, HttpServletRequest req) {
+        Enumeration<Locale> en = req.getLocales();
+        for ( ; en.hasMoreElements() ; ) {
+            String name = en.nextElement().toString();
+            pw.println("Locale: " + name);
+        }
+        pw.println();
+    }
+
+    /**
+     * <code>printEnvironment</code>
+     * 
+     * @return String that is the HTML of the System properties as name/value pairs. The
+     *         values are with single quotes independent of whether or not the value has
+     *         single quotes in it.
+     */
+    static public String printEnvironment() {
+        Properties properties = System.getProperties();
+        try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw);) {
+            Enumeration<Object> en = properties.keys();
+            while (en.hasMoreElements()) {
+                String key = en.nextElement().toString();
+                pw.println(key + ": '" + properties.getProperty(key) + "'");
+            }
+
+            pw.println();
+            return sw.toString();
+        } catch (IOException e) {
+            IO.exception(e);
+            return null;
+        }
+    }
+    
+    public String printServletContext() {
+        try (StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw);) {
+            ServletContext sc = getServletContext();
+            pw.println("majorVersion: '" + sc.getMajorVersion() + "'");
+            pw.println("minorVersion: '" + sc.getMinorVersion() + "'");
+            pw.println("contextName:  '" + sc.getServletContextName() + "'");
+            pw.println("servletInfo:  '" + getServletInfo() + "'");
+            pw.println("serverInfo:  '" + sc.getServerInfo() + "'");
+
+            {
+                Enumeration<String> en = sc.getInitParameterNames();
+                if ( en != null ) {
+                    pw.println("initParameters: ");
+                    while (en.hasMoreElements()) {
+                        String key = en.nextElement();
+                        pw.println(key + ": '" + sc.getInitParameter(key) + "'");
+                    }
+                }
+            }
+
+            {
+                Enumeration<String> en = sc.getAttributeNames();
+                if ( en != null ) {
+                    pw.println("attributes: ");
+                    while (en.hasMoreElements()) {
+                        String key = en.nextElement();
+                        pw.println(key + ": '" + sc.getAttribute(key) + "'");
+                    }
+                }
+            }
+            pw.println();
+
+            return sw.toString();
+        } catch (IOException e) {
+            IO.exception(e);
+            return null;
+        }
+    }
+
+    @Override
+    public String getServletInfo() {
+        return "Dump";
+    }
+}

http://git-wip-us.apache.org/repos/asf/jena/blob/59d1c0d6/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java b/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
deleted file mode 100644
index c9e679e..0000000
--- a/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/mgt/DumpServlet.java
+++ /dev/null
@@ -1,300 +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.
- */
-
-/** A servlet that dumps its request
- */
-
-// Could be neater - much, much neater!
-package org.apache.jena.fuseki.mgt;
-
-import java.io.BufferedReader ;
-import java.io.IOException ;
-import java.io.PrintWriter ;
-import java.io.StringWriter ;
-import java.util.Date ;
-import java.util.Enumeration ;
-import java.util.Locale ;
-import java.util.Properties ;
-
-import javax.servlet.ServletContext ;
-import javax.servlet.http.Cookie ;
-import javax.servlet.http.HttpServlet ;
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
-import org.apache.jena.atlas.io.IO ;
-
-public class DumpServlet extends HttpServlet
-{
-    public DumpServlet() { }
-
-    @Override
-    public void doGet(HttpServletRequest req, HttpServletResponse resp)
-    {
-        try {
-            PrintWriter out = resp.getWriter() ;
-            resp.setContentType("text/html");
-
-            String now = new Date().toString() ;
-
-            // HEAD
-            out.println("<html>") ;
-            out.println("<head>") ;
-            out.println("<Title>Dump @ "+now+"</Title>") ;
-            // Reduce the desire to cache it.
-            out.println("<meta CONTENT=now HTTP-EQUIV=expires>") ;
-            out.println("</head>") ;
-
-            // BODY
-            out.println("<body>") ;
-            out.println("<pre>") ;
-
-            out.println("Dump : "+now);
-            out.println() ;
-            out.println("==== Request");
-            out.println() ;
-            out.print(dumpRequest(req)) ;
-            out.println() ;
-                        
-            out.println(">>>> Body");
-            out.println() ;
-            printBody(out, req) ;
-            out.println("<<<< Body");
-            
-            out.println("==== ServletContext");
-            out.println() ;
-            out.print(dumpServletContext());
-            out.println() ;
-
-            out.println("==== Environment");
-            out.println() ;
-            out.print(dumpEnvironment());
-            out.println() ;
-
-            out.println("</pre>") ;
-
-            out.println("</body>") ;
-            out.println("</html>") ;
-            out.flush() ;
-        } catch (IOException e)
-        { }
-    }
-
-    // This resets the input stream
-
-    static public String dumpRequest(HttpServletRequest req)
-    {
-        try ( StringWriter sw = new StringWriter() ;
-              PrintWriter pw = new PrintWriter(sw) ) {
-            // Standard environment
-            pw.println("Method:                 "+req.getMethod());
-            pw.println("getContentLength:       "+Long.toString(req.getContentLengthLong()));
-            pw.println("getContentType:         "+req.getContentType());
-            pw.println("getRequestURI:          "+req.getRequestURI());
-            pw.println("getRequestURL:          "+req.getRequestURL());
-            pw.println("getContextPath:         "+req.getContextPath());
-            pw.println("getServletPath:         "+req.getServletPath());
-            pw.println("getPathInfo:            "+req.getPathInfo());
-            pw.println("getPathTranslated:      "+req.getPathTranslated());
-            pw.println("getQueryString:         "+req.getQueryString());
-            pw.println("getProtocol:            "+req.getProtocol());
-            pw.println("getScheme:              "+req.getScheme());
-            pw.println("getServerName:          "+req.getServerName());
-            pw.println("getServerPort:          "+req.getServerPort());
-            pw.println("getRemoteUser:          "+req.getRemoteUser());
-            pw.println("getRemoteAddr:          "+req.getRemoteAddr());
-            pw.println("getRemoteHost:          "+req.getRemoteHost());
-            pw.println("getRequestedSessionId:  "+req.getRequestedSessionId());
-            {
-                Cookie c[] = req.getCookies() ;
-                if ( c == null )
-                    pw.println("getCookies:            <none>");
-                else
-                {
-                    for ( int i = 0 ; i < c.length ; i++ )            
-                    {
-                        pw.println("Cookie:        "+c[i].getName());
-                        pw.println("    value:     "+c[i].getValue());
-                        pw.println("    version:   "+c[i].getVersion());
-                        pw.println("    comment:   "+c[i].getComment());
-                        pw.println("    domain:    "+c[i].getDomain());
-                        pw.println("    maxAge:    "+c[i].getMaxAge());
-                        pw.println("    path:      "+c[i].getPath());
-                        pw.println("    secure:    "+c[i].getSecure());
-                        pw.println();
-                    }
-                }
-            }
-            
-            {
-                // To do: create a string for the output so can send to console and return it.
-                Enumeration<String> en = req.getHeaderNames() ;
-
-                for ( ; en.hasMoreElements() ; )
-                {
-                    String name = en.nextElement() ;
-                    String value = req.getHeader(name) ;
-                    pw.println("Head: "+name + " = " + value) ;
-                }
-            }
-            
-            Enumeration<String> en2 = req.getAttributeNames() ;
-            if ( en2.hasMoreElements() )
-                pw.println();
-            for ( ; en2.hasMoreElements() ; )
-            {
-                String name = en2.nextElement() ;
-                String value = req.getAttribute(name).toString() ;
-                pw.println("Attr: "+name + " = " + value) ;
-            }
-
-            // Note that doing this on a form causes the forms content (body) to be read
-            // and parsed as form variables.
-//            en = req.getParameterNames() ;
-//            if ( en.hasMoreElements() )
-//                pw.println();
-//            for ( ; en.hasMoreElements() ; )
-//            {
-//                String name = (String)en.nextElement() ;
-//                String value = req.getParameter(name) ;
-//                pw.println("Param: "+name + " = " + value) ;
-//            }
-
-
-            
-//            MultiMap<String, String> map = WebLib.parseQueryString(req) ;
-//            for ( String name : map.keys() )
-//                for ( String value : map.get(name) )
-//                    pw.println("Param: "+name + " = " + value) ;
-            
-            Enumeration<Locale> en = req.getLocales() ;
-            if ( en.hasMoreElements() )
-                pw.println();
-            for ( ; en.hasMoreElements() ; )
-            {
-                String name = en.nextElement().toString() ;
-                pw.println("Locale: "+name) ;
-            }
-
-            pw.println() ;
-            //printBody(pw, req) ;
-
-            return sw.toString() ;
-        } catch (IOException e) { return null ; }
-    }
-
-    static void printBody(PrintWriter pw, HttpServletRequest req) throws IOException
-    {
-        BufferedReader in = req.getReader() ;
-        if ( req.getContentLength() > 0 )
-            // Need +2 because last line may not have a CR/LF on it.
-            in.mark(req.getContentLength()+2) ;
-        else
-            // This is a dump - try to do something that works, even if inefficient.
-            in.mark(100*1024) ;
-
-        while(true)
-        {
-            String x = in.readLine() ;
-            if ( x == null )
-                break ;
-            x = x.replaceAll("&", "&amp;") ;
-            x = x.replaceAll("<", "&lt;") ;
-            x = x.replaceAll(">", "&gt;") ;
-            pw.println(x) ;
-        }
-        try { in.reset() ; } catch (IOException e) { System.out.println("DumpServlet: Reset of content failed: "+e) ; }
-    }
-    
-    /**
-     * <code>dumpEnvironment</code>
-     * @return String that is the HTML of the System properties as name/value pairs.
-     * The values are with single quotes independent of whether or not the value has
-     * single quotes in it.
-     */
-    static public String dumpEnvironment()
-    {
-        Properties properties = System.getProperties();
-        try ( StringWriter sw = new StringWriter() ;
-            PrintWriter pw = new PrintWriter(sw) ; ) {
-            Enumeration<Object> en = properties.keys();
-            while(en.hasMoreElements())
-            {
-                String key = en.nextElement().toString();
-                pw.println(key+": '"+properties.getProperty(key)+"'");
-            }
-
-            pw.println() ;
-            return sw.toString() ;
-        } catch (IOException e) { IO.exception(e); return null ; }
-    }
-
-    public String dumpServletContext()
-    {
-        try ( StringWriter sw = new StringWriter() ;
-              PrintWriter pw = new PrintWriter(sw) ; ) {
-            ServletContext sc =  getServletContext();
-            pw.println("majorVersion: '"+sc.getMajorVersion()+"'");
-            pw.println("minorVersion: '"+sc.getMinorVersion()+"'");
-            pw.println("contextName:  '"+sc.getServletContextName()+"'");
-            pw.println("servletInfo:  '"+getServletInfo()+"'");
-            pw.println("serverInfo:  '"+sc.getServerInfo()+"'");
-    
-            {
-                Enumeration<String> en = sc.getInitParameterNames();
-                if (en != null) {
-                    pw.println("initParameters: ");
-                    while(en.hasMoreElements())
-                    {
-                        String key = en.nextElement();
-                        pw.println(key+": '"+sc.getInitParameter(key)+"'");
-                    }
-                }
-            }
-            
-            {
-                Enumeration<String> en = sc.getAttributeNames();
-                if (en != null) {
-                    pw.println("attributes: ");
-                    while(en.hasMoreElements())
-                    {
-                        String key = en.nextElement();
-                        pw.println(key+": '"+sc.getAttribute(key)+"'");
-                    }
-                }
-            }
-            pw.println() ;
-         
-             return sw.toString() ;
-        } catch (IOException e) { IO.exception(e); return null ; }
-    }
-
-    
-    @Override
-    public void doPost(HttpServletRequest req, HttpServletResponse resp)
-    {
-        doGet(req, resp) ;
-    }
-
-
-    @Override
-    public String getServletInfo()
-    {
-        return "Dump";
-    }
-}

http://git-wip-us.apache.org/repos/asf/jena/blob/59d1c0d6/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/WEB-INF/web.xml b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/WEB-INF/web.xml
index 0737e76..7de2f92 100644
--- a/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/WEB-INF/web.xml
+++ b/jena-fuseki2/jena-fuseki-webapp/src/main/webapp/WEB-INF/web.xml
@@ -222,21 +222,11 @@
   <!-- Admin controls-->
 
   <servlet>
-    <servlet-name>DumpServlet</servlet-name>
-    <servlet-class>org.apache.jena.fuseki.mgt.DumpServlet</servlet-class>
-  </servlet>
-
-  <servlet>
     <servlet-name>ServerStatusServlet</servlet-name>
     <servlet-class>org.apache.jena.fuseki.mgt.ActionServerStatus</servlet-class>
   </servlet>
 
   <servlet-mapping>
-    <servlet-name>DumpServlet</servlet-name>
-    <url-pattern>/$/dump</url-pattern>
-  </servlet-mapping>
-
-  <servlet-mapping>
     <servlet-name>ServerStatusServlet</servlet-name>
     <url-pattern>/$/server</url-pattern>
   </servlet-mapping>


[8/8] jena git commit: Merge commit 'refs/pull/484/head' of https://github.com/apache/jena

Posted by an...@apache.org.
Merge commit 'refs/pull/484/head' of https://github.com/apache/jena

This closes #484.


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

Branch: refs/heads/master
Commit: f0ac03914c94568e530cf70de0f6bcbd336f68c9
Parents: 33c7df7 b78f518
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Nov 1 19:57:44 2018 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Nov 1 19:57:44 2018 +0000

----------------------------------------------------------------------
 jena-cmds/src/main/java/arq/wwwenc.java         |  14 +-
 .../jena/fuseki/ctl/ActionDumpRequest.java      | 272 +++++++++++++++++
 jena-fuseki2/jena-fuseki-main/pom.xml           |  34 ++-
 .../jena-fuseki-main/sparqler/data/books.ttl    |  47 +++
 .../jena-fuseki-main/sparqler/data/empty.nt     |   1 +
 .../sparqler/log4j-foreground.properties        |  46 +++
 .../sparqler/log4j-server.properties            |  46 +++
 .../sparqler/pages/crossdomain.xml              |   3 +
 .../sparqler/pages/data-validator.html          |  65 ++++
 .../jena-fuseki-main/sparqler/pages/fuseki.css  | 148 +++++++++
 .../jena-fuseki-main/sparqler/pages/index.html  |  87 ++++++
 .../sparqler/pages/iri-validator.html           |  39 +++
 .../sparqler/pages/query-validator.html         |  71 +++++
 .../jena-fuseki-main/sparqler/pages/query.html  |  80 +++++
 .../jena-fuseki-main/sparqler/pages/robots.txt  |   2 +
 .../jena-fuseki-main/sparqler/pages/sparql.html |  68 +++++
 .../sparqler/pages/update-validator.html        |  63 ++++
 .../sparqler/pages/validator.html               |  52 ++++
 .../sparqler/pages/xml-to-html-links.xsl        | 183 +++++++++++
 .../sparqler/pages/xml-to-html-plain.xsl        | 187 ++++++++++++
 .../sparqler/pages/xml-to-html.xsl              | 187 ++++++++++++
 .../jena-fuseki-main/sparqler/run-sparqler      |  63 ++++
 .../jena/fuseki/main/cmds/FusekiMain.java       |   1 +
 .../org/apache/jena/fuseki/mgt/DumpServlet.java | 300 -------------------
 .../src/main/webapp/WEB-INF/web.xml             |  10 -
 25 files changed, 1755 insertions(+), 314 deletions(-)
----------------------------------------------------------------------



[3/8] jena git commit: SPARQLer web pages

Posted by an...@apache.org.
SPARQLer web pages


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

Branch: refs/heads/master
Commit: b78f5182bccda2194e5539a116f9619cc2921517
Parents: 59d1c0d
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 14:42:37 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:36:39 2018 +0100

----------------------------------------------------------------------
 jena-fuseki2/jena-fuseki-main/pom.xml           |  34 +++-
 .../jena-fuseki-main/sparqler/data/books.ttl    |  47 +++++
 .../jena-fuseki-main/sparqler/data/empty.nt     |   1 +
 .../sparqler/log4j-foreground.properties        |  46 +++++
 .../sparqler/log4j-server.properties            |  46 +++++
 .../sparqler/pages/crossdomain.xml              |   3 +
 .../sparqler/pages/data-validator.html          |  65 +++++++
 .../jena-fuseki-main/sparqler/pages/fuseki.css  | 148 +++++++++++++++
 .../jena-fuseki-main/sparqler/pages/index.html  |  87 +++++++++
 .../sparqler/pages/iri-validator.html           |  39 ++++
 .../sparqler/pages/query-validator.html         |  71 +++++++
 .../jena-fuseki-main/sparqler/pages/query.html  |  80 ++++++++
 .../jena-fuseki-main/sparqler/pages/robots.txt  |   2 +
 .../jena-fuseki-main/sparqler/pages/sparql.html |  68 +++++++
 .../sparqler/pages/update-validator.html        |  63 +++++++
 .../sparqler/pages/validator.html               |  52 ++++++
 .../sparqler/pages/xml-to-html-links.xsl        | 183 ++++++++++++++++++
 .../sparqler/pages/xml-to-html-plain.xsl        | 187 +++++++++++++++++++
 .../sparqler/pages/xml-to-html.xsl              | 187 +++++++++++++++++++
 .../jena-fuseki-main/sparqler/run-sparqler      |  63 +++++++
 20 files changed, 1471 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/pom.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/pom.xml b/jena-fuseki2/jena-fuseki-main/pom.xml
index 61ff7de..4b5dd2d 100644
--- a/jena-fuseki2/jena-fuseki-main/pom.xml
+++ b/jena-fuseki2/jena-fuseki-main/pom.xml
@@ -104,7 +104,39 @@
 
   <build>
     <plugins>
-      
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <!--<version>0.12</version>-->
+        <executions>
+          <execution>
+            <id>rat-checks</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <excludes>
+            <exclude>**/.project</exclude>
+            <exclude>**/.settings/**</exclude>
+            <exclude>**/.classpath</exclude>
+            <exclude>**/README.*</exclude>
+            <exclude>**/META-INF/services/*</exclude>
+            <exclude>**/dependency-reduced-pom.xml</exclude>
+
+            <exclude>fuseki.classpath</exclude>
+            <exclude>testing/**/*.ttl</exclude>
+            <exclude>testing/**/*.txt</exclude>
+            <exclude>sparqler/data/empty.nt</exclude>
+            <exclude>sparqler/pages/robots.txt</exclude>
+            <exclude>sparqler/pages/crossdomain.xml</exclude>
+
+          </excludes>
+        </configuration>
+      </plugin>
+
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/data/books.ttl
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/data/books.ttl b/jena-fuseki2/jena-fuseki-main/sparqler/data/books.ttl
new file mode 100644
index 0000000..6cba231
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/data/books.ttl
@@ -0,0 +1,47 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+PREFIX dc:        <http://purl.org/dc/elements/1.1/>
+PREFIX vcard:     <http://www.w3.org/2001/vcard-rdf/3.0#>
+PREFIX ns:        <http://example.org/ns#>
+
+PREFIX :          <http://example.org/book/>
+
+# This data is intentionaly irregular (e.g. different ways to
+# record the book creator) as if the information is either an
+# aggregation or was created at different times.
+
+:book1
+    dc:title    "Harry Potter and the Philosopher's Stone" ;
+    dc:creator  "J.K. Rowling" ;
+    .
+    
+:book2
+    dc:title    "Harry Potter and the Chamber of Secrets" ;
+    dc:creator  _:a .
+    
+:book3
+    dc:title    "Harry Potter and the Prisoner Of Azkaban" ;
+    dc:creator  _:a .
+    
+:book4
+    dc:title    "Harry Potter and the Goblet of Fire" .
+    
+:book5
+    dc:title    "Harry Potter and the Order of the Phoenix";
+    dc:creator  "J.K. Rowling" ;
+    .
+
+:book6
+    dc:title    "Harry Potter and the Half-Blood Prince";
+    dc:creator  "J.K. Rowling" .
+
+:book7
+    dc:title    "Harry Potter and the Deathly Hallows" ;
+    dc:creator  "J.K. Rowling" .
+_:a
+    vcard:FN "J.K. Rowling" ;
+    vcard:N
+        [ vcard:Family "Rowling" ;
+          vcard:Given "Joanna" 
+        ]
+    .

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/data/empty.nt
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/data/empty.nt b/jena-fuseki2/jena-fuseki-main/sparqler/data/empty.nt
new file mode 100644
index 0000000..739dd79
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/data/empty.nt
@@ -0,0 +1 @@
+# This is empty (except for this line!).

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/log4j-foreground.properties
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/log4j-foreground.properties b/jena-fuseki2/jena-fuseki-main/sparqler/log4j-foreground.properties
new file mode 100755
index 0000000..85db29f
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/log4j-foreground.properties
@@ -0,0 +1,46 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+log4j.rootLogger=INFO, stdlog
+#log4j.rootLogger=INFO, fileout
+
+log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
+## log4j.appender.stdlog.target=System.err
+log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# File logging, with roll over.
+log4j.appender.FusekiFileLog=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FusekiFileLog.DatePattern='.'yyyy-MM-dd
+log4j.appender.FusekiFileLog.File=fuseki-log
+log4j.appender.FusekiFileLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.FusekiFileLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# File logging - one file.
+log4j.appender.fileout=org.apache.log4j.FileAppender
+log4j.appender.fileout.File=log.joseki
+log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# Jetty - Fuseki catches Jetty errors and reports them.
+log4j.logger.org.eclipse.jetty=FATAL
+
+## # Execution logging
+## log4j.logger.com.hp.hpl.jena.arq.info=INFO
+## log4j.logger.com.hp.hpl.jena.arq.exec=INFO
+
+# Everything else in Jena
+log4j.logger.com.hp.hpl.jena=WARN
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.openjena=WARN
+log4j.logger.org.openjena.riot=WARN
+
+# Joseki server
+log4j.logger.org.joseki=INFO
+
+# Fuseki
+# Server log.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+# Request log.
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+# Internal logs
+log4j.logger.org.apache.jena.fuseki=INFO

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/log4j-server.properties
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/log4j-server.properties b/jena-fuseki2/jena-fuseki-main/sparqler/log4j-server.properties
new file mode 100755
index 0000000..a214d86
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/log4j-server.properties
@@ -0,0 +1,46 @@
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+#log4j.rootLogger=INFO, stdlog
+log4j.rootLogger=INFO, fileout
+
+log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
+## log4j.appender.stdlog.target=System.err
+log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdlog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# File logging, with roll over.
+log4j.appender.FusekiFileLog=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FusekiFileLog.DatePattern='.'yyyy-MM-dd
+log4j.appender.FusekiFileLog.File=fuseki.log
+log4j.appender.FusekiFileLog.layout=org.apache.log4j.PatternLayout
+log4j.appender.FusekiFileLog.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}%d{HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# File logging - one file.
+log4j.appender.fileout=org.apache.log4j.FileAppender
+log4j.appender.fileout.File=log.fuseki
+log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
+log4j.appender.fileout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %-20c{1} :: %m%n
+
+# Jetty - Fuseki catches Jetty errors and reports them.
+log4j.logger.org.eclipse.jetty=FATAL
+
+## # Execution logging
+## log4j.logger.com.hp.hpl.jena.arq.info=INFO
+## log4j.logger.com.hp.hpl.jena.arq.exec=INFO
+
+# Everything else in Jena
+log4j.logger.com.hp.hpl.jena=WARN
+log4j.logger.org.apache.jena=WARN
+log4j.logger.org.openjena=WARN
+log4j.logger.org.openjena.riot=WARN
+
+# Joseki server
+log4j.logger.org.joseki=INFO
+
+# Fuseki
+# Server log.
+log4j.logger.org.apache.jena.fuseki.Server=INFO
+# Request log.
+log4j.logger.org.apache.jena.fuseki.Fuseki=INFO
+# Internal logs
+log4j.logger.org.apache.jena.fuseki=INFO

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/crossdomain.xml
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/crossdomain.xml b/jena-fuseki2/jena-fuseki-main/sparqler/pages/crossdomain.xml
new file mode 100755
index 0000000..c1e814f
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/crossdomain.xml
@@ -0,0 +1,3 @@
+<cross-domain-policy>
+<allow-access-from domain="*"/>
+</cross-domain-policy>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/data-validator.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/data-validator.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/data-validator.html
new file mode 100755
index 0000000..bc28420
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/data-validator.html
@@ -0,0 +1,65 @@
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer Data Validator</title>
+    <link rel="stylesheet" type="text/css" href="fuseki.css" />
+  </head>
+  <body>
+    <h1>SPARQLer Data Validator</h1>
+    <div class="moreindent">
+      <form action="validate/data" method="post" accept-charset="UTF-8" >
+	    <textarea name="data" cols="70" rows="30">
+# Prefixes for Turtle or TriG - these can be edited or removed.
+@base          &lt;http://example.org/base/> .
+@prefix :      &lt;http://example.org/> .
+@prefix xsd:   &lt;http://www.w3.org/2001/XMLSchema#> .
+@prefix rdf:   &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs:  &lt;http://www.w3.org/2000/01/rdf-schema#> .
+@prefix owl:   &lt;http://www.w3.org/2002/07/owl#> .
+
+
+</textarea>
+<br/>
+Input syntax:
+<input type="radio" name="languageSyntax" value="Turtle" checked="checked"/>Turtle
+<input type="radio" name="languageSyntax" value="TriG"/>TriG
+<input type="radio" name="languageSyntax" value="N-Triples"/>N-Triples
+<input type="radio" name="languageSyntax" value="N-Quads"/>N-Quad
+  <br/>
+      <!--
+Output syntax:
+  <input type="checkbox" name="outputFormat" value="sparql" checked="checked"/>SPARQL
+  <input type="checkbox" name="outputFormat" value="algebra"/>SPARQL algebra
+  <input type="checkbox" name="outputFormat" value="quads"/>SPARQL algebra (quads)
+  <br/>
+
+  Line numbers:
+  <input type="radio" name="linenumbers" value="true" checked="checked"/>Yes
+  <input type="radio" name="linenumbers" value="false"/>No
+  <br/>
+      -->
+        <input type="submit" value="Validate RDF Data" />
+      </form>
+      <hr/>
+Parsing provided by <a href="http://jena.apache.org/documentation/io/">Jena/RIOT</a>.
+Questions to 
+<href="mailto:users@jena.apache.org?s=[Data Validator]: ">users@jena</a>
+(include full details of input).
+    </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/fuseki.css
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/fuseki.css b/jena-fuseki2/jena-fuseki-main/sparqler/pages/fuseki.css
new file mode 100755
index 0000000..e3e5763
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/fuseki.css
@@ -0,0 +1,148 @@
+/**
+   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.
+*/
+body {
+    font-family: Verdana, Arial, Helvetica, sans-serif ;
+    font-size: 10pt ;
+    line-height: 18pt ;
+    color: black;
+    background: white ;
+    margin: 0 ;
+}
+
+textarea { background-color: #F0F0F0 ; }
+
+p { margin-left: 2% ; margin-right: 2% ; }
+
+.warning { color: #FF0000 ; }
+.error   { color: #FF0000 ;  font-weight: bold; }
+
+/* Makes lists a little tighter
+li { line-height: 14pt ; }
+*/
+
+table {
+  font-family: Verdana, Arial, sans-serif ;
+  font-size: 10pt ;
+  border-collapse: collapse;
+  border: 1px solid black ;
+  cellspacing: 0 ;
+  cellpadding: 0 
+}
+
+td {
+  border: 1px solid #808080 ;
+  empty-cells: show;
+  padding: 5 ;
+  spacing: 0 ;
+  vertical-align:top;
+  text-align:center
+}
+
+
+th {
+  border: 1px solid #808080 ;
+  empty-cells: show;
+  padding: 5 ;
+  vertical-align:top;
+  text-align:center
+}
+
+.box 
+{ margin-left :     5% ;
+  margin-right :    5% ;
+  border:           solid ;
+  border-width:     thin; 
+  background-color: #F0F0F0; 
+  padding:          2mm;
+  page-break-inside: avoid ;
+}
+
+.noindent     { margin-left: -5% ; margin-right: -5%; }
+.moreindent   { margin-left:  5% ; margin-right:  5%; }
+
+
+/* Use this for the document title as displayed on the page at the top. */
+
+
+h1 {
+    text-align:center ;
+    font-size: 14pt;
+    line-height: 24pt ;
+    font-weight: bold;
+    color:#000;
+    background:#CADFF4;
+    padding: 0 ;
+    margin: 0 ;
+    padding-left: 1ex;
+    padding-right: 1ex;
+    text-align:center;
+}
+
+h2 {
+    font-size: 12pt;
+    line-height: 16pt ;
+    font-size: 110%;
+    font-weight: bold;
+    color: #003399;
+    background:#CADFF4;
+    margin-bottom:5px;
+    padding-left: 1ex;
+    padding-right: 1ex;
+}
+
+h3, h4, h5 {
+    font-size: 100%;
+    font-weight: bold;
+    margin-bottom:3px;
+}
+
+ul { list-style-type: disc }
+dt { font-weight: bold }
+
+/* Change background/foreground colour on hover */
+
+A:link { color: rgb(0, 0, 255) }        /* for unvisited links */
+A:hover { color: rgb(255, 0, 0) }       /* when mouse is over link */
+
+/* No extra space between paragraphs : inherits from body */
+pre {
+    font-family: monospace;
+    font-size: 10pt ;
+    line-height: 14pt ;
+    margin-top: 1 ;
+    margin-bottom: 1 ;
+    margin-left: 5ex ;
+    }
+
+/* Some general utility definitions */
+.centered {
+    text-align: center;
+}
+
+.caption {
+    text-align: center;
+    font-size: smaller;
+}
+
+code {
+    font-size: 10pt;
+}
+
+.footnote {
+    font-size: smaller;
+    border-top: thin solid gray;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/index.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/index.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/index.html
new file mode 100755
index 0000000..dd17323
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/index.html
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>SPARQLer - An RDF Query Server</title>
+    <link rel="stylesheet" type="text/css" href="fuseki.css" />
+  </head>
+<body>
+    <h1>SPARQLer</h1>
+    
+    <p>&nbsp;</p>
+
+    <h2>Validators</h2>
+    <ul>
+      <li><a href="query-validator.html">SPARQL query validator</a></li>
+      <li><a href="update-validator.html">SPARQL update validator</a></li>
+      <li><a href="data-validator.html">RDF data validator</a></li>
+      <li><a href="iri-validator.html">IRI validator</a></li>
+    </ul>
+
+    <h2>Query</h2>
+
+    <ul>
+      <li><a href="sparql.html">General purpose SPARQL processor</a></li>
+    </ul>
+
+    <h2>SPARQL Services</h2>
+
+    <p>The general SPARQL query service is accessed directly using the SPARQL
+      protocol at URL <tt>/sparql</tt></p>
+
+    <h2>Links to SPARQL 1.1 Specifications</h2>
+    
+    <p>The full set of SPARQL specification is:</p>
+
+    <ul>
+      <li><a href="http://www.w3.org/TR/sparql11-query/"
+             >SPARQL Query language</a></li>
+      <li><a href="http://www.w3.org/TR/sparql11-update/"
+           >SPARQL Update</a></li>
+      <li><a href="http://www.w3.org/TR/sparql11-protocol/"
+             >SPARQL Protocol</a></li>
+      <li><a href="http://www.w3.org/TR/sparql11-http-rdf-update/"
+             >SPARQL Graph Store Protocol</a></li>
+      <li>SPARQL Result formats
+        <ul>
+          <li><a href="http://www.w3.org/TR//sparql11-results-json/"
+                 >SPARQL Query Results JSON Format</a></li>
+          <li><a href="http://www.w3.org/TR/sparql11-results-csv-tsv/"
+                 >SPARQL Query Results CSV and TSV Formats</a></li>
+          <li><a href="http://www.w3.org/TR/rdf-sparql-XMLres/"
+                 >SPARQL Query Results XML Format</a></li>
+        </ul>
+      <li><a href="http://www.w3.org/TR/sparql11-service-description/"
+             >SPARQL Service Description</a></li>
+      <li><a href="http://www.w3.org/TR/sparql11-federated-query/"
+             >SPARQL Federated Query</a></li>
+      <li><a href="http://www.w3.org/TR/sparql11-entailment/"
+             >SPARQL Entailment Regimes</a></li>
+    </ul>
+
+    <hr/>
+
+    <p>This server is running 
+      <a href="https://jena.apache.org/documentation/fuseki2/fuseki-main.html">Apache Jena Fuseki</a>.</p>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/iri-validator.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/iri-validator.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/iri-validator.html
new file mode 100755
index 0000000..ad55941
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/iri-validator.html
@@ -0,0 +1,39 @@
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer Query Validator</title>
+
+  <link rel="stylesheet" type="text/css" href="fuseki.css" />
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+  </head>
+  <body>
+    <h1>SPARQLer IRI Validator</h1>
+
+    <div class="moreindent">
+
+      <form action="validate/iri"  accept-charset="UTF-8">
+	    <p>
+	      <textarea name="iri" cols="70" rows="2"></textarea>
+
+          <input type="submit" value="Validate IRI" />
+	    </p>
+      </form>
+      <hr/>
+    </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/query-validator.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/query-validator.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/query-validator.html
new file mode 100755
index 0000000..f910650
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/query-validator.html
@@ -0,0 +1,71 @@
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer Query Validator</title>
+
+  <link rel="stylesheet" type="text/css" href="fuseki.css" />
+
+  </head>
+  <body>
+    <h1>SPARQLer Query Validator</h1>
+
+    <div class="moreindent">
+
+      <form action="validate/query" method="post" accept-charset="UTF-8">
+	<p>
+	  <textarea name="query" cols="70" rows="30">
+PREFIX xsd:     &lt;http://www.w3.org/2001/XMLSchema#>
+PREFIX rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
+PREFIX rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#>
+PREFIX owl:     &lt;http://www.w3.org/2002/07/owl#>
+PREFIX fn:      &lt;http://www.w3.org/2005/xpath-functions#>
+PREFIX apf:     &lt;http://jena.hpl.hp.com/ARQ/property#>
+PREFIX dc:      &lt;http://purl.org/dc/elements/1.1/>
+
+SELECT ?book ?title
+WHERE
+   { ?book dc:title ?title }</textarea>
+<br/>
+  Input syntax:<br/>
+    <input type="radio" name="languageSyntax" value="SPARQL" checked="checked"/>SPARQL
+    <input type="radio" name="languageSyntax" value="ARQ"/>SPARQL extended syntax
+  <br/>
+  <br/>
+Output:<br/>
+  <input type="checkbox" name="outputFormat" value="sparql" checked="checked"/>SPARQL<br/>
+  <input type="checkbox" name="outputFormat" value="algebra"/>SPARQL algebra<br/>
+  <input type="checkbox" name="outputFormat" value="quads"/>SPARQL algebra (quads)<br/>
+  <input type="checkbox" name="outputFormat" value="opt"/>SPARQL algebra
+(general optimizations)<br/>
+  <input type="checkbox" name="outputFormat" value="optquads"/>SPARQL algebra
+(quads, general optimizations)<br/>
+  <br/>
+  Line numbers:
+  <input type="radio" name="linenumbers" value="true" checked="checked"/>Yes
+  <input type="radio" name="linenumbers" value="false"/>No
+  <br/>
+
+
+  <input type="submit" value="Validate SPARQL Query" />
+	</p>
+      </form>
+
+      <hr/>
+    </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/query.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/query.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/query.html
new file mode 100755
index 0000000..d61d4fb
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/query.html
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer</title>
+  <link rel="stylesheet" type="text/css" href="fuseki.css" />
+  </head>
+
+  <body>
+    <h1>SPARQLer - An RDF Query Demo</h1>
+    <p>Example queries (or edit and write your own!).  All the text boxes invoke the same "books" service - they just get initialised with different examples.</p>
+    <hr/>
+
+    <div class="moreindent">
+
+      <form action="books/sparql" method="get">
+	<p>SELECT - get variables (apply XSLT stylesheet)</p>
+    <p><textarea name="query" cols="70" rows="15">
+PREFIX books:   &lt;http://example.org/book/&gt;
+PREFIX dc:      &lt;http://purl.org/dc/elements/1.1/&gt;
+SELECT ?book ?title
+WHERE 
+  { ?book dc:title ?title }</textarea>
+	  <br/>
+
+      Output: <select name="output">
+        <option value="json">JSON</option>
+        <option value="xml">XML</option>
+        <option value="text">Text</option>
+        <option value="csv">CSV</option>
+        <option value="tsv">TSV</option>
+      </select>
+      <br/>
+	  XSLT style sheet (blank for none): 
+      <input name="stylesheet" size="20" value="/xml-to-html.xsl" />
+      <br/>
+      <input type="checkbox" name="force-accept" value="text/plain"/>
+      Force the accept header to <tt>text/plain</tt> regardless 
+	  <br/>
+	   
+	  <input type="submit" value="Get Results" />
+	</p>
+      </form>
+
+      <hr/>
+
+      <form action="books/sparql">
+	<p>CONSTRUCT - return a graph</p>
+	<p><textarea name="query" cols="70" rows="10">
+PREFIX dc:      &lt;http://purl.org/dc/elements/1.1/&gt;
+CONSTRUCT { $book dc:title $title }
+WHERE 
+  { $book dc:title $title }
+	  </textarea>
+	  <br/>
+	  <input type="submit" value="Get Results" />
+	</p>
+      </form>
+      <hr/>
+    </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/robots.txt
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/robots.txt b/jena-fuseki2/jena-fuseki-main/sparqler/pages/robots.txt
new file mode 100755
index 0000000..1f53798
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Disallow: /

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/sparql.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/sparql.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/sparql.html
new file mode 100755
index 0000000..c9df10e
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/sparql.html
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer</title>
+    <link rel="stylesheet" type="text/css" href="/fuseki.css" />
+  </head>
+
+  <body>
+    <h1>SPARQLer - General purpose processor</h1>
+
+    <div class="moreindent">
+
+      <form action="sparql" method="get">
+	<p>General SPARQL query : input query, set any options and press "Get Results"</p>
+	<p>
+	  <textarea style="background-color: #F0F0F0;" name="query" cols="70" rows="20"></textarea>
+	  <br/>
+	  Target graph URI (or use <code>FROM</code> in the query)
+	  <input name="default-graph-uri" size="25" value="" />
+    <br/>
+    If no dataset is provided, the query will execute agains an empty one.<br/>
+    The query can contain use <code>VALUES</code> to set some variables.
+    <br/>
+    <br/>
+      Output: <select name="output">
+        <option value="json">JSON</option>
+        <option value="xml">XML</option>
+        <option value="text">Text</option>
+        <option value="csv">CSV</option>
+        <option value="tsv">TSV</option>
+      </select>
+      <br/>
+	  XSLT style sheet (blank for none): 
+      <input name="stylesheet" size="20" value="/xml-to-html.xsl" />
+      <br/>
+      <input type="checkbox" name="force-accept" value="text/plain"/>
+      Force the accept header to <tt>text/plain</tt> regardless 
+	  <br/>
+    <br/>
+	  <input type="submit" value="Get Results" />
+    
+	</p>
+      </form>
+    </div>
+
+    <hr/>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/update-validator.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/update-validator.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/update-validator.html
new file mode 100755
index 0000000..a0ff581
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/update-validator.html
@@ -0,0 +1,63 @@
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head><title>SPARQLer Update Validator</title>
+
+  <link rel="stylesheet" type="text/css" href="fuseki.css" />
+
+  </head>
+  <body>
+    <h1>SPARQLer Update Validator</h1>
+
+    <div class="moreindent">
+
+
+      <form action="validate/update" method="post" accept-charset="UTF-8">
+	  <textarea name="update" cols="70" rows="30">
+PREFIX xsd:     &lt;http://www.w3.org/2001/XMLSchema#>
+PREFIX rdf:     &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
+PREFIX rdfs:    &lt;http://www.w3.org/2000/01/rdf-schema#>
+PREFIX owl:     &lt;http://www.w3.org/2002/07/owl#>
+PREFIX fn:      &lt;http://www.w3.org/2005/xpath-functions#>
+PREFIX apf:     &lt;http://jena.hpl.hp.com/ARQ/property#>
+
+</textarea>
+<br/>
+  Input syntax:
+    <input type="radio" name="languageSyntax" value="SPARQL" checked="checked"/>SPARQL
+    <input type="radio" name="languageSyntax" value="ARQ"/>SPARQL extended syntax
+  <br/>
+<!--
+Output syntax:
+  <input type="checkbox" name="outputFormat" value="sparql" checked="checked"/>SPARQL
+  <input type="checkbox" name="outputFormat" value="algebra"/>SPARQL algebra
+  <input type="checkbox" name="outputFormat" value="quads"/>SPARQL algebra (quads)
+  <br/>
+-->
+  Line numbers:
+  <input type="radio" name="linenumbers" value="true" checked="checked"/>Yes
+  <input type="radio" name="linenumbers" value="false"/>No
+  <br/>
+
+  <input type="submit" value="Validate SPARQL Update" />
+      </form>
+
+      <hr/>
+    </div>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/validator.html
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/validator.html b/jena-fuseki2/jena-fuseki-main/sparqler/pages/validator.html
new file mode 100755
index 0000000..48faf6c
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/validator.html
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<!--
+   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.
+-->
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <title>SPARQL Query Validator</title>
+    <link rel="stylesheet" type="text/css" href="fuseki.css" />
+    <meta http-equiv="refresh" content="5;url=http://sparql.org/query-validator.html">
+  </head>
+<body>
+    <h1>SPARQLer</h1>
+    
+    <p>
+The SPARQL query validator page has moved to 
+<a href="http://sparql.org/query-validator.html">http://sparql.org/query-validator.html</a>.
+You should be redirected there in a few seconds.
+</p>
+
+    <h2>Validators</h2>
+    <ul>
+      <li><a href="query-validator.html">SPARQL query validator</a></li>
+      <li><a href="update-validator.html">SPARQL update validator</a></li>
+      <li><a href="data-validator.html">RDF data validator</a></li>
+      <li><a href="iri-validator.html">IRI validator</a></li>
+    </ul>
+
+    <hr/>
+
+    <p>This server is running 
+      <a href="http://jena.apache.org/documentation/serving_data/index.html"
+         >Apache Jena Fuseki</a>.</p>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-links.xsl
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-links.xsl b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-links.xsl
new file mode 100755
index 0000000..9e0a450
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-links.xsl
@@ -0,0 +1,183 @@
+<?xml version="1.0"?>
+
+<!--
+
+XSLT script to format SPARQL Query Results XML Format into xhtml
+
+Copyright © 2004, 2005 World Wide Web Consortium, (Massachusetts
+Institute of Technology, European Research Consortium for
+Informatics and Mathematics, Keio University). All Rights
+Reserved. This work is distributed under the W3C® Software
+License [1] in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.
+
+[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+Version 1 : Dave Beckett (DAWG)
+Version 2 : Jeen Broekstra (DAWG)
+Customization for SPARQler: Andy Seaborne
+URIs as hrefs in results : Bob DuCharme & Andy Seaborne
+
+> -    <xsl:for-each select="//res:head/res:variable">
+> +    <xsl:for-each select="/res:sparql/res:head/res:variable">
+
+-->
+
+<xsl:stylesheet version="1.0"
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns="http://www.w3.org/1999/xhtml"
+		xmlns:res="http://www.w3.org/2005/sparql-results#"
+		xmlns:fn="http://www.w3.org/2005/xpath-functions"
+		exclude-result-prefixes="res xsl">
+
+  <!--
+    <xsl:output
+    method="html"
+    media-type="text/html"
+    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+    indent="yes"
+    encoding="UTF-8"/>
+  -->
+
+  <!-- or this? -->
+
+  <xsl:output
+   method="xml" 
+   indent="yes"
+   encoding="UTF-8" 
+   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+   omit-xml-declaration="no" />
+
+    <xsl:template match="res:link">
+      <p>Link to <xsl:value-of select="@href"/></p>
+    </xsl:template>
+
+    <xsl:template name="header">
+      <div>
+        <h2>Header</h2>
+        <xsl:apply-templates select="res:head/res:link"/>
+      </div>
+    </xsl:template>
+
+  <xsl:template name="boolean-result">
+    <div>
+      <p>ASK => <xsl:value-of select="res:boolean"/></p>
+    </div>
+  </xsl:template>
+
+
+  <xsl:template name="vb-result">
+    <div>
+      <table>
+	<xsl:text>
+	</xsl:text>
+	<tr>
+	  <xsl:for-each select="res:head/res:variable">
+	    <th><xsl:value-of select="@name"/></th>
+	  </xsl:for-each>
+	</tr>
+	<xsl:text>
+	</xsl:text>
+	<xsl:for-each select="res:results/res:result">
+	  <tr>
+	    <xsl:apply-templates select="."/>
+	  </tr>
+	</xsl:for-each>
+      </table>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="res:result">
+    <xsl:variable name="current" select="."/>
+    <xsl:for-each select="/res:sparql/res:head/res:variable">
+      <xsl:variable name="name" select="@name"/>
+      <td>
+	<xsl:choose>
+	  <xsl:when test="$current/res:binding[@name=$name]">
+	    <!-- apply template for the correct value type (bnode, uri, literal) -->
+	    <xsl:apply-templates select="$current/res:binding[@name=$name]"/>
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <!-- no binding available for this variable in this solution -->
+	  </xsl:otherwise>
+	</xsl:choose>
+      </td>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template match="res:bnode">
+    <xsl:text>_:</xsl:text>
+    <xsl:value-of select="text()"/>
+  </xsl:template>
+
+  <xsl:template match="res:uri">
+    <!-- Roughly: SELECT ($uri AS ?subject) ?predicate ?object { $uri ?predicate ?object } -->
+    <!-- XSLT 2.0
+    <xsl:variable name="x"><xsl:value-of select="fn:encode-for-uri(.)"/></xsl:variable>
+    -->
+    <xsl:variable name="x"><xsl:value-of select="."/></xsl:variable>
+    <!--
+    <xsl:variable name="query">SELECT%20%28%3C<xsl:value-of select="."/>%3E%20AS%20%3Fsubject%29%20%3Fpredicate%20%3Fobject%20%7B%3C<xsl:value-of select="."/>%3E%20%3Fpredicate%20%3Fobject%20%7D</xsl:variable>
+    -->
+     <xsl:variable name="query">SELECT%20%28%3C<xsl:value-of select="$x"/>%3E%20AS%20%3Fsubject%29%20%3Fpredicate%20%3Fobject%20%7B%3C<xsl:value-of select="$x"/>%3E%20%3Fpredicate%20%3Fobject%20%7D</xsl:variable>
+    <xsl:text>&lt;</xsl:text>
+    <a href="?query={$query}&amp;output=xml&amp;stylesheet=%2Fxml-to-html.xsl">
+    <xsl:value-of select="."/>
+    </a>
+    <xsl:text>&gt;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="res:literal[@datatype]">
+	<!-- datatyped literal value -->
+    "<xsl:value-of select="."/>"^^&lt;<xsl:value-of select="@datatype"/>&gt;
+  </xsl:template>
+
+  <xsl:template match="res:literal[@lang]">
+	<!-- datatyped literal value -->
+    "<xsl:value-of select="."/>"<xsl:value-of select="@xml:lang"/>
+  </xsl:template>
+
+  <xsl:template match="res:sparql">
+    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+      <head>
+	<title>SPARQLer Query Results</title>
+	<style>
+	  <![CDATA[
+	  h1 { font-size: 150% ; }
+	  h2 { font-size: 125% ; }
+	  table { border-collapse: collapse ; border: 1px solid black ; }
+	  td, th
+ 	  { border: 1px solid black ;
+	    padding-left:0.5em; padding-right: 0.5em; 
+	    padding-top:0.2ex ; padding-bottom:0.2ex 
+	  }
+	  ]]>
+	</style>
+      </head>
+      <body>
+
+
+	<h1>SPARQLer Query Results</h1>
+
+	<xsl:if test="res:head/res:link">
+	  <xsl:call-template name="header"/>
+	</xsl:if>
+
+	<xsl:choose>
+	  <xsl:when test="res:boolean">
+	    <xsl:call-template name="boolean-result" />
+	  </xsl:when>
+
+	  <xsl:when test="res:results">
+	    <xsl:call-template name="vb-result" />
+	  </xsl:when>
+
+	</xsl:choose>
+
+
+      </body>
+    </html>
+  </xsl:template>
+</xsl:stylesheet>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-plain.xsl
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-plain.xsl b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-plain.xsl
new file mode 100755
index 0000000..1878ab0
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html-plain.xsl
@@ -0,0 +1,187 @@
+<?xml version="1.0"?>
+
+<!--
+
+XSLT script to format SPARQL Query Results XML Format into xhtml
+
+Copyright © 2004, 2005 World Wide Web Consortium, (Massachusetts
+Institute of Technology, European Research Consortium for
+Informatics and Mathematics, Keio University). All Rights
+Reserved. This work is distributed under the W3C® Software
+License [1] in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.
+
+[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+Version 1 : Dave Beckett (DAWG)
+Version 2 : Jeen Broekstra (DAWG)
+Customization for SPARQler: Andy Seaborne
+Fix:
+
+> -    <xsl:for-each select="//res:head/res:variable">
+> +    <xsl:for-each select="/res:sparql/res:head/res:variable">
+
+-->
+
+<xsl:stylesheet version="1.0"
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns="http://www.w3.org/1999/xhtml"
+		xmlns:res="http://www.w3.org/2005/sparql-results#"
+		exclude-result-prefixes="res xsl">
+
+  <!--
+    <xsl:output
+    method="html"
+    media-type="text/html"
+    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+    indent="yes"
+    encoding="UTF-8"/>
+  -->
+
+  <!-- or this? -->
+
+  <xsl:output
+   method="xml" 
+   indent="yes"
+   encoding="UTF-8" 
+   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+   omit-xml-declaration="no" />
+
+
+  <xsl:template name="header">
+    <div>
+      <h2>Header</h2>
+      <xsl:for-each select="res:head/res:link"> 
+	<p>Link to <xsl:value-of select="@href"/></p>
+      </xsl:for-each>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="boolean-result">
+    <div>
+      <!--      
+	<h2>Boolean Result</h2>
+      -->      
+      <p>ASK => <xsl:value-of select="res:boolean"/></p>
+    </div>
+  </xsl:template>
+
+
+  <xsl:template name="vb-result">
+    <div>
+      <!--
+	<h2>Variable Bindings Result</h2>
+	<p>Ordered: <xsl:value-of select="res:results/@ordered"/></p>
+	<p>Distinct: <xsl:value-of select="res:results/@distinct"/></p>
+      -->
+
+      <table>
+	<xsl:text>
+	</xsl:text>
+	<tr>
+	  <xsl:for-each select="res:head/res:variable">
+	    <th><xsl:value-of select="@name"/></th>
+	  </xsl:for-each>
+	</tr>
+	<xsl:text>
+	</xsl:text>
+	<xsl:for-each select="res:results/res:result">
+	  <tr>
+	    <xsl:apply-templates select="."/>
+	  </tr>
+	</xsl:for-each>
+      </table>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="res:result">
+    <xsl:variable name="current" select="."/>
+    <xsl:for-each select="/res:sparql/res:head/res:variable">
+      <xsl:variable name="name" select="@name"/>
+      <td>
+	<xsl:choose>
+	  <xsl:when test="$current/res:binding[@name=$name]">
+	    <!-- apply template for the correct value type (bnode, uri, literal) -->
+	    <xsl:apply-templates select="$current/res:binding[@name=$name]"/>
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <!-- no binding available for this variable in this solution -->
+	  </xsl:otherwise>
+	</xsl:choose>
+      </td>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template match="res:bnode">
+    <xsl:text>_:</xsl:text>
+    <xsl:value-of select="text()"/>
+  </xsl:template>
+
+  <xsl:template match="res:uri">
+    <xsl:variable name="uri" select="text()"/>
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="$uri"/>
+    <xsl:text>&gt;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="res:literal">
+    <xsl:text>"</xsl:text>
+    <xsl:value-of select="text()"/>
+    <xsl:text>"</xsl:text>
+
+    <xsl:choose>
+      <xsl:when test="@datatype">
+	<!-- datatyped literal value -->
+	^^&lt;<xsl:value-of select="@datatype"/>&gt;
+      </xsl:when>
+      <xsl:when test="@xml:lang">
+	<!-- lang-string -->
+	@<xsl:value-of select="@xml:lang"/>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="res:sparql">
+    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+      <head>
+	<title>SPARQLer Query Results</title>
+	<style>
+	  <![CDATA[
+	  h1 { font-size: 150% ; }
+	  h2 { font-size: 125% ; }
+	  table { border-collapse: collapse ; border: 1px solid black ; }
+	  td, th
+ 	  { border: 1px solid black ;
+	    padding-left:0.5em; padding-right: 0.5em; 
+	    padding-top:0.2ex ; padding-bottom:0.2ex 
+	  }
+	  ]]>
+	</style>
+      </head>
+      <body>
+
+
+	<h1>SPARQLer Query Results</h1>
+
+	<xsl:if test="res:head/res:link">
+	  <xsl:call-template name="header"/>
+	</xsl:if>
+
+	<xsl:choose>
+	  <xsl:when test="res:boolean">
+	    <xsl:call-template name="boolean-result" />
+	  </xsl:when>
+
+	  <xsl:when test="res:results">
+	    <xsl:call-template name="vb-result" />
+	  </xsl:when>
+
+	</xsl:choose>
+
+
+      </body>
+    </html>
+  </xsl:template>
+</xsl:stylesheet>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html.xsl
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html.xsl b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html.xsl
new file mode 100755
index 0000000..1878ab0
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/pages/xml-to-html.xsl
@@ -0,0 +1,187 @@
+<?xml version="1.0"?>
+
+<!--
+
+XSLT script to format SPARQL Query Results XML Format into xhtml
+
+Copyright © 2004, 2005 World Wide Web Consortium, (Massachusetts
+Institute of Technology, European Research Consortium for
+Informatics and Mathematics, Keio University). All Rights
+Reserved. This work is distributed under the W3C® Software
+License [1] in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.
+
+[1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
+
+Version 1 : Dave Beckett (DAWG)
+Version 2 : Jeen Broekstra (DAWG)
+Customization for SPARQler: Andy Seaborne
+Fix:
+
+> -    <xsl:for-each select="//res:head/res:variable">
+> +    <xsl:for-each select="/res:sparql/res:head/res:variable">
+
+-->
+
+<xsl:stylesheet version="1.0"
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns="http://www.w3.org/1999/xhtml"
+		xmlns:res="http://www.w3.org/2005/sparql-results#"
+		exclude-result-prefixes="res xsl">
+
+  <!--
+    <xsl:output
+    method="html"
+    media-type="text/html"
+    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+    indent="yes"
+    encoding="UTF-8"/>
+  -->
+
+  <!-- or this? -->
+
+  <xsl:output
+   method="xml" 
+   indent="yes"
+   encoding="UTF-8" 
+   doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
+   doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+   omit-xml-declaration="no" />
+
+
+  <xsl:template name="header">
+    <div>
+      <h2>Header</h2>
+      <xsl:for-each select="res:head/res:link"> 
+	<p>Link to <xsl:value-of select="@href"/></p>
+      </xsl:for-each>
+    </div>
+  </xsl:template>
+
+  <xsl:template name="boolean-result">
+    <div>
+      <!--      
+	<h2>Boolean Result</h2>
+      -->      
+      <p>ASK => <xsl:value-of select="res:boolean"/></p>
+    </div>
+  </xsl:template>
+
+
+  <xsl:template name="vb-result">
+    <div>
+      <!--
+	<h2>Variable Bindings Result</h2>
+	<p>Ordered: <xsl:value-of select="res:results/@ordered"/></p>
+	<p>Distinct: <xsl:value-of select="res:results/@distinct"/></p>
+      -->
+
+      <table>
+	<xsl:text>
+	</xsl:text>
+	<tr>
+	  <xsl:for-each select="res:head/res:variable">
+	    <th><xsl:value-of select="@name"/></th>
+	  </xsl:for-each>
+	</tr>
+	<xsl:text>
+	</xsl:text>
+	<xsl:for-each select="res:results/res:result">
+	  <tr>
+	    <xsl:apply-templates select="."/>
+	  </tr>
+	</xsl:for-each>
+      </table>
+    </div>
+  </xsl:template>
+
+  <xsl:template match="res:result">
+    <xsl:variable name="current" select="."/>
+    <xsl:for-each select="/res:sparql/res:head/res:variable">
+      <xsl:variable name="name" select="@name"/>
+      <td>
+	<xsl:choose>
+	  <xsl:when test="$current/res:binding[@name=$name]">
+	    <!-- apply template for the correct value type (bnode, uri, literal) -->
+	    <xsl:apply-templates select="$current/res:binding[@name=$name]"/>
+	  </xsl:when>
+	  <xsl:otherwise>
+	    <!-- no binding available for this variable in this solution -->
+	  </xsl:otherwise>
+	</xsl:choose>
+      </td>
+    </xsl:for-each>
+  </xsl:template>
+
+  <xsl:template match="res:bnode">
+    <xsl:text>_:</xsl:text>
+    <xsl:value-of select="text()"/>
+  </xsl:template>
+
+  <xsl:template match="res:uri">
+    <xsl:variable name="uri" select="text()"/>
+    <xsl:text>&lt;</xsl:text>
+    <xsl:value-of select="$uri"/>
+    <xsl:text>&gt;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="res:literal">
+    <xsl:text>"</xsl:text>
+    <xsl:value-of select="text()"/>
+    <xsl:text>"</xsl:text>
+
+    <xsl:choose>
+      <xsl:when test="@datatype">
+	<!-- datatyped literal value -->
+	^^&lt;<xsl:value-of select="@datatype"/>&gt;
+      </xsl:when>
+      <xsl:when test="@xml:lang">
+	<!-- lang-string -->
+	@<xsl:value-of select="@xml:lang"/>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:template>
+
+  <xsl:template match="res:sparql">
+    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+      <head>
+	<title>SPARQLer Query Results</title>
+	<style>
+	  <![CDATA[
+	  h1 { font-size: 150% ; }
+	  h2 { font-size: 125% ; }
+	  table { border-collapse: collapse ; border: 1px solid black ; }
+	  td, th
+ 	  { border: 1px solid black ;
+	    padding-left:0.5em; padding-right: 0.5em; 
+	    padding-top:0.2ex ; padding-bottom:0.2ex 
+	  }
+	  ]]>
+	</style>
+      </head>
+      <body>
+
+
+	<h1>SPARQLer Query Results</h1>
+
+	<xsl:if test="res:head/res:link">
+	  <xsl:call-template name="header"/>
+	</xsl:if>
+
+	<xsl:choose>
+	  <xsl:when test="res:boolean">
+	    <xsl:call-template name="boolean-result" />
+	  </xsl:when>
+
+	  <xsl:when test="res:results">
+	    <xsl:call-template name="vb-result" />
+	  </xsl:when>
+
+	</xsl:choose>
+
+
+      </body>
+    </html>
+  </xsl:template>
+</xsl:stylesheet>

http://git-wip-us.apache.org/repos/asf/jena/blob/b78f5182/jena-fuseki2/jena-fuseki-main/sparqler/run-sparqler
----------------------------------------------------------------------
diff --git a/jena-fuseki2/jena-fuseki-main/sparqler/run-sparqler b/jena-fuseki2/jena-fuseki-main/sparqler/run-sparqler
new file mode 100755
index 0000000..0d69faf
--- /dev/null
+++ b/jena-fuseki2/jena-fuseki-main/sparqler/run-sparqler
@@ -0,0 +1,63 @@
+#!/bin/bash
+## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0
+
+## Configuration
+SPARQLER_PAGES="${SPARQLER_PAGES:-pages/}"
+SPARQLER_DATA="${SPARQLER_DATA:-file:data/books.ttl}"
+SPARQLER_DS="${SPARQLER_DS:-/books}"
+
+## Development
+FUSEKI_JAR1="$(echo jena-fuseki-basic-*-server.jar)"
+## Deployment
+FUSEKI_JAR2="fuseki-basic.jar"
+FUSEKI_JAR3=""
+
+# Choose which jar to run
+[[ -e $FUSEKI_JAR3 ]] && FUSEKI_JAR=$FUSEKI_JAR3
+[[ -e $FUSEKI_JAR2 ]] && FUSEKI_JAR=$FUSEKI_JAR2
+[[ -e $FUSEKI_JAR1 ]] && FUSEKI_JAR=$FUSEKI_JAR1
+
+if [ ! -e "$FUSEKI_JAR" ]
+then
+    echo "Can't find the Fuseki jar file: $FUSEKI_JAR" 1>&2
+    exit 1 
+fi
+
+BACKGROUND=${BACKGROUND:-1}
+if [ "$BACKGROUND" = 0 ]
+then
+    LOGCONFIG=${LOGCONFIG:-file:log4j-foreground.properties}
+else
+    LOGCONFIG=${LOGCONFIG:-file:log4j-server.properties}
+fi
+
+export FUSEKI_LOG="-Dlog4j.configuration=${LOGCONFIG}"
+export JVM_ARGS="${JVM_ARGS:--Xmx1200M}"
+
+## SPARQLER_ARGS="--base $SPARQLER_PAGES --file=$SPARQLER_DATA  $SPARQLER_DS"
+## 
+## if [[ $1 == "--help" ]]
+## then
+##     echo "$0"
+##     echo "SPARQLER_PAGES = $SPARQLER_PAGES"
+##     echo "SPARQLER_DATA  = $SPARQLER_DATA"
+##     echo "SPARQLER_DS    = $SPARQLER_DS"
+##     exit 0
+## fi
+
+SPARQLER_ARGS="--sparqler $SPARQLER_PAGES"
+
+set --
+
+if [ "$BACKGROUND" = 0 ]
+then
+    # Run in the foreground
+    exec java $JVM_ARGS $FUSEKI_LOG -jar "$FUSEKI_JAR" $SPARQLER_ARGS
+else
+    # Run in the background
+    # Linux / nohup
+    nohup java $JVM_ARGS $FUSEKI_LOG -jar "$FUSEKI_JAR" $SPARQLER_ARGS > nohup.log 2>&1 &
+    # Process ID ... of the script.
+    PROC=$!
+    echo "Server process = $PROC"
+fi


[5/8] jena git commit: wwwenc: read from stdin if called with no args

Posted by an...@apache.org.
wwwenc: read from stdin if called with no args


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

Branch: refs/heads/master
Commit: 85be62dded8875d73b522d1008106fd82a1f1ce1
Parents: 6e81f9f
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Oct 26 14:47:23 2018 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Sat Oct 27 16:36:39 2018 +0100

----------------------------------------------------------------------
 jena-cmds/src/main/java/arq/wwwenc.java | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/85be62dd/jena-cmds/src/main/java/arq/wwwenc.java
----------------------------------------------------------------------
diff --git a/jena-cmds/src/main/java/arq/wwwenc.java b/jena-cmds/src/main/java/arq/wwwenc.java
index 4ee19af..089f412 100644
--- a/jena-cmds/src/main/java/arq/wwwenc.java
+++ b/jena-cmds/src/main/java/arq/wwwenc.java
@@ -18,6 +18,9 @@
 
 package arq;
 
+import java.io.IOException;
+
+import org.apache.jena.atlas.io.IO;
 import org.apache.jena.atlas.lib.StrUtils ;
 
 public class wwwenc
@@ -36,7 +39,7 @@ public class wwwenc
      *   
      *   
      */
-    public static void main(String...args)
+    public static void main(String...args) throws IOException
     {
         // Reserved characters + space
         char reserved[] = 
@@ -47,8 +50,13 @@ public class wwwenc
         
         char[] other = {'<', '>', '~', '.', '{', '}', '|', '\\', '-', '`', '_', '^'} ;        
         
-        for ( String x : args)
-        {
+        if ( args.length == 0 ) {
+            String x = IO.readWholeFileAsUTF8(System.in);
+            String y = StrUtils.encodeHex(x, '%', reserved) ;
+            System.out.println(y) ;
+            return;
+        }       
+        for ( String x : args) {
             // Not URLEncoder which does www-form-encoding.
             String y = StrUtils.encodeHex(x, '%', reserved) ;
             System.out.println(y) ;