Author: fmui
Date: Sat Apr 16 11:49:44 2011
New Revision: 1093973

URL: http://svn.apache.org/viewvc?rev=1093973&view=rev
Log:
CMIS-356: OpenCMIS server framework sends stacktraces

Added:
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
   (with props)
Modified:
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisBaseException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConnectionException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConstraintException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisContentAlreadyExistsException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisFilterNotValidException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNameConstraintViolationException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNotSupportedException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisObjectNotFoundException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisPermissionDeniedException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisRuntimeException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStorageException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Converter.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
    
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractWebServicesService.java
 Sat Apr 16 11:49:44 2011
@@ -18,8 +18,16 @@
  */
 package org.apache.chemistry.opencmis.client.bindings.spi.webservices;
 
+import java.io.StringWriter;
 import java.math.BigInteger;
 
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
 import org.apache.chemistry.opencmis.client.bindings.spi.Session;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import 
org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
@@ -36,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 import 
org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
 import 
org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisException;
+import org.w3c.dom.Node;
 
 /**
  * Base class for all Web Services clients.
@@ -69,35 +78,67 @@ public abstract class AbstractWebService
         String msg = ex.getFaultInfo().getMessage();
         BigInteger code = ex.getFaultInfo().getCode();
 
+        String errorContent = null;
+        if (ex.getFaultInfo().getAny().size() > 0) {
+            StringBuilder sb = new StringBuilder();
+            for (Object o : ex.getFaultInfo().getAny()) {
+                if (o != null) {
+                    if (o instanceof Node) {
+                        sb.append(getNodeAsString((Node) o));
+                    } else {
+                        sb.append(o.toString());
+                    }
+                    sb.append('\n');
+                }
+            }
+            errorContent = sb.toString();
+        }
+
         switch (ex.getFaultInfo().getType()) {
         case CONSTRAINT:
-            return new CmisConstraintException(msg, code);
+            return new CmisConstraintException(msg, code, errorContent);
         case CONTENT_ALREADY_EXISTS:
-            return new CmisContentAlreadyExistsException(msg, code);
+            return new CmisContentAlreadyExistsException(msg, code, 
errorContent);
         case FILTER_NOT_VALID:
-            return new CmisFilterNotValidException(msg, code);
+            return new CmisFilterNotValidException(msg, code, errorContent);
         case INVALID_ARGUMENT:
-            return new CmisInvalidArgumentException(msg, code);
+            return new CmisInvalidArgumentException(msg, code, errorContent);
         case NAME_CONSTRAINT_VIOLATION:
-            return new CmisNameConstraintViolationException(msg, code);
+            return new CmisNameConstraintViolationException(msg, code, 
errorContent);
         case NOT_SUPPORTED:
-            return new CmisNotSupportedException(msg, code);
+            return new CmisNotSupportedException(msg, code, errorContent);
         case OBJECT_NOT_FOUND:
-            return new CmisObjectNotFoundException(msg, code);
+            return new CmisObjectNotFoundException(msg, code, errorContent);
         case PERMISSION_DENIED:
-            return new CmisPermissionDeniedException(msg, code);
+            return new CmisPermissionDeniedException(msg, code, errorContent);
         case RUNTIME:
-            return new CmisRuntimeException(msg, code);
+            return new CmisRuntimeException(msg, code, errorContent);
         case STORAGE:
-            return new CmisStorageException(msg, code);
+            return new CmisStorageException(msg, code, errorContent);
         case STREAM_NOT_SUPPORTED:
-            return new CmisStreamNotSupportedException(msg, code);
+            return new CmisStreamNotSupportedException(msg, code, 
errorContent);
         case UPDATE_CONFLICT:
-            return new CmisUpdateConflictException(msg, code);
+            return new CmisUpdateConflictException(msg, code, errorContent);
         case VERSIONING:
-            return new CmisVersioningException(msg, code);
+            return new CmisVersioningException(msg, code, errorContent);
         }
 
         return new CmisRuntimeException("Unknown exception[" + 
ex.getFaultInfo().getType().value() + "]: " + msg);
     }
+
+    private String getNodeAsString(Node node) {
+        try {
+            TransformerFactory factory = TransformerFactory.newInstance();
+            Transformer transformrt = factory.newTransformer();
+            transformrt.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, 
"yes");
+            // transformrt.setOutputProperty(OutputKeys.INDENT, "yes");
+
+            StringWriter sw = new StringWriter();
+            transformrt.transform(new DOMSource(node), new StreamResult(sw));
+            return sw.toString();
+        } catch (TransformerException e) {
+        }
+
+        return "";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisBaseException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisBaseException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisBaseException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisBaseException.java
 Sat Apr 16 11:49:44 2011
@@ -88,6 +88,22 @@ public abstract class CmisBaseException 
      * 
      * @param message
      *            error message
+     * @param code
+     *            error code
+     * @param errorContent
+     *            error page content
+     */
+    public CmisBaseException(String message, BigInteger code, String 
errorContent) {
+        super(message);
+        this.code = code;
+        this.errorContent = errorContent;
+    }
+
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
      * @param errorContent
      *            error page content
      */
