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 2014/06/24 15:36:05 UTC

svn commit: r1605079 - in /jena/Experimental/jena-fuseki2: src-dev/dev/PROJECT.java src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java

Author: andy
Date: Tue Jun 24 13:36:05 2014
New Revision: 1605079

URL: http://svn.apache.org/r1605079
Log:
Refactor ActionStats

Modified:
    jena/Experimental/jena-fuseki2/src-dev/dev/PROJECT.java
    jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java

Modified: jena/Experimental/jena-fuseki2/src-dev/dev/PROJECT.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src-dev/dev/PROJECT.java?rev=1605079&r1=1605078&r2=1605079&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src-dev/dev/PROJECT.java (original)
+++ jena/Experimental/jena-fuseki2/src-dev/dev/PROJECT.java Tue Jun 24 13:36:05 2014
@@ -19,11 +19,12 @@
 package dev;
 
 public class PROJECT {
-    // POM changes from jena-fuseki.
+    // Use void for the system DB - drive service description from this.
+    // RDF Patch (logging and as mime type)
+    // POM changes from jena-fuseki.??
     
     // Convert FmtLog to own logging.
     
-    // Use ActionContainerItem for ActionDatasets
     // Use Action(Container)Item for ActionStats
     
     // Assembler file mgt

Modified: jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java?rev=1605079&r1=1605078&r2=1605079&view=diff
==============================================================================
--- jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java (original)
+++ jena/Experimental/jena-fuseki2/src/main/java/org/apache/jena/fuseki/mgt/ActionStats.java Tue Jun 24 13:36:05 2014
@@ -20,7 +20,6 @@ package org.apache.jena.fuseki.mgt;
 
 import static java.lang.String.format ;
 import static org.apache.jena.riot.WebContent.charsetUTF8 ;
-import static org.apache.jena.riot.WebContent.contentTypeJSON ;
 import static org.apache.jena.riot.WebContent.contentTypeTextPlain ;
 
 import java.io.IOException ;
@@ -31,14 +30,12 @@ import javax.servlet.ServletOutputStream
 import javax.servlet.http.HttpServletRequest ;
 import javax.servlet.http.HttpServletResponse ;
 
-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.fuseki.server.* ;
 import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletOps ;
 
-public class ActionStats extends ActionCtl
+public class ActionStats extends ActionContainerItem
 {
     // XXX Use ActionContainerItem
     public ActionStats() { super() ; } 
@@ -48,31 +45,9 @@ public class ActionStats extends ActionC
         doCommon(req, resp); 
     }
     
-    @Override
-    protected void perform(HttpAction action) {
-        execGet(action) ;
-    }
-
-    protected void execGet(HttpAction action) {
-        JsonValue v ;
-        if (action.getDatasetName() == null )
-            v = execGetContainer(action) ;
-        else
-            v = execGetDataset(action) ;
-        try {
-            HttpServletResponse response = action.response ;
-            ServletOutputStream out = response.getOutputStream() ;
-            response.setContentType(contentTypeJSON);
-            response.setCharacterEncoding(charsetUTF8) ;
-            JSON.write(out, v) ;
-            out.println() ; 
-            out.flush() ;
-            ServletOps.success(action);
-        } catch (IOException ex) { ServletOps.errorOccurred(ex) ; }
-    }
-    
     // This does not consult the system database for dormant etc.
-    private JsonValue execGetContainer(HttpAction action) { 
+    @Override
+    protected JsonValue execGetContainer(HttpAction action) { 
         action.log.info(format("[%d] GET stats all", action.id)) ;
         JsonBuilder builder = new JsonBuilder() ;
         builder.startObject("top") ;
@@ -87,7 +62,8 @@ public class ActionStats extends ActionC
         return builder.build() ;
     }
 
-    private JsonValue execGetDataset(HttpAction action) {
+    @Override
+    protected JsonValue execGetItem(HttpAction action) {
         action.log.info(format("[%d] GET stats dataset %s", action.id, action.getDatasetName())) ;
         
         JsonBuilder builder = new JsonBuilder() ;
@@ -205,6 +181,18 @@ public class ActionStats extends ActionC
         return  counter(dSrv, OperationName.GSP, cn) +
                 counter(dSrv, OperationName.GSP_R, cn) ;
     }
+
+    // We shouldn't get here - no doPost above.
+    
+    @Override
+    protected JsonValue execPostContainer(HttpAction action) {
+        throw new InternalError(METHOD_POST+" container") ;
+    }
+
+    @Override
+    protected JsonValue execPostItem(HttpAction action) {
+        throw new InternalError(METHOD_POST+" item") ;
+    }
 }