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 2013/12/03 16:53:36 UTC

svn commit: r1547446 [1/2] - in /jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki: ./ mgt/ servlets/ validation/

Author: andy
Date: Tue Dec  3 15:53:35 2013
New Revision: 1547446

URL: http://svn.apache.org/r1547446
Log:
Restructure request processing to put a formal lifecycle for admin operations

Added:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionBase.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionCtl.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java
      - copied, changed from r1547092, jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_ServletBase.java
Removed:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_ServletBase.java
Modified:
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/Fuseki.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/DatasetsServlet.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/REST_Quads.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.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_REST.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Upload.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ServletBase.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidationAction.java
    jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/validation/ValidatorBaseJson.java

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/Fuseki.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/Fuseki.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/Fuseki.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/Fuseki.java Tue Dec  3 15:53:35 2013
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-package org.apache.jena.fuseki;
+package org.apache.jena.fuseki ;
 
 import org.apache.jena.fuseki.server.SPARQLServer ;
 import org.apache.jena.riot.RIOT ;
@@ -37,160 +37,204 @@ import com.hp.hpl.jena.tdb.TDB ;
 import com.hp.hpl.jena.tdb.transaction.TransactionManager ;
 
 /**
- * <p>The main class enabling us to:</p> 
+ * <p>
+ * The main class enabling us to:
+ * </p>
  * <ol>
- * <li>create instances of a Fuseki server e.g.
- * the ARQ, RIOT and TDB server stack</li>
- * <li>get server global {@link com.hp.hpl.jena.sparql.util.Context} e.g. 
- * named values used to pass implementation-specific parameters across 
- * general interfaces.</li>
+ * <li>create instances of a Fuseki server e.g. the ARQ, RIOT and TDB server
+ * stack</li>
+ * <li>get server global {@link com.hp.hpl.jena.sparql.util.Context} e.g. named
+ * values used to pass implementation-specific parameters across general
+ * interfaces.</li>
  * <li>get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.</li>
  * <li>set the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.</li>
- *
+ * 
  */
