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 2011/09/04 17:27:32 UTC

svn commit: r1165047 - in /incubator/jena/Jena2: ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/ Fuseki/trunk/ Fuseki/trunk/pages-update/ Fuseki/trunk/src-dev/dev/ Fuseki/trunk/src/main/java/org/openjena/fuseki/ Fuseki/trunk/src/main/java/org/open...

Author: andy
Date: Sun Sep  4 15:27:32 2011
New Revision: 1165047

URL: http://svn.apache.org/viewvc?rev=1165047&view=rev
Log: (empty)

Added:
    incubator/jena/Jena2/Fuseki/trunk/pages-update/books.ttl   (with props)
    incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html   (with props)
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java   (with props)
Modified:
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/AssemblerUtils.java
    incubator/jena/Jena2/Fuseki/trunk/config.ttl
    incubator/jena/Jena2/Fuseki/trunk/pages-update/fuseki.html
    incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java
    incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/RunFuseki.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Fuseki.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiConfig.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiVocab.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_Query.java
    incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_QueryGeneral.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/AssemblerUtils.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/AssemblerUtils.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/AssemblerUtils.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/core/assembler/AssemblerUtils.java Sun Sep  4 15:27:32 2011
@@ -107,7 +107,10 @@ public class AssemblerUtils
             String value = soln.getLiteral("value").getLexicalForm() ;  // Works for numbers as well!
             name = MappingRegistry.mapPrefixName(name) ;
             Symbol symbol = Symbol.create(name) ;
-            context.set(symbol, value) ;
+            if ( "undef".equalsIgnoreCase(value) )
+                context.remove(symbol) ;
+            else
+                context.set(symbol, value) ;
         }
     }
 }

Modified: incubator/jena/Jena2/Fuseki/trunk/config.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/config.ttl?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
Binary files - no diff available.

Added: incubator/jena/Jena2/Fuseki/trunk/pages-update/books.ttl
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/pages-update/books.ttl?rev=1165047&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/jena/Jena2/Fuseki/trunk/pages-update/books.ttl
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: incubator/jena/Jena2/Fuseki/trunk/pages-update/fuseki.html
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/pages-update/fuseki.html?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/pages-update/fuseki.html (original)
+++ incubator/jena/Jena2/Fuseki/trunk/pages-update/fuseki.html Sun Sep  4 15:27:32 2011
@@ -21,6 +21,11 @@
       <li><a href="iri-validator.html">IRI validator</a></li>
     </ul>
 
+    <h2>General SPARQL Service</h2>
+    <ul>
+      <li><a href="sparql.html">SPARQL query form</a></li>
+    </ul>
+
     <h2>Standards</h2>
     <ul>
       <li> <a href="http://www.w3.org/TR/sparql11-query/">SPARQL 1.1 Query</a></li>

Added: incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html?rev=1165047&view=auto
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html (added)
+++ incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html Sun Sep  4 15:27:32 2011
@@ -0,0 +1,40 @@
+<?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">
+
+<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/>
+	  Output XML: <input type="radio" name="output" value="xml" checked/>
+	  with XSLT style sheet (leave blank for none): 
+	  <input name="stylesheet" size="25" value="/xml-to-html.xsl" /> <br/>
+	  or JSON output: <input type="radio" name="output" value="json"/> <br/>
+	  or text output: <input type="radio" name="output" value="text"/> <br/>
+	  or CSV output: <input type="radio" name="output" value="csv"/> <br/>
+	  or TSV output: <input type="radio" name="output" value="tsv"/> <br/>
+          Force the accept header to <tt>text/plain</tt> regardless 
+ 	  <input type="checkbox" name="force-accept" value="text/plain"/>	  <br/>
+	  <input type="submit" value="Get Results" />
+	</p>
+      </form>
+    </div>
+
+    <hr/>
+
+  </body>
+</html>

