[jboss-svn-commits] JBL Code SVN: r24195 - labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Dec 2 02:36:36 EST 2008


Author: michael.neale at jboss.com
Date: 2008-12-02 02:36:36 -0500 (Tue, 02 Dec 2008)
New Revision: 24195

Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/RepositoryServiceServlet.java
Log:
JBRULES-1859 Error handling

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/RepositoryServiceServlet.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/RepositoryServiceServlet.java	2008-12-02 06:23:37 UTC (rev 24194)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/RepositoryServiceServlet.java	2008-12-02 07:36:36 UTC (rev 24195)
@@ -6,10 +6,13 @@
 
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.log4j.Logger;
 import org.drools.guvnor.client.rpc.DetailedSerializableException;
 import org.drools.guvnor.client.rpc.RepositoryService;
+import org.drools.guvnor.server.util.LoggingHelper;
 import org.drools.guvnor.server.util.TestEnvironmentSessionHelper;
 import org.drools.repository.RulesRepository;
+import org.drools.repository.RulesRepositoryException;
 import org.jboss.seam.Component;
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.security.AuthorizationException;
@@ -18,13 +21,13 @@
 import com.google.gwt.user.server.rpc.RemoteServiceServlet;
 
 /**
- * GWT RPC service endpoint for Repository service.
+ * GWT RPC service endpoint for Repository service. A place to hang some exception handling, but mostly just passing on through.
  *
  * @author Michael Neale
  */
 public class RepositoryServiceServlet extends RemoteServiceServlet implements RepositoryService {
 
-
+    private static final Logger     log              = LoggingHelper.getLogger();
 	/**
 	 * This is used by the pass through methods below.
 	 * Michael got tired of trying to read other peoples overly abstracted code, so its just generated dumb code to
@@ -46,6 +49,7 @@
 		if (e.getCause() instanceof AuthorizationException) {
 			HttpServletResponse response = getThreadLocalResponse();
 		    try {
+		      log.error(e.getCause());
 		      response.setContentType("text/plain");
 		      response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
 		      response.getWriter().write("Sorry, insufficient permissions to perform this action.");
@@ -54,6 +58,19 @@
 		          "respondWithUnexpectedFailure failed while sending the previous failure to the client",
 		          ex);
 		    }
+		} else if (e.getCause() instanceof RulesRepositoryException) {
+			log.error(e.getCause());
+			HttpServletResponse response = getThreadLocalResponse();
+		      response.setContentType("text/plain");
+		      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+		      try {
+		    	  response.getWriter().write(e.getCause().getMessage());
+		      } catch (IOException ex) {
+			      getServletContext().log(
+				          "respondWithUnexpectedFailure failed while sending the previous failure to the client",
+				          ex);
+		      }
+
 		} else {
 				super.doUnexpectedFailure(e);
 		}




More information about the jboss-svn-commits mailing list