-public class Fuseki
-{
-    /** Path to ???*/
-    static public String PATH = "org.apache.jena.fuseki" ;
-    
-    /** a unique IRI for the Fuseki namespace*/
-    static public String FusekiIRI = "http://jena.apache.org/Fuseki" ;
-    
+public class Fuseki {
+    /** Path to ??? */
+    static public String    PATH                         = "org.apache.jena.fuseki" ;
+
+    /** a unique IRI for the Fuseki namespace */
+    static public String    FusekiIRI                    = "http://jena.apache.org/Fuseki" ;
+
     /** Fuseki home environment, usually set to $FUSEKI_HOME */
-    static public String FusekiHomeEnv = "FUSEKI_HOME" ;
-    
-    /** a unique IRI including the symbol notation for which properties should be appended */
-    static public String FusekiSymbolIRI = "http://jena.apache.org/fuseki#" ;
-    
+    static public String    FusekiHomeEnv                = "FUSEKI_HOME" ;
+
+    /**
+     * a unique IRI including the symbol notation for which properties should be
+     * appended
+     */
+    static public String    FusekiSymbolIRI              = "http://jena.apache.org/fuseki#" ;
+
     /** ??? */
-    static public String PagesStatic = "pages" ;
-    
-    /** 
-     * TEMPORARY - this enables POST of triples to the dataset URI causing a graph to be created.
-     * POSTing to /dataset?graph=uri is preferred 
-     */
-    static public boolean graphStoreProtocolPostCreate = false ;
-    
-    /** an relative path to the location of <code>fuseki-properties.xml</code> file */
-    static private String metadataLocation = "org/apache/jena/fuseki/fuseki-properties.xml" ;
-    
-    /** Object which holds metadata specified within {@link Fuseki#metadataLocation} */
-    static private Metadata metadata = initMetadata() ;
-    
-    private static Metadata initMetadata()
-    {
+    static public String    PagesStatic                  = "pages" ;
+
+    /**
+     * TEMPORARY - this enables POST of triples to the dataset URI causing a
+     * graph to be created. POSTing to /dataset?graph=uri is preferred
+     */
+    static public boolean   graphStoreProtocolPostCreate = false ;
+
+    /**
+     * an relative path to the location of <code>fuseki-properties.xml</code>
+     * file
+     */
+    static private String   metadataLocation             = "org/apache/jena/fuseki/fuseki-properties.xml" ;
+
+    /**
+     * Object which holds metadata specified within
+     * {@link Fuseki#metadataLocation}
+     */
+    static private Metadata metadata                     = initMetadata() ;
+
+    private static Metadata initMetadata() {
         Metadata m = new Metadata() ;
-        //m.addMetadata(metadataDevLocation) ;
+        // m.addMetadata(metadataDevLocation) ;
         m.addMetadata(metadataLocation) ;
         return m ;
     }
-    
-    /** The name of the Fuseki server. Set to the string <code>Fuseki</code> by default.*/
-    static public final String NAME             = "Fuseki" ;
-    
+
+    /**
+     * The name of the Fuseki server. Set to the string <code>Fuseki</code> by
+     * default.
+     */
+    static public final String        NAME              = "Fuseki" ;
+
     /** Version of this Fuseki instance */
-    static public final String VERSION          = metadata.get(PATH+".version", "development");
-    
+    static public final String        VERSION           = metadata.get(PATH + ".version", "development") ;
+
     /** Date when Fuseki was built */
-    static public final String BUILD_DATE       = metadata.get(PATH+".build.datetime", "unknown") ; // call Date if unavailable.
-    
-    /** An identifier for the HTTP Fuseki server instance*/
-    static public final String serverHttpName   = NAME+" ("+VERSION+")" ;    
-    
+    static public final String        BUILD_DATE        = metadata.get(PATH + ".build.datetime", "unknown") ; // call
+                                                                                                              // Date
+                                                                                                              // if
+                                                                                                              // unavailable.
+
+    /** An identifier for the HTTP Fuseki server instance */
+    static public final String        serverHttpName    = NAME + " (" + VERSION + ")" ;
+
     /** Actual log file for operations */
-    public static final String requestLogName   = PATH+".Fuseki" ;
-    
+    public static final String        requestLogName    = PATH + ".Fuseki" ;
+
     /** Instance of log for operations */
-    public static final Logger requestLog       = LoggerFactory.getLogger(requestLogName) ;
-    
+    public static final Logger        requestLog        = LoggerFactory.getLogger(requestLogName) ;
+
     /** Admin log file for operations */
-    public static final String adminLogName   = PATH+".Admin" ;
-    
+    public static final String        adminLogName      = PATH + ".Admin" ;
+
     /** Instance of log for operations */
-    public static final Logger adminLog       = LoggerFactory.getLogger(adminLogName) ;
-    
+    public static final Logger        adminLog          = LoggerFactory.getLogger(adminLogName) ;
+
+    /** Validation log file for operations */
+    public static final String        validationLogName = PATH + ".Validate" ;
+
+    /** Instance of log for validation */
+    public static final Logger        validationLog     = LoggerFactory.getLogger(adminLogName) ;
+
+    /** Actual log file for general server messages. */
+    public static final String        serverLogName     = PATH + ".Server" ;
 
-    /** Actual log file for general server messages.*/
-    public static final String serverLogName    = PATH+".Server" ;
-    
     /** Instance of log for general server messages */
-    public static final Logger serverLog        = LoggerFactory.getLogger(serverLogName) ;
-    
+    public static final Logger        serverLog         = LoggerFactory.getLogger(serverLogName) ;
+
     /** Actual log file for config server messages. */
-    public static final String configLogName    = PATH+".Config" ;
-    
-    /** Instance of log for config server message s*/
-    public static final Logger configLog        = LoggerFactory.getLogger(configLogName) ;
-    
-    /** Instance of log for config server message s*/
-    public static boolean verboseLogging        = false ;
-    
-    /** An instance of management for stream opening, including redirecting through a 
-     * location mapper whereby a name (e.g. URL) is redirected to another name (e.g. local file).
+    public static final String        configLogName     = PATH + ".Config" ;
+
+    /** Instance of log for config server message s */
+    public static final Logger        configLog         = LoggerFactory.getLogger(configLogName) ;
+
+    /** Instance of log for config server message s */
+    public static boolean             verboseLogging    = false ;
+
+    /**
+     * An instance of management for stream opening, including redirecting
+     * through a location mapper whereby a name (e.g. URL) is redirected to
+     * another name (e.g. local file).
      * */
     public static final StreamManager webStreamManager ;
     static {
         webStreamManager = new StreamManager() ;
-        // Only know how to handle http URLs 
+        // Only know how to handle http URLs
         webStreamManager.addLocator(new LocatorURL()) ;
     }
-    
-    private static boolean initialized = false ;
-    
+
+    private static boolean            initialized       = false ;
+
     /**
      * Initialize an instance of the Fuseki server stack.
      */
-    public synchronized static void init()
-    {
+    public synchronized static void init() {
         if ( initialized )
             return ;
         initialized = true ;
         ARQ.init() ;
         SystemInfo sysInfo = new SystemInfo(FusekiIRI, VERSION, BUILD_DATE) ;
-        ARQMgt.register(PATH+".system:type=SystemInfo", sysInfo) ;
+        ARQMgt.register(PATH + ".system:type=SystemInfo", sysInfo) ;
         SystemARQ.registerSubSystem(sysInfo) ;
         RIOT.init() ;
         TDB.init() ;
         MappingRegistry.addPrefixMapping("fuseki", FusekiSymbolIRI) ;
-        
+
         TDB.setOptimizerWarningFlag(false) ;
         // Don't set TDB batch commits.
-        // This can be slower, but it less memory hungry and more predictable. 
+        // This can be slower, but it less memory hungry and more predictable.
         TransactionManager.QueueBatchSize = 0 ;
     }
-  
+
     /**
      * Get server global {@link com.hp.hpl.jena.sparql.util.Context}.
+     * 
      * @return {@link com.hp.hpl.jena.query.ARQ#getContext()}
      */
-    public static Context getContext()
-    {
+    public static Context getContext() {
         return ARQ.getContext() ;
     }
-    
+
     // Temporary ...
     private static SPARQLServer server ;
-    private static Server jettyServer ;
-    private static Server mgtJettyServer ;
-    
-    /** set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.*/
-    public static void setServer(SPARQLServer _server)      { server = _server ; }
-    
+    private static Server       jettyServer ;
+    private static Server       mgtJettyServer ;
+
+    /**
+     * set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer}
+     * instance.
+     */
+    public static void setServer(SPARQLServer _server) {
+        server = _server ;
+    }
+
     /** get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance. */
-    public static SPARQLServer getServer()                  { return server ; }
+    public static SPARQLServer getServer() {
+        return server ;
+    }
+
+    /**
+     * set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer}
+     * instance.
+     */
+    public static void setJettyServer(Server _server) {
+        jettyServer = _server ;
+    }
 
-    /** set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.*/
-    public static void setJettyServer(Server _server)      { jettyServer = _server ; }
-    
     /** get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance. */
-    public static Server getJettyServer()                  { return jettyServer ; }
+    public static Server getJettyServer() {
+        return jettyServer ;
+    }
+
+    /**
+     * set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer}
+     * instance.
+     */
+    public static void setJettyMgtServer(Server _server) {
+        mgtJettyServer = _server ;
+    }
 
-    /** set/specify the {@link org.apache.jena.fuseki.server.SPARQLServer} instance.*/
-    public static void setJettyMgtServer(Server _server)      { mgtJettyServer = _server ; }
-    
     /** get the {@link org.apache.jena.fuseki.server.SPARQLServer} instance. */
-    public static Server getJettyMgtServer()                  { return mgtJettyServer ; }
+    public static Server getJettyMgtServer() {
+        return mgtJettyServer ;
+    }
 
     // Force a call to init.
-    static { init() ; }
+    static {
+        init() ;
+    }
 }

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/FusekiCmd.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/FusekiCmd.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/FusekiCmd.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/FusekiCmd.java Tue Dec  3 15:53:35 2013
@@ -77,6 +77,8 @@ public class FusekiCmd extends CmdARQ {
          "log4j.logger."+Fuseki.serverLogName+"=INFO",
          "log4j.logger."+Fuseki.requestLogName+"=INFO",
          "log4j.logger."+Fuseki.adminLogName+"=INFO",
+         "log4j.logger."+Fuseki.validationLogName+"=INFO",
+         
          "log4j.logger.org.apache.jena.tdb.loader=INFO",
          "log4j.logger.org.eclipse.jetty=ERROR" ,
 

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/ActionBackup.java Tue Dec  3 15:53:35 2013
@@ -36,8 +36,8 @@ import org.apache.jena.fuseki.FusekiExce
 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.servlets.ActionCtl ;
 import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.ServletBase ;
 import org.apache.jena.riot.Lang ;
 import org.apache.jena.riot.RDFDataMgr ;
 import org.apache.jena.web.HttpSC ;
@@ -45,7 +45,7 @@ import org.apache.jena.web.HttpSC ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 import com.hp.hpl.jena.sparql.util.Utils ;
 
-public class ActionBackup extends ServletBase
+public class ActionBackup extends ActionCtl
 {
     public ActionBackup() { super() ; }
 
@@ -53,12 +53,17 @@ public class ActionBackup extends Servle
     public static final ExecutorService backupService = Executors.newFixedThreadPool(1) ;
     
     @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        doCommon(request, response); 
+    }
+    
+    @Override
+    protected void perform(HttpAction action)
     {
-        String dataset = FusekiLib.safeParameter(request, "dataset") ;
+        String dataset = FusekiLib.safeParameter(action.request, "dataset") ;
         if ( dataset == null )
         {
-            response.sendError(HttpSC.BAD_REQUEST_400, "Required parameter missing: ?dataset=") ;
+            errorBadRequest("Required parameter missing: ?dataset=") ;
             return ;
         }
         
@@ -72,12 +77,10 @@ public class ActionBackup extends Servle
         boolean known = DatasetRegistry.get().isRegistered(dataset) ;
         if (!known)
         {
-            response.sendError(HttpSC.BAD_REQUEST_400, "No such dataset: " + dataset) ;
+            errorBadRequest("No such dataset: " + dataset) ;
             return ;
         }
         
-        long id = allocRequestId(request, response);
-        HttpAction action = new HttpAction(id, request, response, false) ;
         DatasetRef ref = DatasetRegistry.get().get(dataset) ;
         action.setDataset(ref);
         scheduleBackup(action) ;
@@ -99,15 +102,15 @@ public class ActionBackup extends Servle
                 @Override
                 public Boolean call() throws Exception
                 {
-                    log.info(format("[%d] Start backup %s to '%s'", action.id, ds, filename)) ;
+                    action.log.info(format("[%d] Start backup %s to '%s'", action.id, ds, filename)) ;
                     action.beginRead() ;
                     try {
                         backup(action.getActiveDSG(), filename) ;
-                        log.info(format("[%d] Finish backup %s to '%s'", action.id, ds, filename)) ;
+                        action.log.info(format("[%d] Finish backup %s to '%s'", action.id, ds, filename)) ;
                     }
                     catch ( RuntimeException ex )
                     {
-                        log.info(format("[%d] Exception during backup: ", action.id, ex.getMessage()), ex) ;
+                        action.log.info(format("[%d] Exception during backup: ", action.id, ex.getMessage()), ex) ;
                         return Boolean.FALSE ;
                     }
                     finally {
@@ -116,13 +119,13 @@ public class ActionBackup extends Servle
                     return Boolean.TRUE ;
                 }} ;
             
-            log.info(format("[%d] Schedule backup %s to '%s'", action.id, ds, filename)) ;                
+                action.log.info(format("[%d] Schedule backup %s to '%s'", action.id, ds, filename)) ;                
             backupService.submit(task) ;
         } 
         //catch (FusekiException ex)
         catch (RuntimeException ex)
         {
-            log.warn("Unanticipated exception", ex) ;
+            action.log.warn("Unanticipated exception", ex) ;
             try { action.response.sendError(HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()) ; }
             catch (IOException e) { IO.exception(e) ; }
             return ;            

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/DatasetsServlet.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/DatasetsServlet.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/DatasetsServlet.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/mgt/DatasetsServlet.java Tue Dec  3 15:53:35 2013
@@ -18,10 +18,6 @@
 
 package org.apache.jena.fuseki.mgt;
 
-import static org.apache.jena.fuseki.server.CounterName.Requests ;
-import static org.apache.jena.fuseki.server.CounterName.RequestsBad ;
-import static org.apache.jena.fuseki.server.CounterName.RequestsGood ;
-
 import java.io.* ;
 import java.nio.channels.FileChannel ;
 import java.util.List ;
@@ -37,15 +33,14 @@ 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.web.ContentType ;
-import org.apache.jena.fuseki.Fuseki ;
 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.servlets.ActionCtl ;
 import org.apache.jena.fuseki.servlets.ActionErrorException ;
 import org.apache.jena.fuseki.servlets.HttpAction ;
-import org.apache.jena.fuseki.servlets.SPARQL_ServletBase ;
 import org.apache.jena.riot.* ;
 import org.apache.jena.riot.lang.LangRIOT ;
 import org.apache.jena.riot.system.ErrorHandler ;
@@ -53,26 +48,15 @@ import org.apache.jena.riot.system.Error
 import org.apache.jena.riot.system.StreamRDF ;
 import org.apache.jena.riot.system.StreamRDFLib ;
 import org.apache.jena.web.HttpSC ;
-import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.rdf.model.Model ;
-import com.hp.hpl.jena.rdf.model.ModelFactory ; 
-
+import com.hp.hpl.jena.rdf.model.ModelFactory ;
 
-public class DatasetsServlet extends SPARQL_ServletBase /* rename */ {
-    private static Logger alog = Fuseki.adminLog ;
 
-    // XXX Rewrite for (renamed) SPARQL_ServletBase(Logger)
-    // ActionRequest(Logger)
-    //    > ServiceRequest
-    //    > AdminRequest
-    //    > Backup
-    //    > Status
+public class DatasetsServlet extends ActionCtl {
     
     public DatasetsServlet() {}
     
-    // LOG
-    
     @Override
     protected void doGet(HttpServletRequest request, HttpServletResponse response) {
         doCommon(request, response);
@@ -88,6 +72,11 @@ public class DatasetsServlet extends SPA
         doCommon(request, response);
     }
     
+//    @Override
+//    protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+//        doCommon(request, response);
+//    }
+
     @Override
     protected void executeLifecycle(HttpAction action)
     {
@@ -106,11 +95,6 @@ public class DatasetsServlet extends SPA
     }
     
     @Override
-    protected void validate(HttpAction action) { 
-        // Validate later.
-    }
-
-    @Override
     protected void perform(HttpAction action) {
         String name = mapRequestToDataset(action) ;
         String method = action.request.getMethod().toUpperCase(Locale.ROOT) ;
@@ -127,9 +111,9 @@ public class DatasetsServlet extends SPA
     // Null means no name given, i.e. names the collection.
     @Override
     protected String mapRequestToDataset(HttpAction action) {
-        alog.info("context path  = "+action.request.getContextPath()) ;
-        alog.info("pathinfo      = "+action.request.getPathInfo()) ;
-        alog.info("servlet path  = "+action.request.getServletPath()) ;
+        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 /*
@@ -149,7 +133,7 @@ public class DatasetsServlet extends SPA
     }
 
     protected void execGet(String name, HttpAction action) {
-        alog.info("GET ds="+(name==null?"":name)) ;
+        action.log.info("GET ds="+(name==null?"":name)) ;
         JsonBuilder builder = new JsonBuilder() ;
         if ( name == null ) {
             // All
@@ -173,8 +157,9 @@ public class DatasetsServlet extends SPA
             JSON.write(out, v) ;
             out.println() ; 
             out.flush() ;
-            success(action) ;
         } catch (IOException ex) { errorOccurred(ex) ; }
+        success(action);
+
     }
     
     
@@ -203,17 +188,18 @@ public class DatasetsServlet extends SPA
             dsDesc.dormant() ;
         else
             errorBadRequest("New state '"+s+"' not recognized");
+        success(action);
     }
 
     protected void execPostContainer(HttpAction action) {
-        alog.info("POST container") ;
+        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.request, dest) ;
+        bodyAsGraph(action, dest) ;
         List<DatasetRef> refs = FusekiConfig.readConfiguration(m);
         
         for (DatasetRef dsDesc : refs) {
@@ -230,11 +216,12 @@ public class DatasetsServlet extends SPA
             RDFDataMgr.write(out, m, Lang.TURTLE) ;
             out.close() ;
         } catch (IOException ex) { IO.exception(ex) ; }
+        success(action);
     }
 
     protected void execDelete(String name, HttpAction action) {
         // Find DS.
-        alog.info("DELETE "+(name==null?"":name));
+        action.log.info("DELETE "+(name==null?"":name));
         if ( name == null ) {
             errorBadRequest("DELETE only to the container entries.") ;
             return ;
@@ -248,6 +235,7 @@ public class DatasetsServlet extends SPA
         DatasetRegistry.get().remove(name) ;
         // No longer routeable
         dsRef.gracefulShutdown() ;
+        success(action);
     }
 
     private static void copyFile(File source, File dest) {
@@ -264,9 +252,8 @@ public class DatasetsServlet extends SPA
     
     // XXX Merge with SPARQL_REST_RW.incomingData
     
-    protected static ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(log) ;
-
-    private static void bodyAsGraph(HttpServletRequest request, StreamRDF dest) {
+    private static void bodyAsGraph(HttpAction action, StreamRDF dest) {
+        HttpServletRequest request = action.request ;
         String base = wholeRequestURL(request) ;
         ContentType ct = FusekiLib.getContentType(request) ;
         Lang lang = WebContent.contentTypeToLang(ct.getContentType()) ;
@@ -288,15 +275,17 @@ public class DatasetsServlet extends SPA
 //                                ct.getCharset(), lang.getName())) ;
 //        }
         dest.prefix("root", base+"#");
-        parse(dest, input, lang, base) ;
+        parse(action, dest, input, lang, base) ;
          
     }
 
-    public static void parse(StreamRDF dest, InputStream input, Lang lang, String base) {
+    // See SPARQL_REST for common code.
+    public static void parse(HttpAction action, StreamRDF dest, InputStream input, Lang lang, String base) {
         // Need to adjust the error handler.
 //        try { RDFDataMgr.parse(dest, input, base, lang) ; }
 //        catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
         LangRIOT parser = RiotReader.createParser(input, lang, base, dest) ;
+        ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(action.log) ;
         parser.getProfile().setHandler(errorHandler) ;
         try { parser.parse() ; } 
         catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }

Added: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionBase.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionBase.java?rev=1547446&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionBase.java (added)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionBase.java Tue Dec  3 15:53:35 2013
@@ -0,0 +1,260 @@
+/*
+ * 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.servlets;
+
+import static java.lang.String.format ;
+
+import java.io.IOException ;
+import java.util.Enumeration ;
+import java.util.Map ;
+import java.util.concurrent.atomic.AtomicLong ;
+
+import javax.servlet.ServletException ;
+import javax.servlet.http.HttpServletRequest ;
+import javax.servlet.http.HttpServletResponse ;
+
+import org.apache.jena.fuseki.HttpNames ;
+import org.apache.jena.web.HttpSC ;
+import org.slf4j.Logger ;
+
+import com.hp.hpl.jena.query.ARQ ;
+import com.hp.hpl.jena.query.QueryCancelledException ;
+import com.hp.hpl.jena.sparql.util.Context ;
+
+/** General request lifecycle */
+public abstract class ActionBase extends ServletBase
+{
+    private final Logger log ;
+
+    protected ActionBase(Logger log) {
+        super() ;
+        this.log = log ;
+    }
+    
+    // Common framework for handling HTTP requests
+    protected void doCommon(HttpServletRequest request, HttpServletResponse response)
+    //throws ServletException, IOException
+    {
+        try {
+            long id = allocRequestId(request, response);
+            
+            // Lifecycle
+            HttpAction action = allocHttpAction(id, request, response) ;
+            // then add to doCommonWorker
+            // work with HttpServletResponseTracker
+            
+            printRequest(action) ;
+            action.setStartTime() ;
+            
+            response = action.response ;
+            initResponse(request, response) ;
+            Context cxt = ARQ.getContext() ;
+            
+            try {
+                execCommonWorker(action) ;
+            } catch (QueryCancelledException ex) {
+                // Also need the per query info ...
+                String message = String.format("The query timed out (restricted to %s ms)", cxt.get(ARQ.queryTimeout));
+                // Possibility :: response.setHeader("Retry-after", "600") ;    // 5 minutes
+                responseSendError(response, HttpSC.SERVICE_UNAVAILABLE_503, message);
+            } catch (ActionErrorException ex) {
+                if ( ex.exception != null )
+                    ex.exception.printStackTrace(System.err) ;
+                // Log message done by printResponse in a moment.
+                if ( ex.message != null )
+                    responseSendError(response, ex.rc, ex.message) ;
+                else
+                    responseSendError(response, ex.rc) ;
+            } catch (Throwable ex) {
+                // This should not happen.
+                //ex.printStackTrace(System.err) ;
+                log.warn(format("[%d] RC = %d : %s", id, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()), ex) ;
+                responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()) ;
+            }
+    
+            action.setFinishTime() ;
+            printResponse(action) ;
+            archiveHttpAction(action) ;
+        } catch (Throwable th) {
+            log.error("Internal error", th) ;
+        }
+    }
+
+    // ---- Operation lifecycle
+
+    /** Return a fresh WebAction for this request */
+    protected HttpAction allocHttpAction(long id, HttpServletRequest request, HttpServletResponse response) {
+        // Need a way to set verbose logging on a per servlet and per request basis. 
+        return new HttpAction(id, log, request, response, verboseLogging) ;
+    }
+
+//    protected abstract void validate(HttpAction action) ;
+//    protected abstract void perform(HttpAction action) ;
+
+    // Default start/finish steps. 
+    protected void startRequest(HttpAction action) {
+    }
+    
+    protected void finishRequest(HttpAction action) { }
+    
+    private void archiveHttpAction(HttpAction action)
+    {
+        action.minimize() ;
+    }
+
+    protected abstract void execCommonWorker(HttpAction action) ;
+        
+    @Deprecated
+    protected void inc(AtomicLong x)
+    {
+        x.incrementAndGet() ;
+    }
+
+//    // Execute - no stats.
+//    // Intercept point for the UberServlet 
+//    protected void executeAction(HttpAction action) {
+//        executeLifecycle(action) ;
+//    }
+//    
+//    // This is the service request lifecycle.
+//    // Called directly by the UberServlet which has not done any stats by this point.
+//    protected void executeLifecycle(HttpAction action)
+//    {
+//        incCounter(action.dsRef, Requests) ;
+//        incCounter(action.srvRef, Requests) ;
+//
+//        startRequest(action) ;
+//        try {
+//            validate(action) ;
+//        } catch (ActionErrorException ex) {
+//            incCounter(action.dsRef,RequestsBad) ;
+//            incCounter(action.srvRef, RequestsBad) ;
+//            throw ex ;
+//        }
+//
+//        try {
+//            perform(action) ;
+//            // Success
+//            incCounter(action.srvRef, RequestsGood) ;
+//            incCounter(action.dsRef, RequestsGood) ;
+//        } catch (ActionErrorException ex) {
+//            incCounter(action.srvRef, RequestsBad) ;
+//            incCounter(action.dsRef, RequestsBad) ;
+//            throw ex ;
+//        } catch (QueryCancelledException ex) {
+//            incCounter(action.srvRef, RequestsBad) ;
+//            incCounter(action.dsRef, RequestsBad) ;
+//            throw ex ;
+//        } finally {
+//            finishRequest(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) ;
+//        }
+//    }
+
+    @SuppressWarnings("unused") // ServletException
+    protected void doPatch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "HTTP PATCH not supported");
+    }
+    
+    private void printRequest(HttpAction action)
+    {
+        String url = wholeRequestURL(action.request) ;
+        String method = action.request.getMethod() ;
+
+        log.info(format("[%d] %s %s", action.id, method, url)) ;
+        if ( action.verbose ) {
+            Enumeration<String> en = action.request.getHeaderNames() ;
+            for (; en.hasMoreElements();) {
+                String h = en.nextElement() ;
+                Enumeration<String> vals = action.request.getHeaders(h) ;
+                if (!vals.hasMoreElements())
+                    log.info(format("[%d]   ", action.id, h)) ;
+                else {
+                    for (; vals.hasMoreElements();)
+                        log.info(format("[%d]   %-20s %s", action.id, h, vals.nextElement())) ;
+                }
+            }
+        }
+    }
+    
+    private void initResponse(HttpServletRequest request, HttpServletResponse response)
+    {
+        setCommonHeaders(response) ;
+        String method = request.getMethod() ;
+        // All GET and HEAD operations are sensitive to conneg so ...
+        if ( HttpNames.METHOD_GET.equalsIgnoreCase(method) || HttpNames.METHOD_HEAD.equalsIgnoreCase(method) )
+            setVaryHeader(response) ;
+    }
+    
+    private void printResponse(HttpAction action)
+    {
+        long time = action.getTime() ;
+        
+        HttpServletResponseTracker response = action.response ;
+        if ( action.verbose )
+        {
+            if ( action.contentType != null )
+                log.info(format("[%d]   %-20s %s", action.id, HttpNames.hContentType, action.contentType)) ;
+            if ( action.contentLength != -1 )
+                log.info(format("[%d]   %-20s %d", action.id, HttpNames.hContentLengh, action.contentLength)) ;
+            for ( Map.Entry<String, String> e: action.headers.entrySet() )
+                log.info(format("[%d]   %-20s %s", action.id, e.getKey(), e.getValue())) ;
+        }
+
+        String timeStr = fmtMillis(time) ;
+
+        if ( action.message == null )
+            log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, HttpSC.getMessage(action.statusCode), timeStr)) ;
+        else
+            log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, action.message, timeStr)) ;
+    }
+    
+    private static String fmtMillis(long time)
+    {
+        // Millis only? seconds only?
+        if ( time < 1000 )
+            return String.format("%,d ms", time) ;
+        return String.format("%,.3f s", time/1000.0) ;
+    }
+}

Added: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionCtl.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionCtl.java?rev=1547446&view=auto
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionCtl.java (added)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionCtl.java Tue Dec  3 15:53:35 2013
@@ -0,0 +1,95 @@
+/*
+ * 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.servlets;
+
+import org.apache.jena.fuseki.Fuseki ;
+import org.apache.jena.fuseki.server.* ;
+
+/** Control/admin request lifecycle */
+public abstract class ActionCtl extends ActionBase
+{
+    protected ActionCtl() { super(Fuseki.adminLog) ; }
+    
+    @Override
+    final
+    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() ;
+
+        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) ;
+    }
+
+    // Execute - no stats.
+    // Intercept point for the UberServlet 
+    protected void executeAction(HttpAction action) {
+        executeLifecycle(action) ;
+    }
+    
+    // This is the service request lifecycle.
+    protected void executeLifecycle(HttpAction action)
+    {
+        startRequest(action) ;
+        perform(action) ;
+        finishRequest(action) ;
+    }
+    
+    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) ;
+        }
+    }
+}