Propchange: incubator/jena/Jena2/Fuseki/trunk/pages-update/sparql.html
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/DevFuseki.java Sun Sep  4 15:27:32 2011
@@ -20,10 +20,14 @@ package dev;
 
 public class DevFuseki
 {
+    // Configuration:
+    // 1 - Custom code - server init by reflection.
+    // 2 - 
+    
     // application/json for application/sparql-results+json. 
     // application/xml for application/sparql-results+xml. 
     
-    // LimitingGraph, LimitingBulkUpdateHandler --> chnage to use a limiting Sink<>
+    // LimitingGraph, LimitingBulkUpdateHandler --> change to use a limiting Sink<>
     // Finish: SPARQL_QueryGeneral
     //    Parse errors and etc need to be passed out.
     // --jetty-config documentation

Modified: incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/RunFuseki.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/RunFuseki.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/RunFuseki.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src-dev/dev/RunFuseki.java Sun Sep  4 15:27:32 2011
@@ -24,8 +24,8 @@ public class RunFuseki
 {
     public static void main(String[] args) throws Exception
     {
-        //main1() ;
-        main2() ;
+        main1() ;
+        //main2() ;
     }
     
         

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Fuseki.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Fuseki.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Fuseki.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Fuseki.java Sun Sep  4 15:27:32 2011
@@ -27,13 +27,16 @@ import com.hp.hpl.jena.sparql.SystemARQ 
 import com.hp.hpl.jena.sparql.lib.Metadata ;
 import com.hp.hpl.jena.sparql.mgt.ARQMgt ;
 import com.hp.hpl.jena.sparql.mgt.SystemInfo ;
+import com.hp.hpl.jena.sparql.util.Context ;
+import com.hp.hpl.jena.sparql.util.MappingRegistry ;
 import com.hp.hpl.jena.util.FileManager ;
 
 public class Fuseki
 {
     // External log : operations, etc.
     static public String PATH = "org.openjena.fuseki" ;
-    static public String FusekiIRI = "http://openjena.org/Fuseki" ;
+    static public String FusekiIRI = "http://jena.apache.org/Fuseki" ;
+    static public String FusekiSymbolIRI = "http://jena.apache.org/fuseki#" ;
     
     static public String PagesPublish = "pages-publish" ;
     static public String PagesAll =     "pages-update" ;
@@ -81,8 +84,14 @@ public class Fuseki
         ARQMgt.register(PATH+".system:type=SystemInfo", sysInfo) ;
         SystemARQ.registerSubSystem(sysInfo) ;
         RIOT.init() ;
+        MappingRegistry.addPrefixMapping("fuseki", FusekiSymbolIRI) ;
     }
   
+    public static Context getContext()
+    {
+        return ARQ.getContext() ;
+    }
+
     // Force a call to init.
     static { init() ; }
 }

Added: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java?rev=1165047&view=auto
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java (added)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java Sun Sep  4 15:27:32 2011
@@ -0,0 +1,25 @@
+/**
+ * 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.openjena.fuseki;
+
+public class Test
+{
+    public static void init() { System.out.println("INIT called") ; }
+}
+

Propchange: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/Test.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiConfig.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiConfig.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiConfig.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiConfig.java Sun Sep  4 15:27:32 2011
@@ -18,9 +18,11 @@
 
 package org.openjena.fuseki.server;
 
+import java.lang.reflect.Method ;
 import java.util.ArrayList ;
 import java.util.List ;
 
+import org.openjena.atlas.iterator.Iter ;
 import org.openjena.atlas.lib.StrUtils ;
 import org.openjena.atlas.logging.Log ;
 import org.openjena.fuseki.Fuseki ;
@@ -29,6 +31,8 @@ import org.openjena.fuseki.HttpNames ;
 import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.assembler.Assembler ;
+import com.hp.hpl.jena.assembler.JA ;
+import com.hp.hpl.jena.query.ARQ ;
 import com.hp.hpl.jena.query.Dataset ;
 import com.hp.hpl.jena.query.Query ;
 import com.hp.hpl.jena.query.QueryExecution ;
@@ -41,30 +45,35 @@ import com.hp.hpl.jena.query.ResultSetFa
 import com.hp.hpl.jena.rdf.model.Literal ;
 import com.hp.hpl.jena.rdf.model.Model ;
 import com.hp.hpl.jena.rdf.model.RDFNode ;
+import com.hp.hpl.jena.rdf.model.ResIterator ;
 import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.rdf.model.Statement ;
+import com.hp.hpl.jena.rdf.model.StmtIterator ;
 import com.hp.hpl.jena.shared.PrefixMapping ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.sparql.core.assembler.AssemblerUtils ;
+import com.hp.hpl.jena.tdb.TDB ;
 import com.hp.hpl.jena.util.FileManager ;
 import com.hp.hpl.jena.vocabulary.RDF ;
 import com.hp.hpl.jena.vocabulary.RDFS ;
 
 public class FusekiConfig
 {
-    // TODO
-    // 2: Testing.
-    // 3: Tidy code, put in right place; remove unused copied Joseki code.
-    
-    
     static { Log.setLog4j() ; }
 
     private static Logger log = Fuseki.configLog ;
     
-    public static void main(String...argv)
-    {
-        List<ServiceDesc> services = FusekiConfig.configure("config.ttl") ;
-        SPARQLServer server = new SPARQLServer(null, 3030, services) ;
-        server.start() ;
-    }
+    private static String prefixes = StrUtils.strjoinNL(
+    "PREFIX fu:     <http://jena.apache.org/fuseki#>" ,
+    "PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
+    "PREFIX rdfs:   <http://www.w3.org/2000/01/rdf-schema#>",
+    "PREFIX tdb:    <http://jena.hpl.hp.com/2008/tdb#>",
+    "PREFIX list:   <http://jena.hpl.hp.com/ARQ/list#>",
+    "PREFIX list:   <http://jena.hpl.hp.com/ARQ/list#>",
+    "PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>",
+    "PREFIX apf:     <http://jena.hpl.hp.com/ARQ/property#>", 
+    "PREFIX afn:     <http://jena.hpl.hp.com/ARQ/function#>" ,
+    "") ;
     
     public static ServiceDesc defaultConfiguration(String datasetPath, DatasetGraph dsg, boolean allowUpdate)
     {
@@ -82,18 +91,30 @@ public class FusekiConfig
         }
         else
             sDesc.readGraphStoreEP.add(HttpNames.ServiceData) ;
-        
         return sDesc ;
     }
     
     public static List<ServiceDesc> configure(String filename)
     {
-        // Basic checks
-        // Stage one : parse file and set temporay datastructures
-        // Stateg two : configure server, knowing the data is all valid.
-        
+        // Be absolutely sure everything has initaialized.
+        // Some initialization registers assemblers and sets abbreviation vocabulary. 
+        ARQ.init();
+        TDB.init() ;
+        Fuseki.init() ;
         Model m = FileManager.get().loadModel(filename) ;
-        
+
+        // Find one server.
+        List<Resource> servers = getByType(FusekiVocab.tServer, m) ;
+        if ( servers.size() == 0 )
+            throw new FusekiConfigException("No server found (no resource with type "+strForResource(FusekiVocab.tServer)) ;
+        if ( servers.size() > 1 )
+            throw new FusekiConfigException(servers.size()+" servers found (must be exactly one in a configuration file)") ;
+        
+        // ---- Server 
+        Resource server = servers.get(0) ;
+        processServer(server) ;
+
+        // ---- Services
         ResultSet rs = query("SELECT * { ?s fu:services [ list:member ?member ] }", m) ; 
         if ( ! rs.hasNext() )
             log.warn("No services found") ;
@@ -111,6 +132,54 @@ public class FusekiConfig
         return services ;
     }
 
+    private static void processServer(Resource server)
+    {
+        // Global, currently.
+        AssemblerUtils.setContext(server, Fuseki.getContext()) ;
+        
+        StmtIterator sIter = server.listProperties(JA.loadClass) ;
+        for( ; sIter.hasNext(); )
+        {
+            Statement s = sIter.nextStatement() ;
+            RDFNode rn = s.getObject() ;
+            String className = null ;
+            if ( rn instanceof Resource )
+            {
+                String uri = ((Resource)rn).getURI() ;
+                if ( uri == null )
+                {
+                    log.warn("Blank node for class to load") ;
+                    continue ;
+                }
+                String javaScheme = "java:" ;
+                if ( ! uri.startsWith(javaScheme) )
+                {
+                    log.warn("Class to load is not 'java:': "+uri) ;
+                    continue ;
+                }
+                className = uri.substring(javaScheme.length()) ;
+            }
+            if ( rn instanceof Literal )
+                className = ((Literal)rn).getLexicalForm() ; 
+            /*Loader.*/loadAndInit(className) ;
+        }
+        // ----
+    }
+
+    private static void loadAndInit(String className)
+    {
+        try {
+            Class<?> classObj = Class.forName(className);
+            log.info("Loaded "+className) ;
+            Method initMethod = classObj.getMethod("init");
+            initMethod.invoke(null);
+        } catch (ClassNotFoundException ex)
+        {
+            log.warn("Class not found: "+className);
+        } 
+        catch (Exception e)         { throw new FusekiConfigException(e) ; }
+    }
+
     private static ServiceDesc processService(Resource svc)
     {
         ServiceDesc sDesc = new ServiceDesc() ;
@@ -149,6 +218,12 @@ public class FusekiConfig
         return x ;
     }
     
