directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r289389 - in /directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl: ItemFirstACIItem.java UserFirstACIItem.java
Date Fri, 16 Sep 2005 05:57:55 GMT
Author: trustin
Date: Thu Sep 15 22:57:51 2005
New Revision: 289389

URL: http://svn.apache.org/viewcvs?rev=289389&view=rev
Log:
Added more contructors to ACIItem implementations as Ersin requested.

Modified:
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
    directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java?rev=289389&r1=289388&r2=289389&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
(original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/ItemFirstACIItem.java
Thu Sep 15 22:57:51 2005
@@ -27,16 +27,49 @@
 public class ItemFirstACIItem extends ACIItem
 {
     private static final long serialVersionUID = -8199453391060356463L;
+    
+    private static final Set EMPTY_SET = new HashSet();
 
-    private final Set protectedItems = new HashSet();
-    private final Set itemPermissions = new HashSet();
+    private final Set protectedItems;
+    private final Set itemPermissions;
 
     public ItemFirstACIItem(
             String identificationTag,
             int precedence,
             AuthenticationLevel authenticationLevel )
     {
+        this( identificationTag, precedence, authenticationLevel, EMPTY_SET, EMPTY_SET );
+    }
+    
+    public ItemFirstACIItem(
+            String identificationTag,
+            int precedence,
+            AuthenticationLevel authenticationLevel,
+            Set protectedItems,
+            Set itemPermissions )
+    {
         super( identificationTag, precedence, authenticationLevel );
+        
+        for( Iterator i = protectedItems.iterator(); i.hasNext(); )
+        {
+            if( !ProtectedItem.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "protectedItems contains an element which is not a protected item."
);
+            }
+        }
+
+        for( Iterator i = itemPermissions.iterator(); i.hasNext(); )
+        {
+            if( !ItemPermission.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "itemPermissions contains an element which is not an item permission."
);
+            }
+        }
+
+        this.protectedItems = new HashSet( protectedItems );
+        this.itemPermissions = new HashSet( itemPermissions );
     }
 
     public boolean add( ProtectedItem protectedItem )

Modified: directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java?rev=289389&r1=289388&r2=289389&view=diff
==============================================================================
--- directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java
(original)
+++ directory/shared/ldap/trunk/common/src/java/org/apache/ldap/common/acl/UserFirstACIItem.java
Thu Sep 15 22:57:51 2005
@@ -27,16 +27,49 @@
 public class UserFirstACIItem extends ACIItem
 {
     private static final long serialVersionUID = 5587483838404246148L;
+    
+    private static final Set EMPTY_SET = new HashSet();
 
-    private final Set userClasses = new HashSet();
-    private final Set userPermissions = new HashSet();
+    private final Set userClasses;
+    private final Set userPermissions;
 
     public UserFirstACIItem(
             String identificationTag,
             int precedence,
             AuthenticationLevel authenticationLevel )
     {
+        this( identificationTag, precedence, authenticationLevel, EMPTY_SET, EMPTY_SET );
+    }
+    
+    public UserFirstACIItem(
+            String identificationTag,
+            int precedence,
+            AuthenticationLevel authenticationLevel,
+            Set userClasses,
+            Set userPermissions )
+    {
         super( identificationTag, precedence, authenticationLevel );
+        
+        for( Iterator i = userClasses.iterator(); i.hasNext(); )
+        {
+            if( !UserClass.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "userClasses contains an element which is not a user class." );
+            }
+        }
+
+        for( Iterator i = userPermissions.iterator(); i.hasNext(); )
+        {
+            if( !UserPermission.class.isAssignableFrom( i.next().getClass() ) )
+            {
+                throw new IllegalArgumentException(
+                        "userPermissions contains an element which is not a user permission."
);
+            }
+        }
+
+        this.userClasses = new HashSet( userClasses );
+        this.userPermissions = new HashSet( userPermissions );
     }
 
     public boolean add( UserClass userClass )



Mime
View raw message