Copied: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java (from r1547092, jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_ServletBase.java)
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java?p2=jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java&p1=jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_ServletBase.java&r1=1547092&r2=1547446&rev=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_ServletBase.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ActionSPARQL.java Tue Dec  3 15:53:35 2013
@@ -18,105 +18,24 @@
 
 package org.apache.jena.fuseki.servlets;
 
-import static java.lang.String.format ;
 import static org.apache.jena.fuseki.server.CounterName.Requests ;
 import static org.apache.jena.fuseki.server.CounterName.RequestsBad ;
 import static org.apache.jena.fuseki.server.CounterName.RequestsGood ;
-
-import java.io.IOException ;
-import java.util.Enumeration ;
-import java.util.Map ;
-import java.util.concurrent.atomic.AtomicLong ;
-
-import javax.servlet.ServletException ;
-import javax.servlet.http.HttpServletRequest ;
-import javax.servlet.http.HttpServletResponse ;
-
 import org.apache.jena.fuseki.Fuseki ;
-import org.apache.jena.fuseki.HttpNames ;
 import org.apache.jena.fuseki.server.* ;
-import org.apache.jena.web.HttpSC ;
 
-import com.hp.hpl.jena.query.ARQ ;
 import com.hp.hpl.jena.query.QueryCancelledException ;
