jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1547840 - in /jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki: ./ mgt/ migrate/ server/ servlets/
Date Wed, 04 Dec 2013 16:46:03 GMT
Author: andy
Date: Wed Dec  4 16:46:02 2013
New Revision: 1547840

URL: http://svn.apache.org/r1547840
Log:
Persistent server state.

Added:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
      - copied, changed from r1547170, jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/SinkRDFLimited.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SystemState.java
Removed:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/SinkRDFLimited.java
Modified:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetRef.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetStatus.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiConfig.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiVocab.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/DEF.java Wed Dec
 4 16:46:02 2013
@@ -25,20 +25,21 @@ import org.apache.jena.riot.WebContent ;
 public class DEF
 {
     public static final MediaType acceptRDFXML        = MediaType.create(WebContent.contentTypeRDFXML)
;
-    public static final MediaType acceptTurtle1       = MediaType.create(WebContent.contentTypeTurtle)
;
-    public static final MediaType acceptTurtle2       = MediaType.create(WebContent.contentTypeTurtleAlt1)
;
-    public static final MediaType acceptTurtle3       = MediaType.create(WebContent.contentTypeTurtleAlt2)
;
-    public static final MediaType acceptNTriples      = MediaType.create(WebContent.contentTypeNTriples)
;
-    public static final MediaType acceptNTriplesAlt   = MediaType.create(WebContent.contentTypeNTriplesAlt)
;
-    public static final MediaType acceptTriG          = MediaType.create(WebContent.contentTypeTriG)
;
-    public static final MediaType acceptTriGAlt1      = MediaType.create(WebContent.contentTypeTriGAlt1)
;
-    public static final MediaType acceptTriGAlt2      = MediaType.create(WebContent.contentTypeTriGAlt2)
;
-    public static final MediaType acceptRDFJSON       = MediaType.create(WebContent.contentTypeRDFJSON)
; 
     public static final MediaType acceptNQuads        = MediaType.create(WebContent.contentTypeNQuads)
;
-    public static final MediaType acceptNQuadsAlt1    = MediaType.create(WebContent.contentTypeNQuadsAlt1)
;
-    public static final MediaType acceptNQuadsAlt2    = MediaType.create(WebContent.contentTypeNQuadsAlt2)
;
-   
     public static final MediaType acceptRSXML         = MediaType.create(WebContent.contentTypeResultsXML)
;
+    
+    private static final MediaType acceptTurtle1       = MediaType.create(WebContent.contentTypeTurtle)
;
+    private static final MediaType acceptTurtle2       = MediaType.create(WebContent.contentTypeTurtleAlt1)
;
+    private static final MediaType acceptTurtle3       = MediaType.create(WebContent.contentTypeTurtleAlt2)
;
+    private static final MediaType acceptNTriples      = MediaType.create(WebContent.contentTypeNTriples)
;
+    private static final MediaType acceptNTriplesAlt   = MediaType.create(WebContent.contentTypeNTriplesAlt)
;
+    private static final MediaType acceptTriG          = MediaType.create(WebContent.contentTypeTriG)
;
+    private static final MediaType acceptTriGAlt1      = MediaType.create(WebContent.contentTypeTriGAlt1)
;
+    private static final MediaType acceptTriGAlt2      = MediaType.create(WebContent.contentTypeTriGAlt2)
;
+    private static final MediaType acceptRDFJSON       = MediaType.create(WebContent.contentTypeRDFJSON)
; 
+    private static final MediaType acceptNQuadsAlt1    = MediaType.create(WebContent.contentTypeNQuadsAlt1)
;
+    private static final MediaType acceptNQuadsAlt2    = MediaType.create(WebContent.contentTypeNQuadsAlt2)
;
+   
 
     public static final AcceptList rdfOffer           = AcceptList.create(acceptTurtle1,
acceptTurtle2, acceptTurtle3, 
                                                                           acceptNTriples,
acceptNTriplesAlt,

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionCtl.java
Wed Dec  4 16:46:02 2013
@@ -19,9 +19,9 @@
 package org.apache.jena.fuseki.mgt;
 
 import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.server.* ;
+import org.apache.jena.fuseki.server.DatasetRef ;
+import org.apache.jena.fuseki.server.DatasetRegistry ;
 import org.apache.jena.fuseki.servlets.ActionBase ;
-import org.apache.jena.fuseki.servlets.ActionLib ;
 import org.apache.jena.fuseki.servlets.HttpAction ;
 
 /** Control/admin request lifecycle */
@@ -34,26 +34,41 @@ public abstract class ActionCtl extends 
     protected void execCommonWorker(HttpAction action)
     {
         DatasetRef dsRef = null ;
-
-        String datasetUri = mapRequestToDataset(action) ;
-        
-        if ( datasetUri != null ) {
-            dsRef = DatasetRegistry.get().get(datasetUri) ;
-            if ( dsRef == null ) {
-                errorNotFound("No dataset for URI: "+datasetUri) ;
-                return ;
-            }
-        } else
-            dsRef = FusekiConfig.serviceOnlyDatasetRef() ;
-
+        String name = mapRequestToDatasetName(action) ;
+        if ( name != null )
+            dsRef = DatasetRegistry.get().get(name) ;
+        else {
+            // This is a placeholder when creating new DatasetRefs
+            // and also if addressig a container, not a dataset
+            dsRef = new DatasetRef() ;
+            dsRef.name = name ;
+        }
         action.setDataset(dsRef) ;
-        String uri = action.request.getRequestURI() ;
-        String serviceName = ActionLib.mapRequestToService(dsRef, uri, datasetUri) ;
-        ServiceRef srvRef = dsRef.getServiceRef(serviceName) ;
-        action.setService(srvRef) ;
         executeAction(action) ;
     }
 
+    protected String mapRequestToDatasetName(HttpAction action) {
+//        action.log.info("context path  = "+action.request.getContextPath()) ;
+//        action.log.info("pathinfo      = "+action.request.getPathInfo()) ;
+//        action.log.info("servlet path  = "+action.request.getServletPath()) ;
+        // if /name
+        //    request.getServletPath() otherwise it's null
+        // if /*
+        //    request.getPathInfo() ; otherwise it's null.
+        
+        String pathInfo = action.request.getPathInfo() ;
+        if ( pathInfo == null || pathInfo.isEmpty() || pathInfo.equals("/") )
+            // Includes calling as a container. 
+            return null ;
+        String name = pathInfo ;
+        // pathInfo starts with a "/"
+        int idx = pathInfo.lastIndexOf('/') ;
+        if ( idx > 0 )
+            name = name.substring(idx) ;
+        // Returns "/name"
+        return name ; 
+    }
+
     // Execute - no stats.
     // Intercept point for the UberServlet 
     protected void executeAction(HttpAction action) {
@@ -71,29 +86,11 @@ public abstract class ActionCtl extends 
     
     protected abstract void perform(HttpAction action) ;
 
-    /** Map request to uri in the registry.
-     *  null means no mapping done (passthrough). 
-     */
-    protected String mapRequestToDataset(HttpAction action) 
-    {
-        return ActionLib.mapRequestToDataset(action.request.getRequestURI()) ;
-    }
-    
-    protected static void incCounter(Counters counters, CounterName name) {
-        try {
-            if ( counters.getCounters().contains(name) )
-                counters.getCounters().inc(name) ;
-        } catch (Exception ex) {
-            Fuseki.serverLog.warn("Exception on counter inc", ex) ;
-        }
-    }
-    
-    protected static void decCounter(Counters counters, CounterName name) {
-        try {
-            if ( counters.getCounters().contains(name) )
-                counters.getCounters().dec(name) ;
-        } catch (Exception ex) {
-            Fuseki.serverLog.warn("Exception on counter dec", ex) ;
-        }
-    }
+//    /** Map request to uri in the registry.
+//     *  null means no mapping done (passthrough). 
+//     */
+//    protected String mapRequestToDataset(HttpAction action) 
+//    {
+//        return ActionLib.mapRequestToDataset(action.request.getRequestURI()) ;
+//    }
 }

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionDatasets.java
Wed Dec  4 16:46:02 2013
@@ -18,9 +18,11 @@
 
 package org.apache.jena.fuseki.mgt;
 
+import static java.lang.String.format ;
+
 import java.io.* ;
 import java.nio.channels.FileChannel ;
-import java.util.List ;
+import java.util.Iterator ;
 import java.util.Locale ;
 
 import javax.servlet.ServletException ;
@@ -32,14 +34,15 @@ import org.apache.jena.atlas.io.IO ;
 import org.apache.jena.atlas.json.JSON ;
 import org.apache.jena.atlas.json.JsonBuilder ;
 import org.apache.jena.atlas.json.JsonValue ;
+import org.apache.jena.atlas.lib.StrUtils ;
 import org.apache.jena.atlas.web.ContentType ;
 import org.apache.jena.fuseki.FusekiLib ;
-import org.apache.jena.fuseki.server.DatasetRef ;
-import org.apache.jena.fuseki.server.DatasetRegistry ;
-import org.apache.jena.fuseki.server.FusekiConfig ;
-import org.apache.jena.fuseki.server.SPARQLServer ;
+import org.apache.jena.fuseki.server.* ;
 import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.riot.* ;
+import org.apache.jena.riot.Lang ;
+import org.apache.jena.riot.RiotException ;
+import org.apache.jena.riot.RiotReader ;
+import org.apache.jena.riot.WebContent ;
 import org.apache.jena.riot.lang.LangRIOT ;
 import org.apache.jena.riot.system.ErrorHandler ;
 import org.apache.jena.riot.system.ErrorHandlerFactory ;
@@ -47,12 +50,39 @@ import org.apache.jena.riot.system.Strea
 import org.apache.jena.riot.system.StreamRDFLib ;
 import org.apache.jena.web.HttpSC ;
 
-import com.hp.hpl.jena.rdf.model.Model ;
-import com.hp.hpl.jena.rdf.model.ModelFactory ;
-
+import com.hp.hpl.jena.datatypes.xsd.XSDDatatype ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.NodeFactory ;
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.query.ReadWrite ;
+import com.hp.hpl.jena.rdf.model.* ;
+import com.hp.hpl.jena.shared.uuid.JenaUUID ;
+import com.hp.hpl.jena.sparql.core.DatasetGraph ;
+import com.hp.hpl.jena.sparql.core.Quad ;
+import com.hp.hpl.jena.sparql.util.FmtUtils ;
+import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction ;
+import com.hp.hpl.jena.update.UpdateAction ;
+import com.hp.hpl.jena.update.UpdateFactory ;
+import com.hp.hpl.jena.update.UpdateRequest ;
 
 public class ActionDatasets extends ActionCtl {
+    // XXX DatasetRef to include UUID : see execPostDataset
+    // XXX Build registry from system database
+    // XXX Put the system database somewhere on disk.
+    // XXX
+    // DatasetRef ref = processService(s) ;
+    //   Needs to do the state.
+    
+    // DORMANT on restart excludes on counters.  Not initialised.
+    // DORMANT - close or not close?
+    // ACTIVE - initialize.
     
+    private static Dataset system = SystemState.dataset ;
+    private static DatasetGraphTransaction systemDSG = SystemState.dsg ; 
+    
+    static private Property pServiceName = FusekiVocab.pServiceName ;
+    static private Property pStatus = FusekiVocab.pStatus ;
+
     public ActionDatasets() { super() ; }
     
     @Override
@@ -77,59 +107,28 @@ public class ActionDatasets extends Acti
 
     @Override
     protected void perform(HttpAction action) {
-        String name = mapRequestToDataset(action) ;
         String method = action.request.getMethod().toUpperCase(Locale.ROOT) ;
         if ( method.equals("GET") )
-            execGet(name, action) ;
+            execGet(action) ;
         else if ( method.equals("POST") )
-            execPost(name, action) ;
+            execPost(action) ;
         else if ( method.equals("DELETE") )
-            execDelete(name, action) ;
+            execDelete(action) ;
         else
             error(HttpSC.METHOD_NOT_ALLOWED_405) ;
-    }
-
-    // Null means no name given, i.e. names the collection.
-    @Override
-    protected String mapRequestToDataset(HttpAction action) {
-        action.log.info("context path  = "+action.request.getContextPath()) ;
-        action.log.info("pathinfo      = "+action.request.getPathInfo()) ;
-        action.log.info("servlet path  = "+action.request.getServletPath()) ;
-        // if /name
-        //action.request.getServletPath() ;
-        // if /*
-        String pathInfo = action.request.getPathInfo() ;
-        
-        // Or uri after servlet path.
         
-        if ( pathInfo == null || pathInfo.isEmpty() || pathInfo.equals("/") )
-            return null ;
-        String name = pathInfo ;
-        // pathInfo starts with a "/"
-        int idx = pathInfo.lastIndexOf('/') ;
-        if ( idx > 0 )
-            name = name.substring(idx) ;
-        // Returns "/name"
-        return name ; 
+//      system.begin(ReadWrite.READ) ;
+//      try { RDFDataMgr.write(System.out, system, Lang.TRIG); }
+//      finally { system.end() ; }
+
     }
 
-    protected void execGet(String name, HttpAction action) {
-        action.log.info("GET ds="+(name==null?"":name)) ;
-        JsonBuilder builder = new JsonBuilder() ;
-        if ( name == null ) {
-            // All
-            builder.startObject() ;
-            builder.key("datasets") ;
-            JsonDescription.arrayDatasets(builder, DatasetRegistry.get());
-            builder.finishObject() ;
-        } else {
-            String datasetPath = DatasetRef.canocialDatasetPath(name) ;
-            DatasetRef dsDesc = DatasetRegistry.get().get(datasetPath) ;
-            if ( dsDesc == null )
-                errorNotFound("Not found: dataset "+name);
-            JsonDescription.describe(builder, dsDesc) ;
-        }
-        JsonValue v = builder.build() ;
+    protected void execGet(HttpAction action) {
+        JsonValue v ;
+        if (action.dsRef.name == null )
+            v = execGetContainer(action) ;
+        else
+            v = execGetDataset(action) ;
         try {
             HttpServletResponse response = action.response ;
             ServletOutputStream out = response.getOutputStream() ;
@@ -140,84 +139,182 @@ public class ActionDatasets extends Acti
             out.flush() ;
         } catch (IOException ex) { errorOccurred(ex) ; }
         success(action);
-
     }
     
+    // This does not consult the system database for dormant etc.
+    private JsonValue execGetDataset(HttpAction action) { 
+        JsonBuilder builder = new JsonBuilder() ;
+        builder.startObject() ;
+        builder.key("datasets") ;
+        JsonDescription.arrayDatasets(builder, DatasetRegistry.get());
+        builder.finishObject() ;
+        return builder.build() ;
+    }
+
+    private JsonValue execGetContainer(HttpAction action) {
+        action.log.info(format("[%d] GET ds=%s", action.id, action.dsRef.name)) ;
+        JsonBuilder builder = new JsonBuilder() ;
+        String datasetPath = DatasetRef.canocialDatasetPath(action.dsRef.name) ;
+        DatasetRef dsDesc = DatasetRegistry.get().get(datasetPath) ;
+        if ( dsDesc == null )
+            errorNotFound("Not found: dataset "+action.dsRef.name);
+        JsonDescription.describe(builder, dsDesc) ;
+        return builder.build() ;
+    }
     
     // POST container -> register new dataset
-    // POST conatins/name -> change the state of an exiting entry. 
+    // POST contains/name -> change the state of an existing entry.
     
-    protected void execPost(String name, HttpAction action) {
-        if (name == null )
+    protected void execPost(HttpAction action) {
+        if (action.dsRef.name == null )
             execPostContainer(action) ;
         else
-            execPostDataset(name, action) ;
+            execPostDataset(action) ;
     }
     
-    private void execPostDataset(String name, HttpAction action) {
-        String datasetPath = DatasetRef.canocialDatasetPath(name) ;
-        DatasetRef dsDesc = DatasetRegistry.get().get(datasetPath) ;
-        if ( dsDesc == null )
-            errorNotFound("Not found: dataset "+name);
+    // An action on a dataset.
+    // XXX extend to backup etc??
+    private void execPostDataset(HttpAction action) {
+        String name = action.dsRef.name ;
+        if ( name == null )
+            name = "" ;
+        action.log.info(format("[%d] POST dataset %s", action.id, name)) ;
         
+        if ( action.dsRef.dataset == null )
+            errorNotFound("Not found: dataset "+action.dsRef.name);
+        DatasetRef dsDesc = action.dsRef ;
         String s = action.request.getParameter("status") ;
         if ( s == null || s.isEmpty() )
             errorBadRequest("No state change given") ;
-        if ( s.equalsIgnoreCase("active") )
+
+        if ( s.equalsIgnoreCase("active") ) {
+            setDatasetState(name, FusekiVocab.stateActive) ;        
             dsDesc.activate() ;
-        else if ( s.equalsIgnoreCase("dormant") )
+        } else if ( s.equalsIgnoreCase("dormant") ) {
+            setDatasetState(name, FusekiVocab.stateDormant) ;        
             dsDesc.dormant() ;
-        else
+        } else
             errorBadRequest("New state '"+s+"' not recognized");
-        success(action);
+        success(action) ;
     }
 
-    protected void execPostContainer(HttpAction action) {
-        action.log.info("POST container") ;
-        // ??? 
-        // Send to disk, then parse, then decide what to do.
-        // Overwrite?
-        
-        Model m = ModelFactory.createDefaultModel() ;
-        StreamRDF dest = StreamRDFLib.graph(m.getGraph()) ;
-        bodyAsGraph(action, dest) ;
-        List<DatasetRef> refs = FusekiConfig.readConfiguration(m);
-        
-        for (DatasetRef dsDesc : refs) {
-            String datasetPath = dsDesc.name ;
-            if ( DatasetRegistry.get().isRegistered(datasetPath) )
-                // Remove?
-                errorBadRequest("Already registered: " + dsDesc.name) ;
-            SPARQLServer.registerDataset(datasetPath, dsDesc) ;
+    // Persistent state change.
+    private void setDatasetState(String name, Resource newState) {
+        boolean committed = false ;
+        system.begin(ReadWrite.WRITE) ;
+        try {
+            String dbName = name ;
+            if ( dbName.startsWith("/") )
+                dbName = dbName.substring(1) ;
+            
+            String update =  StrUtils.strjoinNL
+                (SystemState.PREFIXES,
+                 "DELETE { GRAPH ?g { ?s fu:status ?state } }",
+                 "INSERT { GRAPH ?g { ?s fu:status "+FmtUtils.stringForRDFNode(newState)+"
} }",
+                 "WHERE {",
+                 "   GRAPH ?g { ?s fu:name '"+dbName+"' ; ",
+                 "                 fu:status ?state .",
+                 "   }",
+                 "}"
+                 ) ;
+            UpdateRequest req =  UpdateFactory.create(update) ;
+            UpdateAction.execute(req, system);
+            system.commit();
+            committed = true ;
+        } finally { 
+            if ( ! committed ) system.abort() ; 
+            system.end() ; 
         }
+    }
+    
+    private void execPostContainer(HttpAction action) {
+        String newURI = JenaUUID.generate().asURI() ;
+        Node gn = NodeFactory.createURI(newURI) ;
+        
+        //action.beginWrite() ;
+        boolean committed = false ;
+        system.begin(ReadWrite.WRITE) ;
         try {
-            String n = IO.uniqueFilename(FusekiConfig.configurationsDirectory, "assem", "ttl")
;
-            OutputStream out = new FileOutputStream(n) ;
-            out = new BufferedOutputStream(out) ;
-            RDFDataMgr.write(out, m, Lang.TURTLE) ;
-            out.close() ;
-        } catch (IOException ex) { IO.exception(ex) ; }
-        success(action);
+            Model model = system.getNamedModel(newURI) ;
+            StreamRDF dest = StreamRDFLib.graph(model.getGraph()) ;
+            bodyAsGraph(action, dest) ;
+            // Find name.
+            
+            StmtIterator sIter = model.listStatements(null, pServiceName, (RDFNode)null )
;
+            if ( ! sIter.hasNext() )
+                errorBadRequest("No name given in description of Fuseki service") ;
+            Statement stmt = sIter.next() ;
+            if ( sIter.hasNext() )
+                errorBadRequest("Multiple names given in description of Fuseki service")
;
+            if ( ! stmt.getObject().isLiteral() )
+                errorBadRequest("Found "+FmtUtils.stringForRDFNode(stmt.getObject())+" :
Service names are strings, then used to build the external URI") ;
+            
+            Resource subject = stmt.getSubject() ;
+            Literal object = stmt.getObject().asLiteral() ;
+            
+            if ( object.getDatatype() != null && ! object.getDatatype().equals(XSDDatatype.XSDstring)
)
+                action.log.warn(format("[%d] Service name '%s' is not a string", action.id,
FmtUtils.stringForRDFNode(object)));
+
+            String datasetName = object.getLexicalForm() ;
+            model.removeAll(null, pStatus, null) ;
+            model.add(subject, pStatus, FusekiVocab.stateActive) ;
+            
+            String datasetPath = DatasetRef.canocialDatasetPath(datasetName) ;
+            DatasetRef dsRef = FusekiConfig.processService(subject) ;
+            SPARQLServer.registerDataset(datasetPath, dsRef) ;
+            system.commit();
+            committed = true ;
+            success(action) ;
+        } finally { 
+            if ( ! committed ) system.abort() ; 
+            system.end() ; 
+        }
     }
-
-    protected void execDelete(String name, HttpAction action) {
-        // Find DS.
-        action.log.info("DELETE "+(name==null?"":name));
-        if ( name == null ) {
+    
+    protected void execDelete(HttpAction action) {
+        // Does not exist?
+        String name = action.dsRef.name ;
+        if ( name == null )
+            name = "" ;
+        action.log.info(format("[%d] DELETE ds=%s", action.id, name)) ;
+        if ( action.dsRef.name == null ) {
             errorBadRequest("DELETE only to the container entries.") ;
             return ;
         }
-        
-        //  Canoncial name
-        if ( ! DatasetRegistry.get().isRegistered(name) )
-            errorBadRequest("Not found: " + name) ;
-        
-        DatasetRef dsRef = DatasetRegistry.get().get(name) ;
-        DatasetRegistry.get().remove(name) ;
-        // No longer routeable
-        dsRef.gracefulShutdown() ;
-        success(action);
+
+        systemDSG.begin(ReadWrite.WRITE) ;
+        boolean committed =false ;
+        try {
+            // Name to graph
+            Quad q = getOne(SystemState.dsg, null, null, pServiceName.asNode(), null) ;
+            if ( q == null )
+                errorBadRequest("Failed to find dataset for '"+name+"'");
+            Node gn = q.getGraph() ;
+            
+            DatasetRef dsRef = DatasetRegistry.get().get(name) ;
+            dsRef.gracefulShutdown() ;
+            DatasetRegistry.get().remove(name) ;
+            // XXX or set to state deleted.
+            systemDSG.deleteAny(gn, null, null, null) ;
+            systemDSG.commit() ;
+            committed = true ;
+            success(action) ;
+        } finally { 
+            if ( ! committed ) systemDSG.abort() ; 
+            systemDSG.end() ; 
+        }
+    }
+
+    private Quad getOne(DatasetGraph dsg, Node g, Node s, Node p, Node o) {
+        Iterator<Quad> iter = dsg.findNG(g, s, p, o) ;
+        if ( ! iter.hasNext() )
+            return null ;
+        Quad q = iter.next() ;
+        if ( iter.hasNext() )
+            return null ;
+        return q ;
     }
+    
 
     private static void copyFile(File source, File dest) {
         try {

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/GraphLoadUtils.java
Wed Dec  4 16:46:02 2013
@@ -68,7 +68,7 @@ public class GraphLoadUtils
     {
         // We need to do this ourselves, not via riot, to use the webStreamManager
         StreamRDF sink = StreamRDFLib.graph(graph) ;
-        sink = new SinkRDFLimited(sink, limit) ;
+        sink = new StreamRDFLimited(sink, limit) ;
 
         TypedInputStream input = Fuseki.webStreamManager.open(uri) ;
         RDFDataMgr.parse(sink, input, uri) ;

Copied: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
(from r1547170, jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/SinkRDFLimited.java)
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java?p2=jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java&p1=jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/SinkRDFLimited.java&r1=1547170&r2=1547840&rev=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/SinkRDFLimited.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/migrate/StreamRDFLimited.java
Wed Dec  4 16:46:02 2013
@@ -16,9 +16,10 @@
  * limitations under the License.
  */
 
-package org.apache.jena.fuseki.migrate;
+package org.apache.jena.fuseki.migrate ;
 
 import org.apache.jena.atlas.lib.Tuple ;
+import org.apache.jena.riot.RiotException ;
 import org.apache.jena.riot.system.StreamRDF ;
 import org.apache.jena.riot.system.StreamRDFWrapper ;
 
@@ -26,40 +27,47 @@ import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.sparql.core.Quad ;
 
-public class SinkRDFLimited extends StreamRDFWrapper
-{
-   private long count = 0 ;
-   private final long limit ;
-    
-    public SinkRDFLimited(StreamRDF output, long limit)
-    {
+/**
+ * Limit triples/quads and stop passing through after a limit is reached.
+ */
+public class StreamRDFLimited extends StreamRDFWrapper {
+    private long       count = 0 ;
+    private final long limit ;
+
+    public StreamRDFLimited(StreamRDF output, long limit) {
         super(output) ;
         this.limit = limit ;
     }
 
     @Override
-    public void triple(Triple triple)
-    { 
+    public void triple(Triple triple) {
         count++ ;
+        if ( count > limit )
+            throw new RiotException("Limit ("+limit+") reached") ; 
         super.triple(triple) ;
     }
 
     @Override
-    public void quad(Quad quad)
-    { 
+    public void quad(Quad quad) {
         count++ ;
+        if ( count > limit )
+            throw new RiotException("Limit ("+limit+") reached") ; 
         super.quad(quad) ;
     }
 
     @Override
-    public void tuple(Tuple<Node> tuple)
-    { 
+    public void tuple(Tuple<Node> tuple) {
         count++ ;
+        if ( count > limit )
+            throw new RiotException("Limit ("+limit+") reached") ; 
         super.tuple(tuple) ;
     }
 
-    
-    public long getCount() { return count ; } 
-    public long getLimit() { return limit ; }
-}
+    public long getCount() {
+        return count ;
+    }
 
+    public long getLimit() {
+        return limit ;
+    }
+}

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetRef.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetRef.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetRef.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetRef.java
Wed Dec  4 16:46:02 2013
@@ -61,12 +61,12 @@ public class DatasetRef implements Datas
         if ( getState() == UNINITIALIZED )
             initServices() ;    
         setState(ACTIVE) ;
-        
     }
     
     public boolean isActive() { return getState() == ACTIVE ; }  
     
-    public DatasetStatus getStatus()    { return state ; }
+    public DatasetStatus getStatus()                    { return state ; }
+    public void setStatus(DatasetStatus newStatus)      { setState(newStatus) ; }
     
     private DatasetStatus getState() {
         return state ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetStatus.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetStatus.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetStatus.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/DatasetStatus.java
Wed Dec  4 16:46:02 2013
@@ -18,7 +18,24 @@
 
 package org.apache.jena.fuseki.server;
 
+import com.hp.hpl.jena.rdf.model.Resource ;
+
 public enum DatasetStatus {
-    UNINITIALIZED, ACTIVE, CLOSING, DORMANT
+    UNINITIALIZED("Uninitialized"), ACTIVE("Active"), CLOSING("Closing"), CLOSED("Closed"),
DORMANT("Dormant") ;
+    public final String name ; 
+    DatasetStatus(String string) { name = string ; }
+    
+    public static DatasetStatus status(Resource r) {
+        if ( FusekiVocab.stateActive.equals(r) )
+            return ACTIVE ;
+        if ( FusekiVocab.stateDormant.equals(r) )
+            return DORMANT ;
+        if ( FusekiVocab.stateClosing.equals(r) )
+            return CLOSING ;
+        if ( FusekiVocab.stateClosed.equals(r) )
+            return CLOSED ;
+        
+        return null ;
+    }
 }
 

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiConfig.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiConfig.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiConfig.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiConfig.java
Wed Dec  4 16:46:02 2013
@@ -30,7 +30,6 @@ import org.apache.jena.atlas.lib.StrUtil
 import org.apache.jena.fuseki.Fuseki ;
 import org.apache.jena.fuseki.FusekiConfigException ;
 import org.apache.jena.fuseki.HttpNames ;
-import org.apache.jena.riot.RDFDataMgr ;
 import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.assembler.Assembler ;
@@ -68,17 +67,6 @@ public class FusekiConfig {
 
     private static Logger log      = Fuseki.configLog ;
 
-    private static String prefixes = StrUtils.strjoinNL
-        ("PREFIX fu:      <http://jena.apache.org/fuseki#>",
-         "PREFIX fuseki:  <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 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 ServerConfig defaultConfiguration(String datasetPath, DatasetGraph dsg,
boolean allowUpdate,
                                                     boolean listenLocal) {
         DatasetRef dbDesc = new DatasetRef() ;
@@ -118,25 +106,57 @@ public class FusekiConfig {
             }
         } ;
     
-    public static void additional(ServerConfig config) {
-        // server/
-        // configure/
-        // databases/
+//    public static void additional(ServerConfig config) {
+//        // server/
+//        // configure/
+//        // databases/
+//        
+//        File d = new File(configurationsDirectory) ;
+//        String[] assemblerFiles = d.list(visibleFiles) ;
+//        
+//        if ( assemblerFiles == null ) {
+//            log.warn("No configurtion directory '"+configurationsDirectory+"'") ;
+//        }
+//        
+//        String x = Iter.asString(Arrays.asList(assemblerFiles));
+//        log.info("Files: "+x);
+//        
+//        for ( String fn : assemblerFiles ) {
+//            Model m = RDFDataMgr.loadModel(configurationsDirectory+"/"+fn);
+//            List<DatasetRef> refs = readConfiguration(m);
+//            config.datasets.addAll(refs) ;
+//        }
+//    }
         
-        File d = new File(configurationsDirectory) ;
-        String[] assemblerFiles = d.list(visibleFiles) ;
+    public static void additional(ServerConfig config) {
+        String qs = StrUtils.strjoinNL
+            (SystemState.PREFIXES ,
+             "SELECT * {" ,
+             "  GRAPH ?g {",
+             "     ?s fu:name ?name ;" ,
+             "        fu:status ?status ." ,
+             "  }",
+             "}"
+             ) ;
         
-        if ( assemblerFiles == null ) {
-            log.warn("No configurtion directory '"+configurationsDirectory+"'") ;
-        }
+        ResultSet rs = query(qs,SystemState.dataset) ;
         
-        String x = Iter.asString(Arrays.asList(assemblerFiles));
-        log.info("Files: "+x);
+//        ResultSetFormatter.out(rs); 
+//        ((ResultSetRewindable)rs).reset();
         
-        for ( String fn : assemblerFiles ) {
-            Model m = RDFDataMgr.loadModel(configurationsDirectory+"/"+fn);
-            List<DatasetRef> refs = readConfiguration(m);
-            config.datasets.addAll(refs) ;
+        for ( ; rs.hasNext() ; ) {
+            QuerySolution row = rs.next() ;
+            Resource s = row.getResource("s") ;
+            // The result set was copied so we need to find the model again.
+            Resource g = row.getResource("g") ;
+            Resource rStatus = row.getResource("status") ;
+            DatasetStatus status = DatasetStatus.status(rStatus) ;
+            Model m = SystemState.dataset.getNamedModel(g.getURI()) ;
+            s = m.wrapAsResource(s.asNode()) ;
+            //String name = row.getLiteral("name").getLexicalForm() ;
+            DatasetRef ref = processService(s) ;
+            ref.setStatus(status) ;
+            config.datasets.add(ref) ;
         }
     }
     
@@ -169,15 +189,12 @@ public class FusekiConfig {
     
     private static Model additionalRDF(Model m ) {
         String x1 = StrUtils.strjoinNL
-            ( "PREFIX tdb: <http://jena.hpl.hp.com/2008/tdb#>" ,
-              "PREFIX ja:  <http://jena.hpl.hp.com/2005/11/Assembler#>", 
+            ( SystemState.PREFIXES, 
               "INSERT                    { [] ja:loadClass 'com.hp.hpl.jena.tdb.TDB' }",
               "WHERE { FILTER NOT EXISTS { [] ja:loadClass 'com.hp.hpl.jena.tdb.TDB' } }"
              ) ;
         String x2 = StrUtils.strjoinNL
-            ("PREFIX tdb: <http://jena.hpl.hp.com/2008/tdb#>" ,
-             "PREFIX ja:  <http://jena.hpl.hp.com/2005/11/Assembler#>",
-             "PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>",
+            (SystemState.PREFIXES,
              "INSERT DATA {",
              "   tdb:DatasetTDB  rdfs:subClassOf  ja:RDFDataset .",
              "   tdb:GraphTDB    rdfs:subClassOf  ja:Model .",
@@ -378,7 +395,7 @@ public class FusekiConfig {
     }
 
     private static ResultSet query(String string, Model m, String varName, RDFNode value)
{
-        Query query = QueryFactory.create(prefixes + string) ;
+        Query query = QueryFactory.create(SystemState.PREFIXES + string) ;
         QuerySolutionMap initValues = null ;
         if ( varName != null )
             initValues = querySolution(varName, value) ;
@@ -388,6 +405,21 @@ public class FusekiConfig {
         return rs ;
     }
 
+    private static ResultSet query(String string, Dataset ds) {
+        return query(string, ds, null, null) ;
+    }
+
+    private static ResultSet query(String string, Dataset ds, String varName, RDFNode value)
{
+        Query query = QueryFactory.create(SystemState.PREFIXES + string) ;
+        QuerySolutionMap initValues = null ;
+        if ( varName != null )
+            initValues = querySolution(varName, value) ;
+        QueryExecution qExec = QueryExecutionFactory.create(query, ds, initValues) ;
+        ResultSet rs = ResultSetFactory.copyResults(qExec.execSelect()) ;
+        qExec.close() ;
+        return rs ;
+    }
+
     private static QuerySolutionMap querySolution(String varName, RDFNode value) {
         QuerySolutionMap qsm = new QuerySolutionMap() ;
         querySolution(qsm, varName, value) ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiVocab.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiVocab.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiVocab.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/FusekiVocab.java
Wed Dec  4 16:46:02 2013
@@ -43,7 +43,22 @@ public class FusekiVocab
 
     public static final Property pAllowTimeoutOverride = property("allowTimeoutOverride");
     public static final Property pMaximumTimeoutOverride = property("maximumTimeoutOverride");
+    
+    // Internal
+    
+    private static final String stateNameActive      = DatasetStatus.ACTIVE.name ;
+    private static final String stateNameDormant     = DatasetStatus.DORMANT.name ;
+    private static final String stateNameClosing     = DatasetStatus.CLOSING.name ;
+    private static final String stateNameClosed      = DatasetStatus.CLOSED.name ;
+    
+    public static final Resource stateActive        = resource(stateNameActive) ;
+    public static final Resource stateDormant       = resource(stateNameDormant) ;
+    public static final Resource stateClosing       = resource(stateNameClosing) ;
+    public static final Resource stateClosed        = resource(stateNameClosed) ;
+    
+    public static final Property pStatus = property("status") ;
 
+    
     private static Resource resource(String localname) { return ResourceFactory.createResource(iri(localname))
; }
     private static Property property(String localname) { return ResourceFactory.createProperty(iri(localname))
; }
         

Added: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SystemState.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SystemState.java?rev=1547840&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SystemState.java
(added)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/server/SystemState.java
Wed Dec  4 16:46:02 2013
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.fuseki.server;
+
+import org.apache.jena.atlas.lib.FileOps ;
+import org.apache.jena.atlas.lib.StrUtils ;
+
+import com.hp.hpl.jena.query.Dataset ;
+import com.hp.hpl.jena.tdb.TDBFactory ;
+import com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction ;
+
+public class SystemState {
+    public static String SystemDatabaseLocation = "system" ;
+    static { FileOps.ensureDir(SystemDatabaseLocation); }
+    public static Dataset                 dataset   = TDBFactory.createDataset(SystemDatabaseLocation)
;
+    public static DatasetGraphTransaction dsg       = (DatasetGraphTransaction)(dataset.asDatasetGraph())
;
+    
+    public static String PREFIXES = StrUtils.strjoinNL
+        ("BASE <http://example/base#>",
+         "PREFIX fu:      <http://jena.apache.org/fuseki#>",
+         "PREFIX fuseki:  <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 sdb:     <http://jena.hpl.hp.com/20087/sdb#>",
+         "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#>",
+         "") ;
+}
+

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/HttpAction.java
Wed Dec  4 16:46:02 2013
@@ -48,13 +48,13 @@ public class HttpAction
     public final boolean verbose ;
     public final Logger log ;
     
-    // Phase two items - set and valida after the datasetRef is known.  
+    // Phase two items - set and valid after the datasetRef is known.  
     private DatasetGraph dsg ;                  // The data
     public DatasetRef dsRef ;
     public ServiceRef srvRef ;
     
-    private Transactional transactional ;
-    private boolean isTransactional;
+    private Transactional   transactional ;
+    private boolean         isTransactional;
     private DatasetGraph    activeDSG ;             // Set when inside begin/end.
     private ReadWrite       activeMode ;            // Set when inside begin/end.
     
@@ -90,6 +90,9 @@ public class HttpAction
 
     public void setDataset(DatasetRef desc) {
         this.dsRef = desc ;
+        if ( desc == null || desc.dataset == null )
+            return ;
+        
         this.dsg = desc.dataset ;
         DatasetGraph basedsg = unwrap(dsg) ;
 

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_QueryGeneral.java
Wed Dec  4 16:46:02 2013
@@ -91,7 +91,6 @@ public class SPARQL_QueryGeneral extends
                         throw new InternalErrorException("Default graph URI is null or the
empty string")  ;
 
                     try {
-                        //TODO Clearup - RIOT integration.
                         GraphLoadUtils.loadModel(model, uri, MaxTriples) ;
                         action.log.info(format("[%d] Load (default graph) %s", action.id,
uri)) ;
                     } catch (RiotException ex) {

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java?rev=1547840&r1=1547839&r2=1547840&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
(original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
Wed Dec  4 16:46:02 2013
@@ -23,6 +23,7 @@ import static java.lang.String.format ;
 import java.io.IOException ;
 import java.io.InputStream ;
 import java.io.PrintWriter ;
+import java.util.zip.GZIPInputStream ;
 
 import javax.servlet.ServletException ;
 import javax.servlet.http.HttpServletRequest ;
@@ -41,7 +42,9 @@ import org.apache.jena.riot.Lang ;
 import org.apache.jena.riot.RDFLanguages ;
 import org.apache.jena.riot.WebContent ;
 import org.apache.jena.riot.lang.StreamRDFCounting ;
-import org.apache.jena.riot.system.* ;
+import org.apache.jena.riot.system.IRIResolver ;
+import org.apache.jena.riot.system.StreamRDF ;
+import org.apache.jena.riot.system.StreamRDFLib ;
 import org.apache.jena.web.HttpSC ;
 
 import com.hp.hpl.jena.graph.Graph ;
@@ -220,8 +223,16 @@ public class SPARQL_Upload extends Actio
                     ct = ContentType.create(contentTypeHeader) ;
 
                     lang = WebContent.contentTypeToLang(ct.getContentType()) ;
-                    if ( lang == null )
+                    if ( lang == null ) {
                         lang = RDFLanguages.filenameToLang(name) ;
+
+                        //JENA-600 filenameToLang() strips off certain extensions such as
.gz and 
+                        //we need to ensure that if there was a .gz extension present we
wrap the stream accordingly
+                        if (name.endsWith(".gz") )
+                            stream = new GZIPInputStream(stream);
+                    }
+                    
+                    
                     if ( lang == null )
                         // Desperate.
                         lang = RDFLanguages.RDFXML ;



Mime
View raw message