@@ -139,4 +155,9 @@ public abstract class CmisBaseException 
     public String getErrorContent() {
         return errorContent;
     }
+
+    /**
+     * Returns the name of the exception as defined in the CMIS specification.
+     */
+    public abstract String getExceptionName();
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConnectionException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConnectionException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConnectionException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConnectionException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisConnectionException ext
         super(message, code);
     }
 
+    public CmisConnectionException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisConnectionException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisConnectionException ext
     public CmisConnectionException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "connection";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConstraintException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConstraintException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConstraintException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisConstraintException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisConstraintException ext
         super(message, code);
     }
 
+    public CmisConstraintException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisConstraintException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisConstraintException ext
     public CmisConstraintException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "constraint";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisContentAlreadyExistsException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisContentAlreadyExistsException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisContentAlreadyExistsException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisContentAlreadyExistsException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisContentAlreadyExistsExc
         super(message, code);
     }
 
+    public CmisContentAlreadyExistsException(String message, BigInteger code, 
String errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisContentAlreadyExistsException(String message, String 
errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisContentAlreadyExistsExc
     public CmisContentAlreadyExistsException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "contentAlreadyExists";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisFilterNotValidException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisFilterNotValidException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisFilterNotValidException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisFilterNotValidException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisFilterNotValidException
         super(message, code);
     }
 
+    public CmisFilterNotValidException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisFilterNotValidException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisFilterNotValidException
     public CmisFilterNotValidException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "filterNotValid";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisInvalidArgumentException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisInvalidArgumentExceptio
         super(message, code);
     }
 
+    public CmisInvalidArgumentException(String message, BigInteger code, 
String errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisInvalidArgumentException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisInvalidArgumentExceptio
     public CmisInvalidArgumentException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "invalidArgument";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNameConstraintViolationException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNameConstraintViolationException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNameConstraintViolationException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNameConstraintViolationException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisNameConstraintViolation
         super(message, code);
     }
 
+    public CmisNameConstraintViolationException(String message, BigInteger 
code, String errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisNameConstraintViolationException(String message, String 
errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisNameConstraintViolation
     public CmisNameConstraintViolationException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "nameConstraintViolation";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNotSupportedException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNotSupportedException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNotSupportedException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisNotSupportedException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisNotSupportedException e
         super(message, code);
     }
 
+    public CmisNotSupportedException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisNotSupportedException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisNotSupportedException e
     public CmisNotSupportedException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "notSupported";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisObjectNotFoundException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisObjectNotFoundException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisObjectNotFoundException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisObjectNotFoundException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisObjectNotFoundException
         super(message, code);
     }
 
+    public CmisObjectNotFoundException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisObjectNotFoundException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisObjectNotFoundException
     public CmisObjectNotFoundException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "objectNotFound";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisPermissionDeniedException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisPermissionDeniedException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisPermissionDeniedException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisPermissionDeniedException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisPermissionDeniedExcepti
         super(message, code);
     }
 
+    public CmisPermissionDeniedException(String message, BigInteger code, 
String errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisPermissionDeniedException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisPermissionDeniedExcepti
     public CmisPermissionDeniedException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "permissionDenied";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisRuntimeException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisRuntimeException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisRuntimeException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisRuntimeException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisRuntimeException extend
         super(message, code);
     }
 
+    public CmisRuntimeException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisRuntimeException(String message, String errorContent, Throwable 
cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisRuntimeException extend
     public CmisRuntimeException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "runtime";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStorageException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStorageException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStorageException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStorageException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisStorageException extend
         super(message, code);
     }
 
