svn commit: r575065 - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: control/ControlServlet.java control/RequestHandler.java event/ServiceStreamHandler.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r575065 - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: control/ControlServlet.java control/RequestHandler.java event/ServiceStreamHandler.java

jaz-3
Author: jaz
Date: Wed Sep 12 13:31:44 2007
New Revision: 575065

URL: http://svn.apache.org/viewvc?rev=575065&view=rev
Log:
turned off logging from testing the server hit/visit bypass functionality; added code to send back errors to the stream handler

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=575065&r1=575064&r2=575065&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Wed Sep 12 13:31:44 2007
@@ -283,8 +283,6 @@
                 VisitHandler.getVisitor(request, response);
                 if (requestHandler.trackStats(request)) {
                     ServerHitBin.countRequest(webappName + "." + rname, request, requestStartTime, System.currentTimeMillis() - requestStartTime, userLogin, delegator);
-                } else {
-                    Debug.log("Track status is disabled for this request");
                 }
             } catch (Throwable t) {
                 Debug.logError(t, "Error in ControlServlet saving ServerHit/Bin information; the output was successful, but can't save this tracking information. The error was: " + t.toString(), module);

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=575065&r1=575064&r2=575065&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Wed Sep 12 13:31:44 2007
@@ -159,8 +159,10 @@
                 if (clientCerts == null) {
                     throw new RequestHandlerException("Unknown request [" + requestUri + "]; this request does not exist or cannot be called directly.");
                 } else {
-                    for (int i = 0; i < clientCerts.length; i++) {
-                        Debug.logInfo(clientCerts[i].getSubjectX500Principal().getName(), module);
+                    if (Debug.infoOn()) {
+                        for (int i = 0; i < clientCerts.length; i++) {
+                            Debug.logInfo(clientCerts[i].getSubjectX500Principal().getName(), module);
+                        }
                     }
                   
                     // check if this is a trusted cert
@@ -177,7 +179,8 @@
 
             // If its the first visit run the first visit events.
             if (this.trackVisit(request) && session.getAttribute("visit") == null) {
-                Debug.logInfo("This is the first request in this visit." + " sessionId=" + UtilHttp.getSessionId(request), module);
+                if (Debug.infoOn())
+                    Debug.logInfo("This is the first request in this visit." + " sessionId=" + UtilHttp.getSessionId(request), module);
                 // This isn't an event because it is required to run. We do not want to make it optional.
                 GenericValue visit = VisitHandler.getVisit(session);
                 Collection events = requestManager.getFirstVisitEvents();
@@ -203,8 +206,6 @@
                         }
                     }
                 }
-            } else {
-                Debug.log("Track visit is disabled for this request");
             }
 
             // Invoke the pre-processor (but NOT in a chain)
@@ -279,9 +280,10 @@
                     eventReturnString = this.runEvent(request, response, eventType, eventPath, eventMethod);
 
                     // save the server hit
-                    if (this.trackStats(request))
+                    if (this.trackStats(request)) {
                         ServerHitBin.countEvent(cname + "." + eventMethod, request, eventStartTime,
                                 System.currentTimeMillis() - eventStartTime, userLogin, delegator);
+                    }
 
                     // set the default event return
                     if (eventReturnString == null) {

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java?rev=575065&r1=575064&r2=575065&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java Wed Sep 12 13:31:44 2007
@@ -68,15 +68,18 @@
         context.put("inputStream", in);
         context.put("outputStream", out);
 
-        Debug.log("Running service with context: " + context, module);
+        if (Debug.infoOn()) Debug.logInfo("Running service with context: " + context, module);
+        
         Map resp;
         try {
             resp = dispatcher.runSync(eventMethod, context);
         } catch (GenericServiceException e) {
+            outputError(out, e, "Exception thrown in runSync()");
             throw new EventHandlerException(e.getMessage(), e);
         }
         Debug.log("Received respone: " + resp, module);
         if (ServiceUtil.isError(resp)) {
+            outputError(out, null, ServiceUtil.getErrorMessage(resp));
             throw new EventHandlerException(ServiceUtil.getErrorMessage(resp));
         }
         String contentType = (String) resp.get("contentType");
@@ -93,5 +96,20 @@
         }
         
         return null;
+    }
+
+    private void outputError(OutputStream stream, Exception error, String message) {
+        PrintStream out = new PrintStream(stream);
+        if (message != null)
+            out.println("Error message: " + message);
+        if (error != null)
+            out.println("Exception occured: " + error.toString());
+        out.flush();
+        out.close();
+        try {
+            stream.close();
+        } catch (IOException e) {
+            Debug.logError(e, module);
+        }
     }
 }