You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Thorben Heins (JIRA)" <ji...@apache.org> on 2013/03/07 11:10:13 UTC

[jira] [Created] (SLING-2776) A POST that runs into an AccessDeniedException returns a 500 instead of a 403

Thorben Heins created SLING-2776:
------------------------------------

             Summary: A POST that runs into an AccessDeniedException returns a 500 instead of a 403
                 Key: SLING-2776
                 URL: https://issues.apache.org/jira/browse/SLING-2776
             Project: Sling
          Issue Type: Bug
          Components: Servlets
    Affects Versions: Servlets Post 2.2.0
         Environment: CQ5
            Reporter: Thorben Heins
            Priority: Trivial


If you POST to an url that you are not allowed to POST to, a 500 is returned. 

Here is my suggested fix:

host:~/Downloads/sling $ svn diff
Index: bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostResponse.java
===================================================================
--- bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostResponse.java	(revision 1453750)
+++ bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/AbstractPostResponse.java	(working copy)
@@ -292,7 +292,11 @@
         String path = getPath();
         if (getProperty(PN_STATUS_CODE) == null) {
             if (getError() != null) {
-                setStatus(500, getError().toString());
+		if (getError() instanceof javax.jcr.AccessDeniedException) {
+		    setStatus(403, getError.toString());
+		} else {
+                    setStatus(500, getError().toString());
+                }
                 setTitle("Error while processing " + path);
             } else {
                 if (isCreateRequest()) {
@@ -376,4 +380,4 @@
         doSend(response);
     }

-}
\ No newline at end of file
+}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira