incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enor...@apache.org
Subject svn commit: r1098436 - in /sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post: CreateGroupServlet.java CreateUserServlet.java
Date Sun, 01 May 2011 23:06:31 GMT
Author: enorman
Date: Sun May  1 23:06:30 2011
New Revision: 1098436

URL: http://svn.apache.org/viewvc?rev=1098436&view=rev
Log:
SLING-2066 improve error reporting for validation errors

Modified:
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
    sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java?rev=1098436&r1=1098435&r2=1098436&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
Sun May  1 23:06:30 2011
@@ -95,7 +95,7 @@ public class CreateGroupServlet extends 
 
         // check that the submitted parameter values have valid values.
         final String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
-        if (principalName == null) {
+        if (principalName == null || principalName.length() == 0) {
             throw new RepositoryException("Group name was not submitted");
         }
 
@@ -104,41 +104,37 @@ public class CreateGroupServlet extends 
             throw new RepositoryException("JCR Session not found");
         }
 
-        try {
-            UserManager userManager = AccessControlUtil.getUserManager(session);
-            Authorizable authorizable = userManager.getAuthorizable(principalName);
-
-            if (authorizable != null) {
-                // principal already exists!
-                throw new RepositoryException(
-                    "A principal already exists with the requested name: "
-                        + principalName);
-            } else {
-                Group group = userManager.createGroup(new Principal() {
-                    public String getName() {
-                        return principalName;
-                    }
-                });
-
-                String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
-                    + group.getID();
-                
-                Map<String, RequestProperty> reqProperties = collectContent(
-                    request, response, groupPath);
-                response.setPath(groupPath);
-                response.setLocation(externalizePath(request, groupPath));
-                response.setParentLocation(externalizePath(request,
-                    AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PATH));
-                changes.add(Modification.onCreated(groupPath));
-
-                // write content from form
-                writeContent(session, group, reqProperties, changes);
-
-                // update the group memberships
-                updateGroupMembership(request, group, changes);
-            }
-        } catch (RepositoryException re) {
-            throw new RepositoryException("Failed to create new group.", re);
+        UserManager userManager = AccessControlUtil.getUserManager(session);
+        Authorizable authorizable = userManager.getAuthorizable(principalName);
+
+        if (authorizable != null) {
+            // principal already exists!
+            throw new RepositoryException(
+                "A principal already exists with the requested name: "
+                    + principalName);
+        } else {
+            Group group = userManager.createGroup(new Principal() {
+                public String getName() {
+                    return principalName;
+                }
+            });
+
+            String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
+                + group.getID();
+            
+            Map<String, RequestProperty> reqProperties = collectContent(
+                request, response, groupPath);
+            response.setPath(groupPath);
+            response.setLocation(externalizePath(request, groupPath));
+            response.setParentLocation(externalizePath(request,
+                AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PATH));
+            changes.add(Modification.onCreated(groupPath));
+
+            // write content from form
+            writeContent(session, group, reqProperties, changes);
+
+            // update the group memberships
+            updateGroupMembership(request, group, changes);
         }
     }
 }

Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java?rev=1098436&r1=1098435&r2=1098436&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
(original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
Sun May  1 23:06:30 2011
@@ -195,7 +195,7 @@ public class CreateUserServlet extends A
 
         // check that the submitted parameter values have valid values.
         String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
-        if (principalName == null) {
+        if (principalName == null || principalName.length() == 0) {
             throw new RepositoryException("User name was not submitted");
         }
         String pwd = request.getParameter("pwd");



Mime
View raw message