+    public CmisStorageException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisStorageException(String message, String errorContent, Throwable 
cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisStorageException extend
     public CmisStorageException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "storage";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisStreamNotSupportedExcep
         super(message, code);
     }
 
+    public CmisStreamNotSupportedException(String message, BigInteger code, 
String errorContent) {
+        super(message, code, errorContent);
+    }
+    
     public CmisStreamNotSupportedException(String message, String 
errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisStreamNotSupportedExcep
     public CmisStreamNotSupportedException(String message) {
         super(message, BigInteger.ZERO);
     }
+    
+    @Override
+    public String getExceptionName() {
+        return "streamNotSupported";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisUpdateConflictException
         super(message, code);
     }
 
+    public CmisUpdateConflictException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisUpdateConflictException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisUpdateConflictException
     public CmisUpdateConflictException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "updateConflict";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java
 Sat Apr 16 11:49:44 2011
@@ -43,6 +43,10 @@ public class CmisVersioningException ext
         super(message, code);
     }
 
+    public CmisVersioningException(String message, BigInteger code, String 
errorContent) {
+        super(message, code, errorContent);
+    }
+
     public CmisVersioningException(String message, String errorContent, 
Throwable cause) {
         super(message, errorContent, cause);
     }
@@ -54,4 +58,9 @@ public class CmisVersioningException ext
     public CmisVersioningException(String message) {
         super(message, BigInteger.ZERO);
     }
