You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2013/08/09 14:11:11 UTC

svn commit: r1512273 - in /jackrabbit/trunk: jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/secu...

Author: angela
Date: Fri Aug  9 12:11:11 2013
New Revision: 1512273

URL: http://svn.apache.org/r1512273
Log:
JCR-3637 : JackrabbitAccessControlEntry: Add support for multi-valued restrictions

Modified:
    jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlEntry.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryImpl.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
    jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java

Modified: jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlEntry.java?rev=1512273&r1=1512272&r2=1512273&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlEntry.java (original)
+++ jackrabbit/trunk/jackrabbit-api/src/main/java/org/apache/jackrabbit/api/security/JackrabbitAccessControlEntry.java Fri Aug  9 12:11:11 2013
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.api.securi
 
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 import javax.jcr.security.AccessControlEntry;
 
 /**
@@ -43,13 +44,35 @@ public interface JackrabbitAccessControl
 
     /**
      * Return the value of the restriction with the specified name or
-     * <code>null</code> if no such restriction exists.
+     * <code>null</code> if no such restriction exists. In case the restriction
+     * with the specified name contains multiple value this method will call
+     * {@code ValueFormatException}.
      *
      * @param restrictionName The of the restriction as obtained through
      * {@link #getRestrictionNames()}.
      * @return value of the restriction with the specified name or
-     * <code>null</code> if no such restriction exists
+     * <code>null</code> if no such restriction exists.
+     * @throws ValueFormatException If the restriction with the specified name
+     * contains multiple values.
+     * @throws RepositoryException if an error occurs.
+     * @see {@link #getRestrictions(String)}
+     */
+    Value getRestriction(String restrictionName) throws ValueFormatException, RepositoryException;
+
+    /**
+     * Return the values of the restriction with the specified name or
+     * <code>null</code> if no such restriction exists. For restrictions that
+     * contain just a single value this method is expected to return an array
+     * with a single element even if the underlying implementation stored the
+     * restriction in single-value JCR property.
+     *
+     * @param restrictionName The of the restriction as obtained through
+     * {@link #getRestrictionNames()}.
+     * @return the values of the restriction with the specified name as an array
+     * or <code>null</code> if no such restriction exists. The array may contain
+     * zero, one or multiple values.
      * @throws RepositoryException if an error occurs.
+     * @see {@link #getRestriction(String)}
      */
-    Value getRestriction(String restrictionName) throws RepositoryException;
+    Value[] getRestrictions(String restrictionName) throws RepositoryException;
 }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryImpl.java?rev=1512273&r1=1512272&r2=1512273&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryImpl.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/security/authorization/AccessControlEntryImpl.java Fri Aug  9 12:11:11 2013
@@ -23,6 +23,7 @@ import org.apache.jackrabbit.value.Value
 
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.ValueFactory;
 import javax.jcr.security.AccessControlException;
@@ -299,6 +300,13 @@ public abstract class AccessControlEntry
         return getRestriction(getResolver().getQName(restrictionName));
     }
 
+    /**
+     * @see org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry#getRestrictions(String)
+     */
+    public Value[] getRestrictions(String restrictionName) throws RepositoryException {
+        throw new UnsupportedRepositoryOperationException("Not implemented. Please use Jackrabbit OAK to get support for multi-valued restrictions.");
+    }
+
     //-------------------------------------------------------------< Object >---
     /**
      * @see Object#hashCode()
@@ -328,4 +336,4 @@ public abstract class AccessControlEntry
         }
         return false;
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java?rev=1512273&r1=1512272&r2=1512273&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractACLTemplateTest.java Fri Aug  9 12:11:11 2013
@@ -125,6 +125,11 @@ public abstract class AbstractACLTemplat
                 public Value getRestriction(String restrictionName) {
                     return null;
                 }
+
+                public Value[] getRestrictions(String restrictionName) throws RepositoryException {
+                    return null;
+                }
+
                 public Principal getPrincipal() {
                     return testPrincipal;
                 }
@@ -159,6 +164,11 @@ public abstract class AbstractACLTemplat
                 public Value getRestriction(String restrictionName) {
                     return null;
                 }
+
+                public Value[] getRestrictions(String restrictionName) throws RepositoryException {
+                    return null;
+                }
+
                 public Principal getPrincipal() {
                     return testPrincipal;
                 }
@@ -322,4 +332,4 @@ public abstract class AbstractACLTemplat
             // success
         }
     }
-}
\ No newline at end of file
+}

Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java?rev=1512273&r1=1512272&r2=1512273&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authorization/AbstractEntryTest.java Fri Aug  9 12:11:11 2013
@@ -205,6 +205,11 @@ public abstract class AbstractEntryTest 
             public Value getRestriction(String restrictionName) {
                 return null;
             }
+
+            public Value[] getRestrictions(String restrictionName) throws RepositoryException {
+                return null;
+            }
+
             public Principal getPrincipal() {
                 return testPrincipal;
             }
@@ -288,6 +293,11 @@ public abstract class AbstractEntryTest 
             public Value getRestriction(String restrictionName) {
                 return null;
             }
+
+            public Value[] getRestrictions(String restrictionName) throws RepositoryException {
+                return null;
+            }
+
             public Principal getPrincipal() {
                 return testPrincipal;
             }