jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r950439 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user: AuthorizableImpl.java UserManagerImpl.java
Date Wed, 02 Jun 2010 08:59:08 GMT
Author: angela
Date: Wed Jun  2 08:59:07 2010
New Revision: 950439

URL: http://svn.apache.org/viewvc?rev=950439&view=rev
Log:
minor improvement

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java?rev=950439&r1=950438&r2=950439&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/AuthorizableImpl.java
Wed Jun  2 08:59:07 2010
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 import org.apache.jackrabbit.core.PropertyImpl;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.nodetype.NodeTypeImpl;
 import org.apache.jackrabbit.core.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.spi.Name;
@@ -447,6 +448,10 @@ abstract class AuthorizableImpl implemen
             super(name);
         }
 
+        NodeId getNodeId() {
+            return node.getNodeId();
+        }
+        
         //---------------------------------------------< ItemBasedPrincipal >---
         /**
          * Method revealing the path to the Node that represents the

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java?rev=950439&r1=950438&r2=950439&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
Wed Jun  2 08:59:07 2010
@@ -36,7 +36,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.jcr.AccessDeniedException;
-import javax.jcr.Item;
 import javax.jcr.ItemExistsException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
@@ -242,7 +241,6 @@ public class UserManagerImpl extends Pro
      *
      * @param session The editing/reading session.
      * @param adminId The user ID of the administrator.
-     * @throws RepositoryException If an error occurs.
      */
     public UserManagerImpl(SessionImpl session, String adminId) {
         this(session, adminId, null);
@@ -265,7 +263,6 @@ public class UserManagerImpl extends Pro
      * @param session The editing/reading session.
      * @param adminId The user ID of the administrator.
      * @param config The configuration parameters.
-     * @throws RepositoryException If an error occurs.
      */
     public UserManagerImpl(SessionImpl session, String adminId, Properties config) {
         this.session = session;
@@ -356,14 +353,18 @@ public class UserManagerImpl extends Pro
      */
     public Authorizable getAuthorizable(Principal principal) throws RepositoryException {
         NodeImpl n = null;
-        // shortcut that avoids executing a query.
-        if (principal instanceof ItemBasedPrincipal) {
+        // shortcuts that avoids executing a query.
+        if (principal instanceof AuthorizableImpl.NodeBasedPrincipal) {
+            NodeId nodeId = ((AuthorizableImpl.NodeBasedPrincipal) principal).getNodeId();
+            try {
+                n = session.getNodeById(nodeId);
+            } catch (ItemNotFoundException e) {
+                // no such authorizable -> null
+            }
+        } else if (principal instanceof ItemBasedPrincipal) {
             String authPath = ((ItemBasedPrincipal) principal).getPath();
-            if (session.itemExists(authPath)) {
-                Item authItem = session.getItem(authPath);
-                if (authItem.isNode()) {
-                    n = (NodeImpl) authItem;
-                }
+            if (session.nodeExists(authPath)) {
+                n = (NodeImpl) session.getNode(authPath);
             }
         } else {
             // another Principal implementation.
@@ -379,7 +380,7 @@ public class UserManagerImpl extends Pro
             } catch (RepositoryException e) {
                 // ignore and execute the query.
             }
-            // shortcut didn't work -> search.
+            // authorizable whose ID matched the principal name -> search.
             n = (NodeImpl) authResolver.findNode(P_PRINCIPAL_NAME, name, NT_REP_AUTHORIZABLE);
         }
         // build the corresponding authorizable object
@@ -758,7 +759,7 @@ public class UserManagerImpl extends Pro
      * </ul>
      *
      * @return The admin user.
-     * @throws RepositoryException
+     * @throws RepositoryException If an error occurs.
      */
     private User createAdmin() throws RepositoryException {
         User admin;



Mime
View raw message