You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wsrp4j-dev@portals.apache.org by dl...@apache.org on 2006/12/05 01:03:25 UTC

svn commit: r482417 - in /portals/wsrp4j/trunk/consumer-proxyportlet/src: java/org/apache/wsrp4j/consumer/configportlet/controller/ java/org/apache/wsrp4j/consumer/configportlet/exception/ java/org/apache/wsrp4j/consumer/configportlet/model/delegate/im...

Author: dlouzan
Date: Mon Dec  4 16:03:23 2006
New Revision: 482417

URL: http://svn.apache.org/viewvc?view=rev&rev=482417
Log:
Modified exception handling

Modified:
    portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java
    portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/ProducerRegistryConfigPortlet.java
    portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/exception/ConfigPortletException.java
    portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java
    portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java
    portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/DeployPortletConfigPortlet.java Mon Dec  4 16:03:23 2006
@@ -90,6 +90,8 @@
             
             /* A processAction() exception occured */
             if (action.equals(Constants.ACTION_EXCEPTION)) {
+                request.setAttribute(Constants.ATTR_EXCEPTION,
+                        request.getParameter(Constants.PARAM_EXCEPTION));
                 PortletUtils.delegateToJSP(request, response,
                         getPortletContext(), "/jsp/configportlet/errorPage.jsp");
             } else if ((action.equals("")) || 
@@ -113,9 +115,6 @@
             
         } catch (ConfigPortletException e) {
             handleRenderException(request, response, e);
-            if (log.isDebugEnabled()) {
-                log.debug(e);
-            }
         }
         
         if (log.isDebugEnabled()) {
@@ -146,9 +145,6 @@
             }
         } catch (ConfigPortletException e) {
             handleProcessActionException(request, response, e);
-            if (log.isDebugEnabled()) {
-                log.debug(e);
-            }
         }
         
         if (log.isDebugEnabled()) {
@@ -160,6 +156,7 @@
     private void handleRenderException(RenderRequest request, 
             RenderResponse response, ConfigPortletException e)
     throws PortletException, IOException {
+        log.error(e.getMessage());
         request.setAttribute(Constants.ATTR_EXCEPTION, e.toHTMLString());
         PortletUtils.delegateToJSP(request, response, 
                 getPortletContext(), "/jsp/configportlet/errorPage.jsp");
@@ -167,6 +164,7 @@
     
     private void handleProcessActionException(ActionRequest request, 
             ActionResponse response, ConfigPortletException e) {
+        log.error(e.getMessage());
         response.setRenderParameter(Constants.PARAM_ACTION, Constants.ACTION_EXCEPTION);
         response.setRenderParameter(Constants.PARAM_EXCEPTION, e.toHTMLString());
     }

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/ProducerRegistryConfigPortlet.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/ProducerRegistryConfigPortlet.java?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/ProducerRegistryConfigPortlet.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/controller/ProducerRegistryConfigPortlet.java Mon Dec  4 16:03:23 2006
@@ -102,6 +102,8 @@
 
             /* A processAction() exception occured */
             if (action.equals(Constants.ACTION_EXCEPTION)) {
+                request.setAttribute(Constants.ATTR_EXCEPTION,
+                        request.getParameter(Constants.PARAM_EXCEPTION));
                 PortletUtils.delegateToJSP(request, response, 
                         getPortletContext(), "/jsp/configportlet/errorPage.jsp");
             } else if ((action.equals("")) || 
@@ -177,6 +179,7 @@
     private void handleRenderException(RenderRequest request, 
             RenderResponse response, ConfigPortletException e)
     throws PortletException, IOException {
+        log.error(e.getMessage());
         request.setAttribute(Constants.ATTR_EXCEPTION, e.toHTMLString());
         PortletUtils.delegateToJSP(request, response, 
                 getPortletContext(), "/jsp/configportlet/errorPage.jsp");
@@ -184,6 +187,7 @@
     
     private void handleProcessActionException(ActionRequest request, 
             ActionResponse response, ConfigPortletException e) {
+        log.error(e.getMessage());
         response.setRenderParameter(Constants.PARAM_ACTION, Constants.ACTION_EXCEPTION);
         response.setRenderParameter(Constants.PARAM_EXCEPTION, e.toHTMLString());
     }

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/exception/ConfigPortletException.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/exception/ConfigPortletException.java?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/exception/ConfigPortletException.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/exception/ConfigPortletException.java Mon Dec  4 16:03:23 2006
@@ -18,51 +18,45 @@
 import java.io.PrintStream;
 import java.io.PrintWriter;
 
-import org.apache.wsrp4j.commons.exception.WSRPException;
-
-
-public class ConfigPortletException extends Exception {
+import org.apache.commons.lang.exception.NestableException;
 
-    private Exception encapsulatedException;
+import org.apache.wsrp4j.commons.exception.WSRPException;
 
-    public ConfigPortletException(Exception exception) {
-        encapsulatedException = exception;
-    }
 
-    public String getMessage() {
-        return encapsulatedException.getMessage();
-    }
+public class ConfigPortletException extends NestableException {
 
-    public Exception getEncapsulatedException() {
-        return encapsulatedException;
+    public ConfigPortletException(Throwable throwable) {
+        super(throwable);
     }
     
-    public void printStackTrace() {
-        printStackTrace(System.err);
-    }
-    
-    public void printStackTrace(PrintStream printStream) {
-        super.printStackTrace(printStream);
-        printStream.println("***Information about encapsulated exception***");
-        encapsulatedException.printStackTrace(printStream);
-    }
-    
-    public void printStackTrace(PrintWriter printWriter) {
-        super.printStackTrace(printWriter);
-        printWriter.println("***Information about encapsulated exception***");
-        encapsulatedException.printStackTrace(printWriter);
+    public ConfigPortletException(String message, Throwable t) {
+        super(message, t);
     }
     
     public String toHTMLString() {
         
-        if (encapsulatedException instanceof WSRPException) {
-            return ((WSRPException) encapsulatedException).toHTMLString();
-        } else {
-            StringBuffer sb = new StringBuffer();
-            sb.append("<div class='portlet-font'>" + 
-                    encapsulatedException.getMessage() + "</div>");
-            return sb.toString();
+        StringBuffer sb = new StringBuffer();
+        sb.append("<div class='portlet-section-subheader'>" + 
+                this.getClass().getName() + "</div>");
+        sb.append("<div class='portlet-font'>Message = " + 
+                getMessage() + "</div>");
+        
+        if (getCause() != null) {
+            Throwable t = getCause();
+            sb.append("<div class='portlet-section-subheader'>" +
+                    "Exception stack:</div>");
+            while (t != null) {
+                sb.append("<div class='portlet-font'>" + 
+                        t.getMessage() + "</div>");
+                if (t instanceof NestableException) {
+                    t = t.getCause();
+                } else {
+                    t = null;
+                }
+            }
         }
+        
+        return sb.toString();
         
     }
     

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/configportlet/model/delegate/impl/DeployPortletDelegateImpl.java Mon Dec  4 16:03:23 2006
@@ -34,6 +34,7 @@
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
@@ -491,10 +492,19 @@
             
             transformer.transform(src, dest);
             
+        } catch (TransformerFactoryConfigurationError e) {
+            /* Probably an xml processor not found */
+            log.error(e);
+            throw new ConfigPortletException(
+                    "Error while instantiating xml engine", e);
         } catch (TransformerConfigurationException e) {
-            throw new ConfigPortletException(e);
+            log.error(e);
+            throw new ConfigPortletException(
+                    "Error in the xml transformer configuration", e);
         } catch (TransformerException e) {
-            throw new ConfigPortletException(e);
+            log.error(e);
+            throw new ConfigPortletException(
+                    "Error while transforming the xml tree", e);
         }
         
     }

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/java/org/apache/wsrp4j/consumer/proxyportlet/impl/ProxyPortlet.java Mon Dec  4 16:03:23 2006
@@ -342,7 +342,6 @@
             
         } catch (WSRPException e) {
             handleProcessActionException(request, actionResponse, e);
-            log.error(e);
         } finally {
             if (log.isDebugEnabled()) {
                 log.debug(Utility.strExit(MN));
@@ -381,6 +380,8 @@
         String actionParam = request.getParameter(Constants.PROXYPORTLET_PARAM_ACTION);
         String action = (actionParam == null) ? new String() : actionParam;
         if (action.equals(Constants.PROXYPORTLET_ACTION_EXCEPTION)) {
+            request.setAttribute(Constants.PROXYPORTLET_ATTR_EXCEPTION,
+                    request.getParameter(Constants.PROXYPORTLET_PARAM_EXCEPTION));
             PortletUtils.delegateToJSP(request, renderResponse,
                     getPortletContext(), "/jsp/proxyportlet/errorPage.jsp");
         }
@@ -464,7 +465,6 @@
             
         } catch (WSRPException e) {
             handleRenderException(request, renderResponse, e);
-            log.error(e);
         }
 
         if (log.isDebugEnabled()) {
@@ -788,6 +788,7 @@
     private void handleRenderException(RenderRequest request, 
             RenderResponse response, WSRPException e)
     throws PortletException, IOException {
+        log.error(e.getMessage());
         request.setAttribute(Constants.PROXYPORTLET_ATTR_EXCEPTION, 
                 e.toHTMLString());
         PortletUtils.delegateToJSP(request, response, 
@@ -796,6 +797,7 @@
     
     private void handleProcessActionException(ActionRequest request, 
             ActionResponse response, WSRPException e) {
+        log.error(e.getMessage());
         response.setRenderParameter(Constants.PROXYPORTLET_PARAM_ACTION, 
                 Constants.PROXYPORTLET_ACTION_EXCEPTION);
         response.setRenderParameter(Constants.PROXYPORTLET_PARAM_EXCEPTION, 

Modified: portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties
URL: http://svn.apache.org/viewvc/portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties?view=diff&rev=482417&r1=482416&r2=482417
==============================================================================
--- portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties (original)
+++ portals/wsrp4j/trunk/consumer-proxyportlet/src/resources/Messages.properties Mon Dec  4 16:03:23 2006
@@ -15,7 +15,7 @@
 Alert.deleteProducer=Are you sure you want to delete this producer?
 Alert.deletePortlet=Are you sure you want to delete this portlet?
 
-Error.exceptionNotFound=Exception Object Not Found
+Error.exceptionNotFound=Exception Not Found
 Error.exceptionThrown=Exception Thrown
 Error.noPortletsFound=No Deployed Portlets Found
 Error.noProducersFound=No Producers Found