-import com.hp.hpl.jena.sparql.util.Context ;
 
-public abstract class SPARQL_ServletBase extends ServletBase
+/** SPARQL request lifecycle */
+public abstract class ActionSPARQL extends ActionBase
 {
-    protected SPARQL_ServletBase()      {   super() ; }
+    protected ActionSPARQL() { super(Fuseki.requestLog) ; }
     
-    // Common framework for handling HTTP requests
-    protected void doCommon(HttpServletRequest request, HttpServletResponse response)
-    //throws ServletException, IOException
-    {
-        try {
-            long id = allocRequestId(request, response);
-            
-            // Lifecycle
-            HttpAction action = allocHttpAction(id, request, response) ;
-            // then add to doCommonWorker
-            // work with HttpServletResponseTracker
-            
-            printRequest(action) ;
-            action.setStartTime() ;
-            
-            response = action.response ;
-            initResponse(request, response) ;
-            Context cxt = ARQ.getContext() ;
-            
-            try {
-                execCommonWorker(action) ;
-            } catch (QueryCancelledException ex) {
-                // Also need the per query info ...
-                String message = String.format("The query timed out (restricted to %s ms)", cxt.get(ARQ.queryTimeout));
-                // Possibility :: response.setHeader("Retry-after", "600") ;    // 5 minutes
-                responseSendError(response, HttpSC.SERVICE_UNAVAILABLE_503, message);
-            } catch (ActionErrorException ex) {
-                if ( ex.exception != null )
-                    ex.exception.printStackTrace(System.err) ;
-                // Log message done by printResponse in a moment.
-                if ( ex.message != null )
-                    responseSendError(response, ex.rc, ex.message) ;
-                else
-                    responseSendError(response, ex.rc) ;
-            } catch (Throwable ex) {
-                // This should not happen.
-                //ex.printStackTrace(System.err) ;
-                log.warn(format("[%d] RC = %d : %s", id, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()), ex) ;
-                responseSendError(response, HttpSC.INTERNAL_SERVER_ERROR_500, ex.getMessage()) ;
-            }
-    
-            action.setFinishTime() ;
-            printResponse(action) ;
-            archiveHttpAction(action) ;
-        } catch (Throwable th) {
-            log.error("Internal error", th) ;
-        }
-    }
-
-    // ---- Operation lifecycle
-
-    /** Return a fresh WebAction for this request */
-    protected HttpAction allocHttpAction(long id, HttpServletRequest request, HttpServletResponse response) {
-        // Need a way to set verbose logging on a per servlet and per request basis. 
-        return new HttpAction(id, request, response, verboseLogging) ;
-    }
-
     protected abstract void validate(HttpAction action) ;
     protected abstract void perform(HttpAction action) ;
 
-    // Default start/finish steps. 
-    protected void startRequest(HttpAction action) {
-    }
-    
-    protected void finishRequest(HttpAction action) { }
-    
-    private void archiveHttpAction(HttpAction action)
-    {
-        action.minimize() ;
-    }
-
-    private void execCommonWorker(HttpAction action)
+    @Override
+    protected void execCommonWorker(HttpAction action)
     {
         DatasetRef dsRef = null ;
 
@@ -138,11 +57,6 @@ public abstract class SPARQL_ServletBase
         action.setService(srvRef) ;
         executeAction(action) ;
     }
-        
-    protected void inc(AtomicLong x)
-    {
-        x.incrementAndGet() ;
-    }
 
     // Execute - no stats.
     // Intercept point for the UberServlet 
@@ -209,70 +123,4 @@ public abstract class SPARQL_ServletBase
             Fuseki.serverLog.warn("Exception on counter dec", ex) ;
         }
     }