+    private static List<Resource> getByType(Resource type, Model m)
+    {
+        ResIterator rIter = m.listSubjectsWithProperty(RDF.type, type) ;
+        return Iter.toList(rIter) ;
+    }
+
     private static void addServiceEP(String label, String name, List<String> output, Resource svc, String property)
     {
         ResultSet rs = query("SELECT * { ?svc "+property+" ?ep}", svc.getModel(), "svc", svc) ;
@@ -161,28 +236,7 @@ public class FusekiConfig
         }
     }
 
-    // Dataset
-    String[] s = new String[] {
-        "SELECT ?x ?dft ?graphName ?graphData",
-        "{ { ?x a ja:RDFDataset } UNION { ?x a [ rdfs:subClassOf ja:RDFDataset ] }",  
-        "  OPTIONAL { ?x ja:defaultGraph ?dft }",
-        "  OPTIONAL { ?x ja:namedGraph  [ ja:graphName ?graphName ; ja:graph ?graphData ] }",  
-        "}", 
-        "ORDER BY ?x ?dft ?graphName"
-    } ;
 
-    private static String prefixes = StrUtils.strjoinNL(
-        "PREFIX fu:     <http://jena.apache.org/fuseki#>" ,
-        "PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>",
-        "PREFIX rdfs:   <http://www.w3.org/2000/01/rdf-schema#>",
-        "PREFIX tdb:    <http://jena.hpl.hp.com/2008/tdb#>",
-        "PREFIX list:   <http://jena.hpl.hp.com/ARQ/list#>",
-        "PREFIX list:   <http://jena.hpl.hp.com/ARQ/list#>",
-        "PREFIX xsd:     <http://www.w3.org/2001/XMLSchema#>",
-        "PREFIX apf:     <http://jena.hpl.hp.com/ARQ/property#>", 
-        "PREFIX afn:     <http://jena.hpl.hp.com/ARQ/function#>" ,
-        "") ;
-    
     private static ResultSet query(String string, Model m)
     {
         return query(string, m, null, null) ;

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiVocab.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiVocab.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiVocab.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/server/FusekiVocab.java Sun Sep  4 15:27:32 2011
@@ -21,17 +21,30 @@ package org.openjena.fuseki.server;
 import org.openjena.fuseki.FusekiException ;
 import org.openjena.riot.system.IRIResolver ;
 
-import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.iri.IRI ;
+import com.hp.hpl.jena.rdf.model.Property ;
+import com.hp.hpl.jena.rdf.model.Resource ;
+import com.hp.hpl.jena.rdf.model.ResourceFactory ;
 
 public class FusekiVocab
 {
     public static String NS = "http://jena.apache.org/fuseki#" ;
+
+    public static final Resource tServer = resource("Server") ;
+
+    public static final Property pServices = property("services") ;
+    public static final Property pServiceName = property("name") ;
     
-    public static final Node pServiceName = property("serviceName") ; 
-    
-    
-    private static Node property(String localname)
+    public static final Property pServiceQueryEP = property("serviceQuery") ;
+    public static final Property pServiceUpdateEP = property("serviceUpdate") ;
+    public static final Property pServiceUploadEP = property("serviceUpload") ;
+    public static final Property pServiceReadWriteGraphStoreEP = property("serviceReadWriteGraphStore") ;
+    public static final Property pServiceReadgraphStoreEP = property("serviceReadGraphStore") ;
+
+    private static Resource resource(String localname) { return ResourceFactory.createResource(iri(localname)) ; }
+    private static Property property(String localname) { return ResourceFactory.createProperty(iri(localname)) ; }
+        
+    private static String iri(String localname)
     {
         String uri = NS+localname ;
         IRI iri = IRIResolver.parseIRI(uri) ;
@@ -40,7 +53,7 @@ public class FusekiVocab
         if ( ! iri.isAbsolute() )
             throw new FusekiException("Bad IRI: "+iri) ;
         
-        return Node.createURI(uri) ;
+        return uri ;
     }
 }
 

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_Query.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_Query.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_Query.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_Query.java Sun Sep  4 15:27:32 2011
@@ -192,7 +192,7 @@ public abstract class SPARQL_Query exten
     private void execute(String queryString, HttpActionQuery action)
     {
         String queryStringLog = formatForLog(queryString) ;
-        log.info(format("[%d] Query = %s", action.id, queryString));
+        log.info(format("[%d] Query = %s", action.id, queryStringLog));
         
         Query query = null ;
         try {

Modified: incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_QueryGeneral.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_QueryGeneral.java?rev=1165047&r1=1165046&r2=1165047&view=diff
==============================================================================
--- incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_QueryGeneral.java (original)
+++ incubator/jena/Jena2/Fuseki/trunk/src/main/java/org/openjena/fuseki/servlets/SPARQL_QueryGeneral.java Sun Sep  4 15:27:32 2011
@@ -18,7 +18,7 @@
 
 package org.openjena.fuseki.servlets;
 
-import static org.openjena.fuseki.Fuseki.webFileManager ;
+import static java.lang.String.format ;
 import static org.openjena.fuseki.HttpNames.paramAccept ;
 import static org.openjena.fuseki.HttpNames.paramCallback ;
 import static org.openjena.fuseki.HttpNames.paramDefaultGraphURI ;
@@ -39,8 +39,11 @@ import java.util.Set ;
 import javax.servlet.http.HttpServletRequest ;
 import javax.servlet.http.HttpServletResponse ;
 
+import org.openjena.atlas.iterator.Filter ;
 import org.openjena.atlas.iterator.Iter ;
+import org.openjena.atlas.lib.InternalErrorException ;
 import org.openjena.fuseki.migrate.GraphLoadUtils ;
+import org.openjena.riot.RiotException ;
 
 import com.hp.hpl.jena.query.DataSource ;
 import com.hp.hpl.jena.query.Dataset ;
@@ -80,10 +83,7 @@ public class SPARQL_QueryGeneral extends
 
     @Override
     protected void validateQuery(HttpActionQuery action, Query query)
-    {
-        if ( query.hasDatasetDescription() )
-            errorBadRequest("Query may not include a dataset description (FROM/FROM NAMED)") ;
-    }
+    { }
     
     @Override
     protected String mapRequestToDataset(String uri)
@@ -92,9 +92,9 @@ public class SPARQL_QueryGeneral extends
     @Override
     protected Dataset decideDataset(HttpActionQuery action, Query query, String queryStringLog) 
     {
-        Dataset ds = datasetFromProtocol(action.request) ;
+        Dataset ds = datasetFromProtocol(action) ;
         if ( ds == null )
-            ds = datasetFromQuery(query) ;
+            ds = datasetFromQuery(action, query) ;
         if ( ds == null )
             errorBadRequest("No dataset description in protocol request or in the query string") ;
         return ds ;
@@ -119,21 +119,21 @@ public class SPARQL_QueryGeneral extends
         return false ;
     }
     
-    protected Dataset datasetFromProtocol(HttpServletRequest request)
+    protected Dataset datasetFromProtocol(HttpActionQuery action)
     {
-        List<String> graphURLs = toStrList(request.getParameterValues(paramDefaultGraphURI)) ;
-        List<String> namedGraphs = toStrList(request.getParameterValues(paramNamedGraphURI)) ;
-        return datasetFromDescription(graphURLs, namedGraphs) ;
+        List<String> graphURLs = toStrList(action.request.getParameterValues(paramDefaultGraphURI)) ;
+        List<String> namedGraphs = toStrList(action.request.getParameterValues(paramNamedGraphURI)) ;
+        return datasetFromDescription(action, graphURLs, namedGraphs) ;
     }
     
-    protected Dataset datasetFromQuery(Query query)
+    protected Dataset datasetFromQuery(HttpActionQuery action, Query query)
     {
         List<String> graphURLs = query.getGraphURIs() ;
         List<String> namedGraphs = query.getNamedGraphURIs() ;
-        return datasetFromDescription(graphURLs, namedGraphs) ;
+        return datasetFromDescription(action, graphURLs, namedGraphs) ;
     }
     
-    protected Dataset datasetFromDescription(List<String> graphURLs, List<String> namedGraphs)
+    protected Dataset datasetFromDescription(HttpActionQuery action, List<String> graphURLs, List<String> namedGraphs)
     {
         try {
             graphURLs = removeEmptyValues(graphURLs) ;
@@ -150,27 +150,19 @@ public class SPARQL_QueryGeneral extends
                 Model model = ModelFactory.createDefaultModel() ;
                 for ( String uri : graphURLs )
                 {
-                    if ( uri == null )
-                    {
-                        // TODO LOG
-                        log.warn("Null "+paramDefaultGraphURI+ " (ignored)") ;
-                        continue ;
-                    }
-                    if ( uri.equals("") )
-                    {
-                        // TODO LOG
-                        log.warn("Empty "+paramDefaultGraphURI+ " (ignored)") ;
-                        continue ;
-                    }
+                    if ( uri == null || uri.equals("") )
+                        throw new InternalErrorException("Default graph URI is null or the empty string")  ;
 
                     try {
                         //TODO Clearup - RIOT integration.
                         GraphLoadUtils.loadModel(model, uri, MaxTriples) ;
-                        log.info("Load (default) "+uri) ;
+                        log.info(format("[%d] Load (default graph) %s", action.id, uri)) ;
+                    } catch (RiotException ex) {
+                        log.info(format("[%d] Parsing error loading %s: %s", action.id, uri, ex.getMessage())) ;
+                        errorBadRequest("Failed to load URL (parse error) "+uri+" : "+ex.getMessage()) ;
                     } catch (Exception ex)
                     {
-                        // TODO LOG
-                        log.info("Failed to load (default) "+uri+" : "+ex.getMessage()) ;
+                        log.info(format("[%d] Failed to load (default) %s: %s", action.id, uri, ex.getMessage())) ;
                         errorBadRequest("Failed to load URL "+uri) ;
                     }
                 }
@@ -181,25 +173,21 @@ public class SPARQL_QueryGeneral extends
             {
                 for ( String uri : namedGraphs )
                 {
-                    if ( uri == null )
-                    {
-                        log.warn("Null "+paramNamedGraphURI+ " (ignored)") ;
-                        continue ;
-                    }
-                    if ( uri.equals("") )
-                    {
-                        log.warn("Empty "+paramNamedGraphURI+ " (ignored)") ;
-                        continue ;
-                    }
+                    if ( uri == null || uri.equals("") )
+                        throw new InternalErrorException("Named graph URI is null or the empty string")  ;
+
                     try {
-                        Model model2 = webFileManager.loadModel(uri) ;
-                        log.info("Load (named) "+uri) ;
-                        dataset.addNamedModel(uri, model2) ;
+                        Model model = ModelFactory.createDefaultModel() ;
+                        GraphLoadUtils.loadModel(model, uri, MaxTriples) ;
+                        log.info(format("[%d] Load (named graph) %s", action.id, uri)) ;
+                        dataset.addNamedModel(uri, model) ;
+                    } catch (RiotException ex) {
+                        log.info(format("[%d] Parsing error loading %s: %s", action.id, uri, ex.getMessage())) ;
+                        errorBadRequest("Failed to load URL (parse error) "+uri+" : "+ex.getMessage()) ;
                     } catch (Exception ex)
                     {
-                        // TODO LOG
-                        log.info("Failed to load (named) "+uri+" : "+ex.getMessage()) ;
-                        errorBadRequest("Failed to load (named) "+uri+" : "+ex.getMessage()) ;
+                        log.info(format("[%d] Failed to load (named graph) %s: %s", action.id, uri, ex.getMessage())) ;
+                        errorBadRequest("Failed to load URL "+uri) ;
                     }
                 }
             }
@@ -207,11 +195,11 @@ public class SPARQL_QueryGeneral extends
             return dataset ;
             
         } 
+        catch (ActionErrorException ex) { throw ex ; }
         catch (Exception ex)
         {
-            // TODO LOG
-            log.info("SPARQL parameter error",ex) ;
-            errorBadRequest("Parameter error");
+            log.info(format("[%d] SPARQL parameter error: "+ex.getMessage(),action.id, ex)) ;
+            errorBadRequest("Parameter error: "+ex.getMessage());
             return null ;
         }
         
@@ -224,9 +212,16 @@ public class SPARQL_QueryGeneral extends
         return Arrays.asList(array) ;
     }
 
-    private  <T>  List<T> removeEmptyValues(List<T> list)
+    private  List<String> removeEmptyValues(List<String> list)
     {
-        return Iter.iter(list).removeNulls().toList() ;
+        return Iter.iter(list).filter(acceptNonEmpty).toList() ;
     }
     
+    private static Filter<String> acceptNonEmpty = new Filter<String>(){ 
+        @Override
+        public boolean accept(String item)
+        {
+            return item != null && item.length() != 0 ;
+        }
+    } ;
 }