+
+    @Override
+    public String getExceptionName() {
+        return "versioning";
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Converter.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Converter.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Converter.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Converter.java
 Sat Apr 16 11:49:44 2011
@@ -239,7 +239,7 @@ import com.sun.xml.ws.developer.Streamin
  */
 public final class Converter {
 
-    private static final String DEFAULT_EXTENSION_NS = 
"http://apache.org/chemistry/opencmis";;
+    private static final String DEFAULT_EXTENSION_NS = 
"http://chemistry.apache.org/opencmis/extension";;
 
     /**
      * Private constructor.
@@ -2270,7 +2270,7 @@ public final class Converter {
     public static Acl convert(CmisACLType acl) {
         if (acl == null)
             return null;
-        
+
         Acl result = convert(acl.getACL(), acl.isExact());
 
         // handle extensions

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
 Sat Apr 16 11:49:44 2011
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.server.impl.atompub;
 
 import java.io.IOException;
+import java.io.PrintWriter;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
@@ -46,6 +47,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
 import org.apache.chemistry.opencmis.server.shared.CallContextHandler;
 import org.apache.chemistry.opencmis.server.shared.Dispatcher;
+import org.apache.chemistry.opencmis.server.shared.ExceptionHelper;
 import org.apache.chemistry.opencmis.server.shared.HttpUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -158,8 +160,8 @@ public class CmisAtomPubServlet extends 
         // create a context object, dispatch and handle exceptions
         CallContext context = null;
         try {
-            context = HttpUtils.createContext(request, getServletContext(),
-                    CallContext.BINDING_ATOMPUB, callContextHandler);
+            context = HttpUtils.createContext(request, getServletContext(), 
CallContext.BINDING_ATOMPUB,
+                    callContextHandler);
             dispatch(context, request, response);
         } catch (Exception e) {
             if (e instanceof CmisPermissionDeniedException) {
@@ -169,14 +171,8 @@ public class CmisAtomPubServlet extends 
                 } else {
                     
response.sendError(getErrorCode((CmisPermissionDeniedException) e), 
e.getMessage());
                 }
-            } else if (e instanceof CmisRuntimeException) {
-                LOG.error(e.getMessage(), e);
-                response.sendError(getErrorCode((CmisRuntimeException) e), 
e.getMessage());
-            } else if (e instanceof CmisBaseException) {
-                response.sendError(getErrorCode((CmisBaseException) e), 
e.getMessage());
             } else {
-                LOG.error(e.getMessage(), e);
-                
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 
e.getMessage());
+                printError(e, response);
             }
         }
 
@@ -264,4 +260,47 @@ public class CmisAtomPubServlet extends 
 
         return 500;
     }
+
+    /**
+     * Prints the error HTML page.
+     */
+    private void printError(Exception ex, HttpServletResponse response) {
+        int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
+        String exceptionName = "runtime";
+
+        if (ex instanceof CmisRuntimeException) {
+            LOG.error(ex.getMessage(), ex);
+        } else if (ex instanceof CmisBaseException) {
+            statusCode = getErrorCode((CmisBaseException) ex);
+            exceptionName = ((CmisBaseException) ex).getExceptionName();
+        } else {
+            LOG.error(ex.getMessage(), ex);
+        }
+
+        try {
+            PrintWriter pw = response.getWriter();
+            response.setStatus(statusCode);
+            response.setContentType("text/html");
+            
+            pw.print("<html><head><title>Apache Chemistry OpenCMIS - " + 
exceptionName + " error</title>"
+                    + "<style><!--H1 
{font-size:24px;line-height:normal;font-weight:bold;background-color:#f0f0f0;color:#003366;border-bottom:1px
 solid #3c78b5;padding:2px;} "
+                    + "BODY 
{font-family:Verdana,arial,sans-serif;color:black;font-size:14px;} "
+                    + "HR 
{color:#3c78b5;height:1px;}--></style></head><body>");
+            pw.print("<h1>HTTP Status " + statusCode + " - <!--exception-->" + 
exceptionName + "<!--/exception--></h1>");
+            pw.print("<p><!--message-->" + ex.getMessage() + 
"<!--/message--></p>");
+
+            String st = ExceptionHelper.getStacktraceAsString(ex);
+            if (st != null) {
+                pw.print("<hr noshade='noshade'/><!--stacktrace--><pre>\n" + 
st + "\n</pre><!--/stacktrace--><hr noshade='noshade'/>");
+            }
+
+            pw.print("</body></html>");
+        } catch (Exception e) {
+            LOG.error(e.getMessage(), e);
+            try {
+                response.sendError(statusCode, ex.getMessage());
+            } catch (Exception en) {
+            }
+        }
+    }
 }

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1093973&r1=1093972&r2=1093973&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
 Sat Apr 16 11:49:44 2011
@@ -48,6 +48,8 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
 import org.apache.chemistry.opencmis.server.impl.CallContextImpl;
 import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
+import org.apache.chemistry.opencmis.server.shared.ExceptionHelper;
+import org.w3c.dom.Node;
 
 /**
  * This class contains operations used by all services.
@@ -178,6 +180,11 @@ public abstract class AbstractService {
             } else if (ex instanceof CmisVersioningException) {
                 fault.setType(EnumServiceException.VERSIONING);
             }
+
+            Node node = ExceptionHelper.getStacktraceAsNode(ex);
+            if (node != null) {
+                fault.getAny().add(node);
+            }
         }
 
         return new CmisException(fault.getMessage(), fault, ex);

Added: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java?rev=1093973&view=auto
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
 (added)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
 Sat Apr 16 11:49:44 2011
@@ -0,0 +1,80 @@
+/*
+ * 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.chemistry.opencmis.server.shared;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ExceptionHelper {
+
+    public static final String STACK_TRACE_PROPERTY = 
"org.apache.chemistry.opencmis.stacktrace.disable";
+
+    private static boolean sendStackTrace;
+
+    static {
+        sendStackTrace = System.getProperty(STACK_TRACE_PROPERTY) == null;
+    }
+
+    /**
+     * Returns the stack trace as string.
+     */
+    public static String getStacktraceAsString(Throwable t) {
+        if (!sendStackTrace || t == null) {
+            return null;
+        }
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+
+        t.printStackTrace(pw);
+
+        return sw.toString();
+    }
+
+    /**
+     * Returns the stack trace as DOM node.
+     */
+    public static Node getStacktraceAsNode(Exception ex) {
+        try {
+            String st = getStacktraceAsString(ex);
+            if (st != null) {
+                DocumentBuilderFactory dbfac = 
DocumentBuilderFactory.newInstance();
+                DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+                Document doc = docBuilder.newDocument();
+
+                Element node = 
doc.createElementNS("http://chemistry.apache.org/opencmis/exception";, 
"stacktrace");
+                doc.appendChild(node);
+
+                node.appendChild(doc.createTextNode(st));
+
+                return node;
+            }
+        } catch (Exception e) {
+        }
+
+        return null;
+    }
+}

Propchange: 
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ExceptionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to