jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1421980 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/ oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/
Date Fri, 14 Dec 2012 17:14:53 GMT
Author: angela
Date: Fri Dec 14 17:14:51 2012
New Revision: 1421980

URL: http://svn.apache.org/viewvc?rev=1421980&view=rev
Log:
OAK-50 : Implement User Management (WIP)
- rename OakAuthorizableProperties as there is only a single implementation left
- remove redundant test
- consistently use RepositoryException if relPath doesn't refer to a property in this user-tree
OAK-502 : User.getPropertyNames throws StringIndexOutOfBoundsException

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
      - copied, changed from r1421865, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/OakAuthorizablePropertyTest.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
(from r1421865, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java&r1=1421865&r2=1421980&rev=1421980&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/OakAuthorizableProperties.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizablePropertiesImpl.java
Fri Dec 14 17:14:51 2012
@@ -50,17 +50,17 @@ import org.slf4j.LoggerFactory;
  * {@code UserManager} and only OAK API methods can be used to read and
  * modify authorizable properties.
  */
-class OakAuthorizableProperties implements AuthorizableProperties {
+class AuthorizablePropertiesImpl implements AuthorizableProperties {
 
-    private static final Logger log = LoggerFactory.getLogger(OakAuthorizableProperties.class);
+    private static final Logger log = LoggerFactory.getLogger(AuthorizablePropertiesImpl.class);
 
     private final UserProvider userProvider;
     private final String id;
     private final NamePathMapper namePathMapper;
     private final ReadOnlyNodeTypeManager nodeTypeManager;
 
-    OakAuthorizableProperties(final Root root, UserProvider userProvider,
-                              String id, NamePathMapper namePathMapper) {
+    AuthorizablePropertiesImpl(final Root root, UserProvider userProvider,
+                               String id, NamePathMapper namePathMapper) {
         this.userProvider = userProvider;
         this.id = id;
         this.namePathMapper = namePathMapper;
@@ -85,7 +85,7 @@ class OakAuthorizableProperties implemen
             }
             return l.iterator();
         } else {
-            throw new IllegalArgumentException("Relative path " + relPath + " refers to items
outside of scope of authorizable.");
+            throw new RepositoryException("Relative path " + relPath + " refers to items
outside of scope of authorizable.");
         }
     }
 
@@ -301,10 +301,7 @@ class OakAuthorizableProperties implemen
     }
 
     private static void checkRelativePath(String relativePath) throws RepositoryException
{
-        if (relativePath == null) {
-            throw new RepositoryException("Relative path expected. Found null.");
-        }
-        if ('/' == relativePath.charAt(0)) {
+        if (relativePath == null || relativePath.isEmpty() || relativePath.charAt(0) == '/')
{
             throw new RepositoryException("Relative path expected. Found " + relativePath);
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java?rev=1421980&r1=1421979&r2=1421980&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
Fri Dec 14 17:14:51 2012
@@ -292,7 +292,7 @@ public class UserManagerImpl implements 
 
     @Nonnull
     AuthorizableProperties getAuthorizableProperties(String id) throws RepositoryException
{
-        return new OakAuthorizableProperties(root, userProvider, id, namePathMapper);
+        return new AuthorizablePropertiesImpl(root, userProvider, id, namePathMapper);
     }
 
     @Nonnull

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java?rev=1421980&r1=1421979&r2=1421980&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizablePropertyTest.java
Fri Dec 14 17:14:51 2012
@@ -188,7 +188,7 @@ public class AuthorizablePropertyTest ex
             try {
                 user.setProperty(invalidRelPath, v);
                 fail("Modifications outside of the scope of the authorizable must fail. Path
was: " + invalidRelPath);
-            } catch (Exception e) {
+            } catch (RepositoryException e) {
                 // success.
             } finally {
                 superuser.refresh(false);
@@ -214,7 +214,7 @@ public class AuthorizablePropertyTest ex
         for (String invalidPath : invalidPaths) {
             try {
                 assertNull(user.getProperty(invalidPath));
-            } catch (Exception e) {
+            } catch (RepositoryException e) {
                 // success
             }
         }
@@ -239,7 +239,7 @@ public class AuthorizablePropertyTest ex
         for (String invalidPath : invalidPaths) {
             try {
                 assertFalse(user.hasProperty(invalidPath));
-            } catch (Exception e) {
+            } catch (RepositoryException e) {
                 // success
             }
         }
@@ -316,6 +316,8 @@ public class AuthorizablePropertyTest ex
     @Test
     public void testGetPropertyNamesByInvalidRelPath() throws NotExecutableException, RepositoryException
{
         List<String> invalidPaths = new ArrayList<String>();
+        invalidPaths.add("");
+        invalidPaths.add("/");
         invalidPaths.add("../");
         invalidPaths.add("../../");
         invalidPaths.add("../testing");
@@ -326,17 +328,12 @@ public class AuthorizablePropertyTest ex
             try {
                 user.getPropertyNames(invalidRelPath);
                 fail("Calling Authorizable#getPropertyNames with " + invalidRelPath + " must
fail.");
-            } catch (Exception e) {
+            } catch (RepositoryException e) {
                 // success
             }
         }
     }
 
-//    @Test FIXME OAK-502
-//    public void testGetPropertyNamesByInvalidRelPathThrowsAIOOBE() throws NotExecutableException,
RepositoryException {
-//        user.getPropertyNames("");
-//    }
-
     @Test
     public void testGetNotExistingProperty() throws RepositoryException, NotExecutableException
{
         String hint = "Fullname";



Mime
View raw message