jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1173746 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/ jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/...
Date Wed, 21 Sep 2011 16:28:33 GMT
Author: angela
Date: Wed Sep 21 16:28:32 2011
New Revision: 1173746

URL: http://svn.apache.org/viewvc?rev=1173746&view=rev
Log:
JCR-3081 : Add UserManager#getAuthorizableByPath(String)ring oldPw)

Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/UserManager.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserManagerImpl.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/UserManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/UserManager.java?rev=1173746&r1=1173745&r2=1173746&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/UserManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/user/UserManager.java
Wed Sep 21 16:28:32 2011
@@ -67,6 +67,19 @@ public interface UserManager {
     Authorizable getAuthorizable(Principal principal) throws RepositoryException;
 
     /**
+     * In accordance to {@link org.apache.jackrabbit.api.security.user.Authorizable#getPath()}
+     * this method allows to retrieve an given authorizable by it's path.
+     *
+     * @param path The path to an authorizable.
+     * @return Authorizable or <code>null</code>, if not present.
+     * @throws UnsupportedRepositoryOperationException If this implementation does
+     * support to retrieve authorizables by path.
+     * @throws RepositoryException If another error occurs.
+     * @see org.apache.jackrabbit.api.security.user.Authorizable#getPath()
+     */
+    Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException;
+
+    /**
      * Returns all <code>Authorizable</code>s that have a
      * {@link Authorizable#getProperty(String) property} with the given relative
      * path (or name) that matches the specified value.

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=1173746&r1=1173745&r2=1173746&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 Sep 21 16:28:32 2011
@@ -445,6 +445,17 @@ public class UserManagerImpl extends Pro
     }
 
     /**
+     * Always throws <code>UnsupportedRepositoryOperationException</code> since
+     * this implementation of the user management API does not allow to retrieve
+     * the path of an authorizable.
+     * 
+     * @see UserManager#getAuthorizableByPath(String)
+     */
+    public Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+        throw new UnsupportedRepositoryOperationException();
+    }
+
+    /**
      * @see UserManager#findAuthorizables(String,String)
      */
     public Iterator<Authorizable> findAuthorizables(String relPath, String value) throws
RepositoryException {
@@ -747,6 +758,15 @@ public class UserManagerImpl extends Pro
     }
 
     /**
+     * Returns the session associated with this user manager.
+     *
+     * @return the session.
+     */
+    SessionImpl getSession() {
+        return session;
+    }
+
+    /**
      * Test if a user or group exists that has the given principals name as ID,
      * which might happen if userID != principal-name.
      * In this case: generate another ID for the group to be created.

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java?rev=1173746&r1=1173745&r2=1173746&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/user/UserPerWorkspaceUserManager.java
Wed Sep 21 16:28:32 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.jackrabbit.core.security.user;
 
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
 
 import javax.jcr.Node;
@@ -78,6 +80,20 @@ public class UserPerWorkspaceUserManager
 
     //--------------------------------------------------------< UserManager >---
     /**
+     * @see org.apache.jackrabbit.api.security.user.UserManager#getAuthorizableByPath(String)
+     */
+    @Override
+    public Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+        SessionImpl session = getSession();
+        if (session.nodeExists(path)) {
+            NodeImpl n = (NodeImpl) session.getNode(path);
+            return getAuthorizable(n);
+        } else {
+            return null;
+        }
+    }
+
+    /**
      * @see org.apache.jackrabbit.api.security.user.UserManager#isAutoSave()
      */
     @Override

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java?rev=1173746&r1=1173745&r2=1173746&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/api/security/user/UserManagerTest.java
Wed Sep 21 16:28:32 2011
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.api.securi
 import org.apache.jackrabbit.test.NotExecutableException;
 
 import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import java.security.Principal;
 import java.util.Iterator;
 import java.util.Set;
@@ -53,4 +54,20 @@ public class UserManagerTest extends Abs
             }
         }
     }
+
+    public void testGetAuthorizableByPath() throws RepositoryException, NotExecutableException
{
+        String uid = superuser.getUserID();
+        Authorizable a = userMgr.getAuthorizable(uid);
+        if (a == null) {
+            throw new NotExecutableException();
+        }
+        try {
+            String path = a.getPath();
+            Authorizable a2 = userMgr.getAuthorizableByPath(path);
+            assertNotNull(a2);
+            assertEquals(a.getID(), a2.getID());
+        } catch (UnsupportedRepositoryOperationException e) {
+            throw new NotExecutableException();
+        }
+    }
 }
\ No newline at end of file

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java?rev=1173746&r1=1173745&r2=1173746&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
Wed Sep 21 16:28:32 2011
@@ -19,7 +19,13 @@ package org.apache.jackrabbit.core.secur
 import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
-import org.apache.jackrabbit.api.security.user.*;
+import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
+import org.apache.jackrabbit.api.security.user.Group;
+import org.apache.jackrabbit.api.security.user.Impersonation;
+import org.apache.jackrabbit.api.security.user.Query;
+import org.apache.jackrabbit.api.security.user.User;
+import org.apache.jackrabbit.api.security.user.UserManager;
 import org.apache.jackrabbit.commons.xml.ParsingContentHandler;
 import org.apache.jackrabbit.core.NodeImpl;
 import org.apache.jackrabbit.core.SessionImpl;
@@ -36,7 +42,29 @@ import org.apache.jackrabbit.test.NotExe
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
-import javax.jcr.*;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.Credentials;
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.InvalidSerializedDataException;
+import javax.jcr.Item;
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.LoginException;
+import javax.jcr.NamespaceException;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.ValueFactory;
+import javax.jcr.Workspace;
 import javax.jcr.lock.LockException;
 import javax.jcr.nodetype.ConstraintViolationException;
 import javax.jcr.nodetype.NoSuchNodeTypeException;
@@ -50,7 +78,12 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.security.AccessControlException;
 import java.security.Principal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
 
 /**
  * <code>UserImporterTest</code>...
@@ -1364,6 +1397,10 @@ public class UserImporterTest extends Ab
                     return null;
                 }
 
+                public Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+                    return null;
+                }
+
                 public Iterator<Authorizable> findAuthorizables(String relPath, String
value) throws RepositoryException {
                     return null;
                 }



Mime
View raw message