-
-    @SuppressWarnings("unused") // ServletException
-    protected void doPatch(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "HTTP PATCH not supported");
-    }
-    
-    private void printRequest(HttpAction action)
-    {
-        String url = wholeRequestURL(action.request) ;
-        String method = action.request.getMethod() ;
-
-        log.info(format("[%d] %s %s", action.id, method, url)) ;
-        if ( action.verbose ) {
-            Enumeration<String> en = action.request.getHeaderNames() ;
-            for (; en.hasMoreElements();) {
-                String h = en.nextElement() ;
-                Enumeration<String> vals = action.request.getHeaders(h) ;
-                if (!vals.hasMoreElements())
-                    log.info(format("[%d]   ", action.id, h)) ;
-                else {
-                    for (; vals.hasMoreElements();)
-                        log.info(format("[%d]   %-20s %s", action.id, h, vals.nextElement())) ;
-                }
-            }
-        }
-    }
-    
-    private void initResponse(HttpServletRequest request, HttpServletResponse response)
-    {
-        setCommonHeaders(response) ;
-        String method = request.getMethod() ;
-        // All GET and HEAD operations are sensitive to conneg so ...
-        if ( HttpNames.METHOD_GET.equalsIgnoreCase(method) || HttpNames.METHOD_HEAD.equalsIgnoreCase(method) )
-            setVaryHeader(response) ;
-    }
-    
-    private void printResponse(HttpAction action)
-    {
-        long time = action.getTime() ;
-        
-        HttpServletResponseTracker response = action.response ;
-        if ( action.verbose )
-        {
-            if ( action.contentType != null )
-                log.info(format("[%d]   %-20s %s", action.id, HttpNames.hContentType, action.contentType)) ;
-            if ( action.contentLength != -1 )
-                log.info(format("[%d]   %-20s %d", action.id, HttpNames.hContentLengh, action.contentLength)) ;
-            for ( Map.Entry<String, String> e: action.headers.entrySet() )
-                log.info(format("[%d]   %-20s %s", action.id, e.getKey(), e.getValue())) ;
-        }
-
-        String timeStr = fmtMillis(time) ;
-
-        if ( action.message == null )
-            log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, HttpSC.getMessage(action.statusCode), timeStr)) ;
-        else
-            log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, action.message, timeStr)) ;
-    }
-    
-    private static String fmtMillis(long time)
-    {
-        // Millis only? seconds only?
-        if ( time < 1000 )
-            return String.format("%,d ms", time) ;
-        return String.format("%,.3f s", time/1000.0) ;
-    }
 }

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=1547446&r1=1547445&r2=1547446&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 Tue Dec  3 15:53:35 2013
@@ -33,6 +33,7 @@ import org.apache.jena.fuseki.DEF ;
 import org.apache.jena.fuseki.conneg.ConNeg ;
 import org.apache.jena.fuseki.server.DatasetRef ;
 import org.apache.jena.fuseki.server.ServiceRef ;
+import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.query.ReadWrite ;
 import com.hp.hpl.jena.sparql.SystemARQ ;
