jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1405637 - in /jena/trunk/jena-fuseki: src-dev/dev/ src/main/java/org/apache/jena/fuseki/ src/main/java/org/apache/jena/fuseki/servlets/
Date Sun, 04 Nov 2012 21:04:50 GMT
Author: andy
Date: Sun Nov  4 21:04:50 2012
New Revision: 1405637

URL: http://svn.apache.org/viewvc?rev=1405637&view=rev
Log:
Special mode for strict Graph Store Protocol.

Modified:
    jena/trunk/jena-fuseki/src-dev/dev/RunFuseki.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
    jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java

Modified: jena/trunk/jena-fuseki/src-dev/dev/RunFuseki.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src-dev/dev/RunFuseki.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src-dev/dev/RunFuseki.java (original)
+++ jena/trunk/jena-fuseki/src-dev/dev/RunFuseki.java Sun Nov  4 21:04:50 2012
@@ -53,7 +53,7 @@ public class RunFuseki
     private static void main1()
     {
         FusekiCmd.main(
-                     "--update", "--mem", "/ds"
+                     "--update", "--mem", "--gsp", "--uber", "/ds"
                      //"--update", "--loc=DB", "/ds"
                        
                     //"-v", 

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java (original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/Fuseki.java Sun Nov  4 21:04:50
2012
@@ -43,6 +43,9 @@ public class Fuseki
     
     static public String PagesStatic = "pages" ;
     
+    // TEMPORARY
+    static public boolean graphStoreProtocolMode = false ;
+    
     //static private String metadataDevLocation = "org/openjena/fuseki/fuseki-properties-dev.xml"
;
     static private String metadataLocation = "org/apache/jena/fuseki/fuseki-properties.xml"
;
     static private Metadata metadata = initMetadata() ;

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java (original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/FusekiCmd.java Sun Nov  4
21:04:50 2012
@@ -126,6 +126,8 @@ public class FusekiCmd extends CmdARQ
     private static ArgDecl argGZip          = new ArgDecl(ArgDecl.HasValue, "gzip") ;
     private static ArgDecl argUber          = new ArgDecl(ArgDecl.NoValue,  "uber") ;   //
Use the uberservlet (experimental)
     
+    private static ArgDecl argGSP           = new ArgDecl(ArgDecl.NoValue,  "gsp") ;    //
GSP compliance mode
+    
     private static ArgDecl argHome          = new ArgDecl(ArgDecl.HasValue, "home") ;
     private static ArgDecl argPages         = new ArgDecl(ArgDecl.HasValue, "pages") ;
     
@@ -184,6 +186,7 @@ public class FusekiCmd extends CmdARQ
         add(argGZip, "--gzip=on|off",           "Enable GZip compression (HTTP Accept-Encoding)
if request header set") ;
         
         add(argUber) ;
+        add(argGSP) ;
         
         super.modVersion.addClass(TDB.class) ;
         super.modVersion.addClass(Fuseki.class) ;
@@ -371,6 +374,13 @@ public class FusekiCmd extends CmdARQ
         
         if ( contains(argUber) )
             SPARQLServer.überServlet = true ;
+        
+        if ( contains(argGSP) )
+        {
+            SPARQLServer.überServlet = true ;
+            Fuseki.graphStoreProtocolMode = true ;
+        }
+
     }
 
     private static String sort_out_dir(String path)

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java (original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java Sun
Nov  4 21:04:50 2012
@@ -25,13 +25,21 @@ import java.io.IOException ;
 import javax.servlet.ServletOutputStream ;
 import javax.servlet.http.HttpServletRequest ;
 
+import org.apache.jena.fuseki.Fuseki ;
 import org.apache.jena.fuseki.FusekiLib ;
 import org.apache.jena.fuseki.HttpNames ;
+import org.openjena.atlas.lib.Sink ;
 import org.openjena.atlas.web.MediaType ;
 import org.openjena.atlas.web.TypedOutputStream ;
 import org.openjena.riot.Lang ;
+import org.openjena.riot.RiotReader ;
 import org.openjena.riot.RiotWriter ;
+import org.openjena.riot.lang.LangRIOT ;
+import org.openjena.riot.lang.SinkTriplesToGraph ;
 
+import com.hp.hpl.jena.graph.Graph ;
+import com.hp.hpl.jena.graph.Node ;
+import com.hp.hpl.jena.graph.Triple ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 
 /** 
@@ -100,9 +108,44 @@ public class REST_Quads extends SPARQL_R
         } finally { action.endRead() ; }
     }
 
+    static int counter = 0 ;
     @Override
     protected void doPost(HttpActionREST action)
-    { errorMethodNotAllowed("POST") ; }
+    { 
+        if ( ! Fuseki.graphStoreProtocolMode )
+            errorMethodNotAllowed("POST") ;
+        // Code to pass the GSP test suite.
+        String x = action.request.getContentType() ;
+        
+        MediaType mediaType = MediaType.create(x) ;
+        Lang lang = FusekiLib.langFromContentType(mediaType.getContentType()) ;
+        if ( lang == null )
+            lang = Lang.TRIG ;
+
+        if ( action.verbose )
+            log.info(format("[%d]   Post: Content-Type=%s, Charset=%s => %s", 
+                                  action.id, mediaType.getContentType(), mediaType.getCharset(),
lang.getName())) ;
+        if ( lang.isQuads() )
+            errorBadRequest("Quads format: "+mediaType) ;
+        
+        action.beginWrite() ;
+        try {
+            DatasetGraph dsg = action.getActiveDSG() ;
+            String name = action.request.getRequestURL().append("/").append(""+(++counter)).toString()
;
+            Node gn = Node.createURI(name) ;
+            Graph g = dsg.getGraph(gn) ;
+            Sink<Triple> sink = new SinkTriplesToGraph(g) ;
+
+            LangRIOT parser = RiotReader.createParserTriples(action.request.getInputStream(),
lang, name , sink) ;
+            parser.parse() ;
+            action.response.setHeader("Location",  name) ;
+            action.commit();
+            successCreated(action) ;
+        } catch (IOException ex) { action.abort() ; } 
+        finally { action.endWrite() ; }
+        
+    }
+    
 
     @Override
     protected void doDelete(HttpActionREST action)

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
(original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
Sun Nov  4 21:04:50 2012
@@ -31,6 +31,7 @@ import org.apache.jena.fuseki.server.Dat
 import org.openjena.atlas.web.MediaType ;
 import org.openjena.atlas.web.TypedOutputStream ;
 import org.openjena.riot.Lang ;
+import org.openjena.riot.WebContent ;
 
 import com.hp.hpl.jena.rdf.model.Model ;
 import com.hp.hpl.jena.rdf.model.ModelFactory ;
@@ -106,7 +107,8 @@ public class SPARQL_REST_R extends SPARQ
             // If we want to set the Content-Length, we need to buffer.
             //response.setContentLength(??) ;
             RDFWriter writer = FusekiLib.chooseWriter(lang) ;
-            //action.response.setContentType(getServletInfo())
+            String ct = WebContent.mapLangToContentType(lang) ;
+            action.response.setContentType(ct) ;
             
             Model model = ModelFactory.createModelForGraph(action.getTarget().graph()) ;
             writer.write(model, out, null) ;

Modified: jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java?rev=1405637&r1=1405636&r2=1405637&view=diff
==============================================================================
--- jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
(original)
+++ jena/trunk/jena-fuseki/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
Sun Nov  4 21:04:50 2012
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse ;
 
 import org.apache.jena.fuseki.DEF ;
+import org.apache.jena.fuseki.Fuseki ;
 import org.apache.jena.fuseki.HttpNames ;
 import org.apache.jena.fuseki.conneg.ConNeg ;
 import org.apache.jena.fuseki.http.HttpSC ;
@@ -162,9 +163,15 @@ public abstract class SPARQL_UberServlet
         
         if ( ! hasTrailing && ! hasParams )
         {
-            // Security checking?
-            //executeRequest(desc, restQuads, id, request, response) ;
-            errorBadRequest("Request not support (quad operation)") ;
+            // Action on the dataset URI.
+            if ( ! Fuseki.graphStoreProtocolMode )
+            {
+                // Security checking?
+                //executeRequest(desc, restQuads, id, request, response) ;
+                errorBadRequest("Request not support (quad operation)") ;
+                return ;
+            }
+            restQuads.doCommonWorker(id, request, response) ;
             return ;
         }
         



Mime
View raw message