You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2014/07/24 18:31:31 UTC
svn commit: r1613180 - in
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl:
atompub/ browser/ webservices/
Author: fmui
Date: Thu Jul 24 16:31:31 2014
New Revision: 1613180
URL: http://svn.apache.org/r1613180
Log:
OpenCMIS Server: don't disclose details about programming errors and infrastructure problems to the clients
Modified:
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/browser/CmisBrowserBindingServlet.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-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=1613180&r1=1613179&r2=1613180&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 Thu Jul 24 16:31:31 2014
@@ -302,6 +302,11 @@ public class CmisAtomPubServlet extends
return;
}
+ String message = ex.getMessage();
+ if (!(ex instanceof CmisBaseException)) {
+ message = "An error occurred!";
+ }
+
try {
response.resetBuffer();
response.setStatus(statusCode);
@@ -317,7 +322,7 @@ public class CmisAtomPubServlet extends
+ "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-->" + StringEscapeUtils.escapeHtml(ex.getMessage()) + "<!--/message--></p>");
+ pw.print("<p><!--message-->" + StringEscapeUtils.escapeHtml(message) + "<!--/message--></p>");
String st = ExceptionHelper.getStacktraceAsString(ex);
if (st != null) {
@@ -329,7 +334,7 @@ public class CmisAtomPubServlet extends
} catch (Exception e) {
LOG.error(e.getMessage(), e);
try {
- response.sendError(statusCode, ex.getMessage());
+ response.sendError(statusCode, message);
} catch (Exception en) {
// there is nothing else we can do
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.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/browser/CmisBrowserBindingServlet.java?rev=1613180&r1=1613179&r2=1613180&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Thu Jul 24 16:31:31 2014
@@ -458,9 +458,14 @@ public class CmisBrowserBindingServlet e
response.resetBuffer();
setStatus(request, response, statusCode);
+ String message = ex.getMessage();
+ if (!(ex instanceof CmisBaseException)) {
+ message = "An error occurred!";
+ }
+
JSONObject jsonResponse = new JSONObject();
jsonResponse.put(ERROR_EXCEPTION, exceptionName);
- jsonResponse.put(ERROR_MESSAGE, ex.getMessage());
+ jsonResponse.put(ERROR_MESSAGE, message);
String st = ExceptionHelper.getStacktraceAsString(ex);
if (st != null) {
@@ -471,6 +476,11 @@ public class CmisBrowserBindingServlet e
writeJSON(jsonResponse, request, response);
} catch (Exception e) {
LOG.error(e.getMessage(), e);
+ try {
+ response.sendError(statusCode, message);
+ } catch (Exception en) {
+ // there is nothing else we can do
+ }
}
} else {
setStatus(request, response, HttpServletResponse.SC_OK);
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=1613180&r1=1613179&r2=1613180&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 Thu Jul 24 16:31:31 2014
@@ -18,6 +18,7 @@
*/
package org.apache.chemistry.opencmis.server.impl.webservices;
+import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import java.util.Map;
@@ -55,6 +56,8 @@ import org.apache.chemistry.opencmis.ser
import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
import org.apache.chemistry.opencmis.server.impl.ServerVersion;
import org.apache.chemistry.opencmis.server.shared.ExceptionHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
/**
@@ -62,6 +65,8 @@ import org.w3c.dom.Node;
*/
public abstract class AbstractService {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractService.class);
+
public static final String CALL_CONTEXT_MAP = "org.apache.chemistry.opencmis.callcontext";
/**
@@ -196,36 +201,43 @@ public abstract class AbstractService {
fault.setType(EnumServiceException.RUNTIME);
if (ex != null) {
- fault.setMessage(ex.getMessage());
-
if (ex instanceof CmisBaseException) {
fault.setCode(((CmisBaseException) ex).getCode());
- }
+ fault.setMessage(ex.getMessage());
- if (ex instanceof CmisConstraintException) {
- fault.setType(EnumServiceException.CONSTRAINT);
- } else if (ex instanceof CmisContentAlreadyExistsException) {
- fault.setType(EnumServiceException.CONTENT_ALREADY_EXISTS);
- } else if (ex instanceof CmisFilterNotValidException) {
- fault.setType(EnumServiceException.FILTER_NOT_VALID);
- } else if (ex instanceof CmisInvalidArgumentException) {
- fault.setType(EnumServiceException.INVALID_ARGUMENT);
- } else if (ex instanceof CmisNameConstraintViolationException) {
- fault.setType(EnumServiceException.NAME_CONSTRAINT_VIOLATION);
- } else if (ex instanceof CmisNotSupportedException) {
- fault.setType(EnumServiceException.NOT_SUPPORTED);
- } else if (ex instanceof CmisObjectNotFoundException) {
- fault.setType(EnumServiceException.OBJECT_NOT_FOUND);
- } else if (ex instanceof CmisPermissionDeniedException) {
- fault.setType(EnumServiceException.PERMISSION_DENIED);
- } else if (ex instanceof CmisStorageException) {
- fault.setType(EnumServiceException.STORAGE);
- } else if (ex instanceof CmisStreamNotSupportedException) {
- fault.setType(EnumServiceException.STREAM_NOT_SUPPORTED);
- } else if (ex instanceof CmisUpdateConflictException) {
- fault.setType(EnumServiceException.UPDATE_CONFLICT);
- } else if (ex instanceof CmisVersioningException) {
- fault.setType(EnumServiceException.VERSIONING);
+ if (ex instanceof CmisConstraintException) {
+ fault.setType(EnumServiceException.CONSTRAINT);
+ } else if (ex instanceof CmisContentAlreadyExistsException) {
+ fault.setType(EnumServiceException.CONTENT_ALREADY_EXISTS);
+ } else if (ex instanceof CmisFilterNotValidException) {
+ fault.setType(EnumServiceException.FILTER_NOT_VALID);
+ } else if (ex instanceof CmisInvalidArgumentException) {
+ fault.setType(EnumServiceException.INVALID_ARGUMENT);
+ } else if (ex instanceof CmisNameConstraintViolationException) {
+ fault.setType(EnumServiceException.NAME_CONSTRAINT_VIOLATION);
+ } else if (ex instanceof CmisNotSupportedException) {
+ fault.setType(EnumServiceException.NOT_SUPPORTED);
+ } else if (ex instanceof CmisObjectNotFoundException) {
+ fault.setType(EnumServiceException.OBJECT_NOT_FOUND);
+ } else if (ex instanceof CmisPermissionDeniedException) {
+ fault.setType(EnumServiceException.PERMISSION_DENIED);
+ } else if (ex instanceof CmisStorageException) {
+ fault.setType(EnumServiceException.STORAGE);
+ } else if (ex instanceof CmisStreamNotSupportedException) {
+ fault.setType(EnumServiceException.STREAM_NOT_SUPPORTED);
+ } else if (ex instanceof CmisUpdateConflictException) {
+ fault.setType(EnumServiceException.UPDATE_CONFLICT);
+ } else if (ex instanceof CmisVersioningException) {
+ fault.setType(EnumServiceException.VERSIONING);
+ }
+ } else {
+ fault.setMessage("An error occurred!");
+
+ if (ex instanceof IOException) {
+ LOG.warn(ex.getMessage(), ex);
+ } else {
+ LOG.error(ex.getMessage(), ex);
+ }
}
Node node = ExceptionHelper.getStacktraceAsNode(ex);