@@ -45,6 +46,7 @@ public class HttpAction
 {
     public final long id ;
     public final boolean verbose ;
+    public final Logger log ;
     
     // Phase two items - set and valida after the datasetRef is known.  
     private DatasetGraph dsg ;                  // The data
@@ -76,8 +78,9 @@ public class HttpAction
     public HttpServletRequest request;
     public HttpServletResponseTracker response ;
     
-    public HttpAction(long id, HttpServletRequest request, HttpServletResponse response, boolean verbose) {
+    public HttpAction(long id, Logger log, HttpServletRequest request, HttpServletResponse response, boolean verbose) {
         this.id = id ;
+        this.log = log ;
         this.request = request ;
         this.response = new HttpServletResponseTracker(this, response) ;
         // Should this be set when setDataset is called from the dataset context?

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/REST_Quads.java Tue Dec  3 15:53:35 2013
@@ -66,7 +66,7 @@ public class REST_Quads extends SPARQL_R
             lang = RDFLanguages.TRIG ;
 
         if ( action.verbose )
-            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s", 
+            action.log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s", 
                                   action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
         if ( ! RDFLanguages.isQuads(lang) )
             errorBadRequest("Not a quads format: "+mediaType) ;
@@ -122,7 +122,7 @@ public class REST_Quads extends SPARQL_R
             lang = RDFLanguages.TRIG ;
 
         if ( action.verbose )
-            log.info(format("[%d]   Post: Content-Type=%s, Charset=%s => %s", 
+            action.log.info(format("[%d]   Post: Content-Type=%s, Charset=%s => %s", 
                                   action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
         
         if ( RDFLanguages.isQuads(lang) )
@@ -186,7 +186,7 @@ public class REST_Quads extends SPARQL_R
             StreamRDF dest = StreamRDFLib.graph(g) ;
             LangRIOT parser = RiotReader.createParser(action.request.getInputStream(), lang, name , dest) ;
             parser.parse() ;
-            log.info(format("[%d] Location: %s", action.id, name)) ;
+            action.log.info(format("[%d] Location: %s", action.id, name)) ;
             action.response.setHeader("Location",  name) ;
             action.commit();
             successCreated(action) ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseModel.java Tue Dec  3 15:53:35 2013
@@ -38,14 +38,11 @@ import org.apache.jena.riot.Lang ;
 import org.apache.jena.riot.RDFDataMgr ;
 import org.apache.jena.riot.WebContent ;
 import org.apache.jena.web.HttpSC ;
-import org.slf4j.Logger ;
 
 import com.hp.hpl.jena.rdf.model.Model ;
 
 public class ResponseModel
 {
-    private static Logger slog = ServletBase.log ;
-
     // Short names for "output="
     private static final String contentOutputJSON          = "json" ;
     private static final String contentOutputXML           = "xml" ;
@@ -123,14 +120,14 @@ public class ResponseModel
     //        }
 
         try {
-            ResponseResultSet.setHttpResponse(request, response, contentType, charset) ; 
+            ResponseResultSet.setHttpResponse(action, contentType, charset) ; 
             response.setStatus(HttpSC.OK_200) ;
             ServletOutputStream out = response.getOutputStream() ;
             RDFDataMgr.write(out, model, lang) ;
             out.flush() ;
         }
         catch (Exception ex) { 
-            slog.info("Exception while writing the response model: "+ex.getMessage(), ex) ;
+            action.log.info("Exception while writing the response model: "+ex.getMessage(), ex) ;
             errorOccurred("Exception while writing the response model: "+ex.getMessage(), ex) ;
         }
     }

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ResponseResultSet.java Tue Dec  3 15:53:35 2013
@@ -22,7 +22,6 @@ import static java.lang.String.format ;
 import static org.apache.jena.atlas.lib.Lib.equal ;
 import static org.apache.jena.fuseki.servlets.ServletBase.errorBadRequest ;
 import static org.apache.jena.fuseki.servlets.ServletBase.errorOccurred ;
-import static org.apache.jena.fuseki.servlets.ServletBase.log ;
 
 import java.io.IOException ;
 import java.util.HashMap ;
@@ -52,7 +51,6 @@ import com.hp.hpl.jena.sparql.core.Prolo
 public class ResponseResultSet
 {
     private static Logger xlog = LoggerFactory.getLogger(ResponseResultSet.class) ;
-    private static Logger slog = ServletBase.log ;
 
     // Short names for "output="
     private static final String contentOutputJSON          = "json" ;
@@ -152,24 +150,25 @@ public class ResponseResultSet
     }
     
     
-    public static void setHttpResponse(HttpServletRequest httpRequest,
-                                       HttpServletResponse httpResponse,
+    public static void setHttpResponse(HttpAction action, 
+//                                       HttpServletRequest httpRequest,
+//                                       HttpServletResponse httpResponse,
                                        String contentType, String charset) 
     {
         // ---- Set up HTTP Response
         // Stop caching (not that ?queryString URLs are cached anyway)
         if ( true )
         {
-            httpResponse.setHeader("Cache-Control", "no-cache") ;
-            httpResponse.setHeader("Pragma", "no-cache") ;
+            action.response.setHeader("Cache-Control", "no-cache") ;
+            action.response.setHeader("Pragma", "no-cache") ;
         }
         // See: http://www.w3.org/International/O-HTTP-charset.html
         if ( contentType != null )
         {
             if ( charset != null && ! isXML(contentType) )
                 contentType = contentType+"; charset="+charset ;
-            log.trace("Content-Type for response: "+contentType) ;
-            httpResponse.setContentType(contentType) ;
+            action.log.trace("Content-Type for response: "+contentType) ;
+            action.response.setContentType(contentType) ;
         }
     }
 
@@ -275,7 +274,7 @@ public class ResponseResultSet
     private static void output(HttpAction action, String contentType, String charset, OutputContent proc) 
     {
         try {
-            setHttpResponse(action.request, action.response, contentType, charset) ; 
+            setHttpResponse(action, contentType, charset) ; 
             action.response.setStatus(HttpSC.OK_200) ;
             ServletOutputStream out = action.response.getOutputStream() ;
             try
@@ -284,7 +283,7 @@ public class ResponseResultSet
                 out.flush() ;
             } catch (QueryCancelledException ex) {
                 // Bother.  Status code 200 already sent.
-                slog.info(format("[%d] Query Cancelled - results truncated (but 200 already sent)", action.id)) ;
+                action.log.info(format("[%d] Query Cancelled - results truncated (but 200 already sent)", action.id)) ;
                 out.println() ;
                 out.println("##  Query cancelled due to timeout during execution   ##") ;
                 out.println("##  ****          Incomplete results           ****   ##") ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Protocol.java Tue Dec  3 15:53:35 2013
@@ -37,7 +37,7 @@ import com.hp.hpl.jena.sparql.core.Datas
 
 /** Support for the SPARQL protocol (SPARQL Query, SPARQL Update)
  */
-public  abstract class SPARQL_Protocol extends SPARQL_ServletBase
+public  abstract class SPARQL_Protocol extends ActionSPARQL
 {
     protected SPARQL_Protocol() { super() ; }
 

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Query.java Tue Dec  3 15:53:35 2013
@@ -123,13 +123,13 @@ public abstract class SPARQL_Query exten
             
         if ( HttpNames.METHOD_GET.equals(method) && action.request.getQueryString() == null )
         {
-            warning("Service Description / SPARQL Query / "+action.request.getRequestURI()) ;
+            warning(action, "Service Description / SPARQL Query / "+action.request.getRequestURI()) ;
             errorNotFound("Service Description: "+action.request.getRequestURI()) ;
         }
         
         // Use of the dataset describing parameters is check later.
         try {
-            validateParams(action.request, allParams) ;
+            validateParams(action, allParams) ;
             validateRequest(action) ; 
         } catch (ActionErrorException ex) { 
             throw ex ; 
@@ -141,8 +141,9 @@ public abstract class SPARQL_Query exten
     protected abstract void validateRequest(HttpAction action) ;
     
     /** Helper for validating request */
-    protected void validateParams(HttpServletRequest request, Collection<String> params)
+    protected void validateParams(HttpAction action, Collection<String> params)
     {
+        HttpServletRequest request = action.request ;
         ContentType ct = FusekiLib.getContentType(request) ;
         boolean mustHaveQueryParam = true ;
         if ( ct != null )
@@ -184,7 +185,7 @@ public abstract class SPARQL_Query exten
             {
                 String name = en.nextElement() ;
                 if ( ! params.contains(name) )
-                    warning("SPARQL Query: Unrecognize request parameter (ignored): "+name) ;
+                    warning(action, "SPARQL Query: Unrecognize request parameter (ignored): "+name) ;
             }
         }
     }
@@ -210,9 +211,9 @@ public abstract class SPARQL_Query exten
     {
         String queryStringLog = formatForLog(queryString) ;
         if ( action.verbose )
-            log.info(format("[%d] Query = \n%s", action.id, queryString));
+            action.log.info(format("[%d] Query = \n%s", action.id, queryString));
         else
-            log.info(format("[%d] Query = %s", action.id, queryStringLog));
+            action.log.info(format("[%d] Query = %s", action.id, queryStringLog));
 
         Query query = null ;
         try {
@@ -285,28 +286,28 @@ public abstract class SPARQL_Query exten
             
             //rs = ResultSetFactory.copyResults(rs) ;
 
-            log.info(format("[%d] exec/select", action.id)) ;
+            action.log.info(format("[%d] exec/select", action.id)) ;
             return new SPARQLResult(rs) ;
         }
 
         if ( query.isConstructType() )
         {
             Model model = qExec.execConstruct() ;
-            log.info(format("[%d] exec/construct", action.id)) ;
+            action.log.info(format("[%d] exec/construct", action.id)) ;
             return new SPARQLResult(model) ;
         }
 
         if ( query.isDescribeType() )
         {
             Model model = qExec.execDescribe() ;
-            log.info(format("[%d] exec/describe",action.id)) ;
+            action.log.info(format("[%d] exec/describe",action.id)) ;
             return new SPARQLResult(model) ;
         }
 
         if ( query.isAskType() )
         {
             boolean b = qExec.execAsk() ;
-            log.info(format("[%d] exec/ask",action.id)) ;
+            action.log.info(format("[%d] exec/ask",action.id)) ;
             return new SPARQLResult(b) ;
         }
 

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=1547446&r1=1547445&r2=1547446&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 Tue Dec  3 15:53:35 2013
@@ -65,7 +65,7 @@ public class SPARQL_QueryGeneral extends
      * Construct a Dataset based on a dataset description.
      */
     
-    protected static Dataset datasetFromDescription(HttpAction action, DatasetDescription datasetDesc)
+    protected Dataset datasetFromDescription(HttpAction action, DatasetDescription datasetDesc)
     {
         try {
             if ( datasetDesc == null )
@@ -93,13 +93,13 @@ public class SPARQL_QueryGeneral extends
                     try {
                         //TODO Clearup - RIOT integration.
                         GraphLoadUtils.loadModel(model, uri, MaxTriples) ;
-                        log.info(format("[%d] Load (default graph) %s", action.id, uri)) ;
+                        action.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())) ;
+                        action.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)
                     {
-                        log.info(format("[%d] Failed to load (default) %s: %s", action.id, uri, ex.getMessage())) ;
+                        action.log.info(format("[%d] Failed to load (default) %s: %s", action.id, uri, ex.getMessage())) ;
                         errorBadRequest("Failed to load URL "+uri) ;
                     }
                 }
@@ -116,14 +116,14 @@ public class SPARQL_QueryGeneral extends
                     try {
                         Model model = ModelFactory.createDefaultModel() ;
                         GraphLoadUtils.loadModel(model, uri, MaxTriples) ;
-                        log.info(format("[%d] Load (named graph) %s", action.id, uri)) ;
+                        action.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())) ;
+                        action.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)
                     {
-                        log.info(format("[%d] Failed to load (named graph) %s: %s", action.id, uri, ex.getMessage())) ;
+                        action.log.info(format("[%d] Failed to load (named graph) %s: %s", action.id, uri, ex.getMessage())) ;
                         errorBadRequest("Failed to load URL "+uri) ;
                     }
                 }
@@ -135,7 +135,7 @@ public class SPARQL_QueryGeneral extends
         catch (ActionErrorException ex) { throw ex ; }
         catch (Exception ex)
         {
-            log.info(format("[%d] SPARQL parameter error: "+ex.getMessage(),action.id, ex)) ;
+            action.log.info(format("[%d] SPARQL parameter error: "+ex.getMessage(),action.id, ex)) ;
             errorBadRequest("Parameter error: "+ex.getMessage());
             return null ;
         }

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST.java Tue Dec  3 15:53:35 2013
@@ -47,11 +47,9 @@ import com.hp.hpl.jena.graph.Node ;
 import com.hp.hpl.jena.graph.NodeFactory ;
 import com.hp.hpl.jena.sparql.core.DatasetGraph ;
 
-public abstract class SPARQL_REST extends SPARQL_ServletBase
+public abstract class SPARQL_REST extends ActionSPARQL
 {
     protected static Logger classLog = LoggerFactory.getLogger(SPARQL_REST.class) ;
-    
-    protected static ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(log) ;
 
     protected final static Target determineTarget(HttpAction action) {
         // Delayed until inside a transaction.
@@ -149,7 +147,9 @@ public abstract class SPARQL_REST extend
             return _graph != null ;
         }
 
-        @Override
+        @Override    
+//      protected static ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(log) ;
+
         public String toString()
         {
             if ( isDefault ) return "default" ;
@@ -296,6 +296,7 @@ public abstract class SPARQL_REST extend
 //        try { RDFDataMgr.parse(dest, input, base, lang) ; }
 //        catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
         LangRIOT parser = RiotReader.createParser(input, lang, base, dest) ;
+        ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(action.log); 
         parser.getProfile().setHandler(errorHandler) ;
         try { parser.parse() ; } 
         catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_R.java Tue Dec  3 15:53:35 2013
@@ -56,15 +56,15 @@ public class SPARQL_REST_R extends SPARQ
         Lang lang = WebContent.contentTypeToLang(mediaType.getContentType()) ;
 
         if ( action.verbose )
-            log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s", 
+            action.log.info(format("[%d]   Get: Content-Type=%s, Charset=%s => %s", 
                             action.id, mediaType.getContentType(), mediaType.getCharset(), lang.getName())) ;
 
         action.beginRead() ;
 
         try {
             Target target = determineTarget(action) ;
-            if ( log.isDebugEnabled() )
-                log.debug("GET->"+target) ;
+            if ( action.log.isDebugEnabled() )
+                action.log.debug("GET->"+target) ;
             boolean exists = target.exists() ;
             if ( ! exists )
                 errorNotFound("No such graph: <"+target.name+">") ;
@@ -95,8 +95,8 @@ public class SPARQL_REST_R extends SPARQ
         action.beginRead() ;
         try { 
             Target target = determineTarget(action) ;
-            if ( log.isDebugEnabled() )
-                log.debug("HEAD->"+target) ;
+            if ( action.log.isDebugEnabled() )
+                action.log.debug("HEAD->"+target) ;
             if ( ! target.exists() )
             {
                 successNotFound(action) ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_REST_RW.java Tue Dec  3 15:53:35 2013
@@ -57,8 +57,8 @@ public class SPARQL_REST_RW extends SPAR
         action.beginWrite() ;
         try {
             Target target = determineTarget(action) ;
-            if ( log.isDebugEnabled() )
-                log.debug("DELETE->"+target) ;
+            if ( action.log.isDebugEnabled() )
+                action.log.debug("DELETE->"+target) ;
             boolean existedBefore = target.exists() ; 
             if ( ! existedBefore)
             {
@@ -70,7 +70,7 @@ public class SPARQL_REST_RW extends SPAR
             action.commit() ;
         }
         finally { action.endWrite() ; }
-        SPARQL_ServletBase.successNoContent(action) ;
+        ActionSPARQL.successNoContent(action) ;
     }
 
     @Override
@@ -102,9 +102,9 @@ public class SPARQL_REST_RW extends SPAR
             existedBefore = addDataIntoNonTxn(action, overwrite) ;
             
         if ( existedBefore )
-            SPARQL_ServletBase.successNoContent(action) ;
+            ActionSPARQL.successNoContent(action) ;
         else
-            SPARQL_ServletBase.successCreated(action) ;
+            ActionSPARQL.successCreated(action) ;
     }
 
     /** Directly add data in a transaction.
@@ -119,8 +119,8 @@ public class SPARQL_REST_RW extends SPAR
         Target target = determineTarget(action) ;
         boolean existedBefore = false ;
         try {
-            if ( log.isDebugEnabled() )
-                log.debug("  ->"+target) ;
+            if ( action.log.isDebugEnabled() )
+                action.log.debug("  ->"+target) ;
             existedBefore = target.exists() ;
             Graph g = target.graph() ;
             if ( overwrite && existedBefore )
@@ -167,8 +167,8 @@ public class SPARQL_REST_RW extends SPAR
         Target target = determineTarget(action) ;
         boolean existedBefore = false ;
         try {
-            if ( log.isDebugEnabled() )
-                log.debug("  ->"+target) ;
+            if ( action.log.isDebugEnabled() )
+                action.log.debug("  ->"+target) ;
             existedBefore = target.exists() ; 
             if ( overwrite && existedBefore )
                 clearGraph(target) ;
@@ -201,10 +201,10 @@ public class SPARQL_REST_RW extends SPAR
         int len = action.request.getContentLength() ;
         if ( action.verbose ) {
             if ( len >= 0 )
-                log.info(format("[%d]   Body: Content-Length=%d, Content-Type=%s, Charset=%s => %s", action.id, len,
+                action.log.info(format("[%d]   Body: Content-Length=%d, Content-Type=%s, Charset=%s => %s", action.id, len,
                                 ct.getContentType(), ct.getCharset(), lang.getName())) ;
             else
-                log.info(format("[%d]   Body: Content-Type=%s, Charset=%s => %s", action.id, ct.getContentType(),
+                action.log.info(format("[%d]   Body: Content-Type=%s, Charset=%s => %s", action.id, ct.getContentType(),
                                 ct.getCharset(), lang.getName())) ;
         }
     

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_UberServlet.java Tue Dec  3 15:53:35 2013
@@ -39,7 +39,7 @@ import org.apache.jena.web.HttpSC ;
  *  and acts as a router for all SPARQL operations
  *  (query, update, graph store, both direct and indirect naming). 
  */
-public abstract class SPARQL_UberServlet extends SPARQL_ServletBase
+public abstract class SPARQL_UberServlet extends ActionSPARQL
 {
     protected abstract boolean allowQuery(HttpAction action) ;
     protected abstract boolean allowUpdate(HttpAction action) ;
@@ -93,12 +93,12 @@ public abstract class SPARQL_UberServlet
     // Refactor? Extract the direct naming handling.
     // To test: enable in SPARQLServer.configureOneDataset
     
-    private final SPARQL_ServletBase queryServlet    = new SPARQL_QueryDataset() ;
-    private final SPARQL_ServletBase updateServlet   = new SPARQL_Update() ;
-    private final SPARQL_ServletBase uploadServlet   = new SPARQL_Upload() ;
-    private final SPARQL_REST        restServlet_RW  = new SPARQL_REST_RW() ;
-    private final SPARQL_REST        restServlet_R   = new SPARQL_REST_R() ;
-    private final SPARQL_ServletBase restQuads       = new REST_Quads() ;
+    private final ActionSPARQL queryServlet    = new SPARQL_QueryDataset() ;
+    private final ActionSPARQL updateServlet   = new SPARQL_Update() ;
+    private final ActionSPARQL uploadServlet   = new SPARQL_Upload() ;
+    private final ActionSPARQL restServlet_RW  = new SPARQL_REST_RW() ;
+    private final ActionSPARQL restServlet_R   = new SPARQL_REST_R() ;
+    private final ActionSPARQL restQuads       = new REST_Quads() ;
     
     public SPARQL_UberServlet() { super(); }
 
@@ -162,7 +162,7 @@ public abstract class SPARQL_UberServlet
         if ( ct != null )
             mt = MediaType.create(ct, charset) ;
         
-        log.info(format("[%d] All: %s %s :: '%s' :: %s ? %s", id, method, desc.name, trailing, (mt==null?"<none>":mt), (qs==null?"":qs))) ;
+        action.log.info(format("[%d] All: %s %s :: '%s' :: %s ? %s", id, method, desc.name, trailing, (mt==null?"<none>":mt), (qs==null?"":qs))) ;
                        
         boolean hasTrailing = ( trailing.length() != 0 ) ;
         
@@ -259,14 +259,14 @@ public abstract class SPARQL_UberServlet
        return ;
     }
 
-    private void executeRequest(HttpAction action, SPARQL_ServletBase servlet, ServiceRef service)
+    private void executeRequest(HttpAction action, ActionSPARQL servlet, ServiceRef service)
     {
         if ( service.endpoints.size() == 0 )
             errorMethodNotAllowed(action.request.getMethod()) ;
         servlet.executeLifecycle(action) ;
     }
 
-    private void executeRequest(HttpAction action,SPARQL_ServletBase servlet)
+    private void executeRequest(HttpAction action,ActionSPARQL servlet)
     {
         servlet.executeLifecycle(action) ;
 //      // Forwarded dispatch.
@@ -297,7 +297,7 @@ public abstract class SPARQL_UberServlet
     }
 
     /** return true if dispatched */
-    private boolean serviceDispatch(HttpAction action, ServiceRef service, String srvName , SPARQL_ServletBase servlet)
+    private boolean serviceDispatch(HttpAction action, ServiceRef service, String srvName , ActionSPARQL servlet)
     {
         if ( ! service.endpoints.contains(srvName) )
             return false ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/SPARQL_Update.java Tue Dec  3 15:53:35 2013
@@ -135,7 +135,7 @@ public class SPARQL_Update extends SPARQ
             String charset = request.getCharacterEncoding() ;
             if ( charset != null && ! charset.equalsIgnoreCase(WebContent.charsetUTF8) )
                 errorBadRequest("Bad charset: "+charset) ;
-            validate(request, paramsPOST) ;
+            validate(action, paramsPOST) ;
             return ;
         }
         
@@ -152,23 +152,23 @@ public class SPARQL_Update extends SPARQ
                 requestStr = request.getParameter(paramRequest) ;
             if ( requestStr == null )
                 errorBadRequest("SPARQL Update: No update= in HTML form") ;
-            validate(request, paramsForm) ;
+            validate(action, paramsForm) ;
             return ;
         }
         
         error(HttpSC.UNSUPPORTED_MEDIA_TYPE_415, "Must be "+WebContent.contentTypeSPARQLUpdate+" or "+WebContent.contentTypeForm+" (got "+ctStr+")") ;
     }
     
-    protected void validate(HttpServletRequest request, Collection<String> params)
+    protected void validate(HttpAction action, Collection<String> params)
     {
         if ( params != null )
         {
-            Enumeration<String> en = request.getParameterNames() ;
+            Enumeration<String> en = action.request.getParameterNames() ;
             for ( ; en.hasMoreElements() ; )
             {
                 String name = en.nextElement() ;
                 if ( ! params.contains(name) )
-                    warning("SPARQL Update: Unrecognize request parameter (ignored): "+name) ;
+                    warning(action, "SPARQL Update: Unrecognize request parameter (ignored): "+name) ;
             }
         }
     }

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=1547446&r1=1547445&r2=1547446&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 Tue Dec  3 15:53:35 2013
@@ -22,7 +22,7 @@ import static java.lang.String.format ;
 
 import java.io.IOException ;
 import java.io.InputStream ;
-import java.io.PrintWriter;
+import java.io.PrintWriter ;
 
 import javax.servlet.ServletException ;
 import javax.servlet.http.HttpServletRequest ;
@@ -50,10 +50,8 @@ import com.hp.hpl.jena.graph.NodeFactory
 import com.hp.hpl.jena.sparql.core.Quad ;
 import com.hp.hpl.jena.sparql.graph.GraphFactory ;
 
-public class SPARQL_Upload extends SPARQL_ServletBase 
+public class SPARQL_Upload extends ActionSPARQL 
 {
-    private static ErrorHandler errorHandler = ErrorHandlerFactory.errorHandlerStd(log) ;
-    
     public SPARQL_Upload() {
         super() ;
     }
@@ -126,7 +124,7 @@ public class SPARQL_Upload extends SPARQ
          Graph graphTmp = p.getRight() ;
          long tripleCount = graphTmp.size() ;
 
-         log.info(format("[%d] Upload: Graph: %s (%d triple(s))", 
+         action.log.info(format("[%d] Upload: Graph: %s (%d triple(s))", 
                          action.id, graphName,  tripleCount)) ;
 
          Node gn = graphName.equals(HttpNames.valueDefault)
@@ -211,7 +209,7 @@ public class SPARQL_Upload extends SPARQ
                         graphName = null ;
                     else
                         // Add file type?
-                        log.info(format("[%d] Upload: Field=%s ignored", action.id, fieldName)) ;
+                        action.log.info(format("[%d] Upload: Field=%s ignored", action.id, fieldName)) ;
                 } else {
                     // Process the input stream
                     name = item.getName() ; 
@@ -228,7 +226,7 @@ public class SPARQL_Upload extends SPARQ
                         // Desperate.
                         lang = RDFLanguages.RDFXML ;
 
-                    log.info(format("[%d] Upload: Filename: %s, Content-Type=%s, Charset=%s => %s", 
+                    action.log.info(format("[%d] Upload: Filename: %s, Content-Type=%s, Charset=%s => %s", 
                                     action.id, name,  ct.getContentType(), ct.getCharset(), lang.getName())) ;
                     
                     StreamRDF x = StreamRDFLib.graph(graphTmp) ;

Modified: jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ServletBase.java
URL: http://svn.apache.org/viewvc/jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ServletBase.java?rev=1547446&r1=1547445&r2=1547446&view=diff
==============================================================================
--- jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ServletBase.java (original)
+++ jena/branches/jena-fuseki-new-ui/src/main/java/org/apache/jena/fuseki/servlets/ServletBase.java Tue Dec  3 15:53:35 2013
@@ -30,10 +30,8 @@ import org.apache.jena.atlas.lib.StrUtil
 import org.apache.jena.fuseki.Fuseki ;
 import org.apache.jena.fuseki.HttpNames ;
 import org.apache.jena.web.HttpSC ;
-import org.slf4j.Logger ;
 
 public abstract class ServletBase extends HttpServlet {
-    protected static final Logger log            = Fuseki.requestLog ;
     public final boolean          verboseLogging = Fuseki.verboseLogging ;
     private static AtomicLong     requestIdAlloc = new AtomicLong(0) ;
 
@@ -138,12 +136,12 @@ public abstract class ServletBase extend
         }
     }
 
-    protected static void warning(String string) {
-        log.warn(string) ;
+    protected void warning(HttpAction action, String string) {
+        action.log.warn(string) ;
     }
 
-    protected static void warning(String string, Throwable thorwable) {
-        log.warn(string, thorwable) ;
+    protected void warning(HttpAction action, String string, Throwable thorwable) {
+        action.log.warn(string, thorwable) ;
     }
 
     protected static void errorBadRequest(String string) {