chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1493103 - /chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
Date Fri, 14 Jun 2013 15:04:47 GMT
Author: fmui
Date: Fri Jun 14 15:04:46 2013
New Revision: 1493103

URL: http://svn.apache.org/r1493103
Log:
Web Services server: improved error message for clients that don't send MTOM requests

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.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/CmisWebServicesServlet.java?rev=1493103&r1=1493102&r2=1493103&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
Fri Jun 14 15:04:46 2013
@@ -154,7 +154,22 @@ public class CmisWebServicesServlet exte
             return;
         }
 
-        super.service(new ProtectionRequestWrapper(request, MAX_SOAP_SIZE), response);
+        // handle other non-POST requests
+        if (!request.getMethod().equals("POST")) {
+            printError(request, response, "Not a HTTP POST request.");
+            return;
+        }
+
+        // handle POST requests
+        ProtectionRequestWrapper requestWrapper = null;
+        try {
+            requestWrapper = new ProtectionRequestWrapper(request, MAX_SOAP_SIZE);
+        } catch (ServletException e) {
+            printError(request, response, "The request is not MTOM encoded.");
+            return;
+        }
+
+        super.service(requestWrapper, response);
     }
 
     private void printXml(HttpServletRequest request, HttpServletResponse response, String
doc, UrlBuilder baseUrl)
@@ -199,6 +214,36 @@ public class CmisWebServicesServlet exte
         pw.flush();
     }
 
+    private void printError(HttpServletRequest request, HttpServletResponse response, String
message)
+            throws ServletException, IOException {
+        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        response.setContentType("text/xml");
+        response.setCharacterEncoding("UTF-8");
+
+        PrintWriter pw = response.getWriter();
+
+        String messageEscaped = StringEscapeUtils.escapeXml(message);
+
+        pw.println("<?xml version='1.0' encoding='UTF-8'?>");
+        pw.println("<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\">");
+        pw.println("<S:Body>");
+        pw.println("<S:Fault>");
+        pw.println("<faultcode>S:Client</faultcode>");
+        pw.println("<faultstring>" + messageEscaped + "</faultstring>");
+        pw.println("<detail>");
+        pw.println("<cmisFault xmlns=\"http://docs.oasis-open.org/ns/cmis/messaging/200908/\">");
+        pw.println("<type>runtime</type>");
+        pw.println("<code>0</code>");
+        pw.println("<message>" + messageEscaped + "</message>");
+        pw.println("</cmisFault>");
+        pw.println("</detail>");
+        pw.println("</S:Fault>");
+        pw.println("</S:Body>");
+        pw.println("</S:Envelope>");
+
+        pw.flush();
+    }
+
     private UrlBuilder compileBaseUrl(HttpServletRequest request, HttpServletResponse response)
{
         UrlBuilder result;
 



Mime
View raw message