[portal-commits] JBoss Portal SVN: r8934 - branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Nov 14 18:20:06 EST 2007


Author: chris.laprun at jboss.com
Date: 2007-11-14 18:20:06 -0500 (Wed, 14 Nov 2007)
New Revision: 8934

Modified:
   branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
Log:
- JBPORTAL-1167: Improved error creation so that WSRP faults are properly de-serialized on the client... However, this causes extra information to be lost...

Modified: branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java	2007-11-14 21:08:03 UTC (rev 8933)
+++ branches/JBoss_Portal_Branch_2_6/wsrp/src/main/org/jboss/portal/wsrp/WSRPExceptionFactory.java	2007-11-14 23:20:06 UTC (rev 8934)
@@ -40,7 +40,7 @@
 public class WSRPExceptionFactory
 {
 
-   private static final String NS = "urn:oasis:names:tc:wsrp:c1:types";
+   private static final String NS = "urn:oasis:names:tc:wsrp:v1:types";
 
    public static final String ACCESS_DENIED = "AccessDenied";
    public static final String INCONSISTENT_PARAMETERS = "InconsistentParameters";
@@ -56,6 +56,7 @@
    public static final String UNSUPPORTED_MIME_TYPE = "UnsupportedMimeType";
    public static final String UNSUPPORTED_MODE = "UnsupportedMode";
    public static final String UNSUPPORTED_WINDOW_STATE = "UnsupportedWindowState";
+   private static final String NS_PREFIX = "wsrp";
 
    public static void throwMissingParametersFaultIfValueIsMissing(Object valueToCheck, String valueName, String context)
       throws SOAPFaultException
@@ -88,8 +89,14 @@
       {
          try
          {
-            detail = SOAPFactory.newInstance().createDetail();
-            detail.addChildElement("cause").addTextNode(cause.getLocalizedMessage());
+            SOAPFactory soapFactory = SOAPFactory.newInstance();
+            detail = soapFactory.createDetail();
+
+            // using a DetailEntry with the proper errorCode and NS will cause JBossWS to create a user created exception
+            // for ex: errorCode == InvalidRegistration => InvalidRegistrationFault on the client side...
+            // however, due to the crappy nature of faults in WSRP, this is highly uninformative as all extra information
+            // is not propagated once the user exception is created :(
+            detail.addDetailEntry(soapFactory.createName(errorCode, NS_PREFIX, NS));
          }
          catch (SOAPException e)
          {
@@ -101,9 +108,14 @@
       HttpServletRequest req = ServletAccess.getRequest();
       if (req != null)
       {
-         actor = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + "/" + req.getServletPath();
+         actor = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + req.getContextPath() + req.getServletPath();
       }
 
+      String causeMessage = cause.getLocalizedMessage();
+      if (causeMessage != null)
+      {
+         message += " " + causeMessage;
+      }
 
       return new SOAPFaultException(new QName(NS, errorCode), message, actor, detail);
    }




More information about the portal-commits mailing list