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 2010/03/05 14:50:18 UTC

svn commit: r919412 - /incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java

Author: fmui
Date: Fri Mar  5 13:50:18 2010
New Revision: 919412

URL: http://svn.apache.org/viewvc?rev=919412&view=rev
Log:
changed AtomPub servlet: authentication providers should be able to throw meaningful exceptions

Modified:
    incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java

Modified: incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=919412&r1=919411&r2=919412&view=diff
==============================================================================
--- incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ incubator/chemistry/trunk/opencmis/opencmis-server/opencmis-server-impl/src/main/java/org/apache/opencmis/server/impl/atompub/CmisAtomPubServlet.java Fri Mar  5 13:50:18 2010
@@ -166,24 +166,15 @@
   protected void service(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
 
-    // create a context object
+    // create a context object, dispatch and handle exceptions
     CallContext context = null;
     try {
       context = createContext(request);
-    }
-    catch (Exception e) {
-      response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Context creation failed: "
-          + e.getMessage());
-      return;
-    }
-
-    // dispatch and handle exceptions
-    try {
       dispatch(context, request, response);
     }
     catch (Exception e) {
       if (e instanceof CmisPermissionDeniedException) {
-        if (context.getUsername() == null) {
+        if ((context == null) || (context.getUsername() == null)) {
           response.setHeader("WWW-Authenticate", "Basic realm=\"CMIS\"");
           response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required");
         }