directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r566513 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci: ACITuple.java UserClass.java
Date Thu, 16 Aug 2007 07:09:49 GMT
Author: akarasulu
Date: Thu Aug 16 00:09:48 2007
New Revision: 566513

URL: http://svn.apache.org/viewvc?view=rev&rev=566513
Log:
rolling back emmanuel's commits which again caused compilation errors on my 
machine while trying to fix bug - will figure out the cause later.  Using
following lines to rollback changes:

[akarasulu@vcwks shared]$ svn merge -r 566508:566507 .
U    ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
[akarasulu@vcwks shared]$ svn merge -r 566506:566505 .
U    ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java


Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java?view=diff&rev=566513&r1=566512&r2=566513
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/ACITuple.java
Thu Aug 16 00:09:48 2007
@@ -25,6 +25,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 
@@ -39,13 +40,13 @@
 {
     private static final long serialVersionUID = 4353150626941232371L;
 
-    private final Collection<UserClass> userClasses;
+    private final Collection userClasses;
 
     private final AuthenticationLevel authenticationLevel;
 
-    private final Collection<ProtectedItem> protectedItems;
+    private final Collection protectedItems;
 
-    private final Set<MicroOperation> microOperations;
+    private final Set microOperations;
 
     private final boolean grant;
 
@@ -68,14 +69,34 @@
      * @param precedence
      *            the precedence of this tuple (<tt>0</tt>-<tt>255</tt>)
      */
-    public ACITuple( 
-            Collection<UserClass> userClasses, 
-            AuthenticationLevel authenticationLevel, 
-            Collection<ProtectedItem> protectedItems,
-            Set<MicroOperation> microOperations, 
-            boolean grant, 
-            int precedence )
+    public ACITuple(Collection userClasses, AuthenticationLevel authenticationLevel, Collection
protectedItems,
+        Set microOperations, boolean grant, int precedence)
     {
+        for ( Iterator i = userClasses.iterator(); i.hasNext(); )
+        {
+            if ( !( i.next() instanceof UserClass ) )
+            {
+                throw new IllegalArgumentException( "userClasses contains an element which
is not a user classs." );
+            }
+        }
+
+        for ( Iterator i = protectedItems.iterator(); i.hasNext(); )
+        {
+            if ( !( i.next() instanceof ProtectedItem ) )
+            {
+                throw new IllegalArgumentException( "protectedItems contains an element which
is not a protected item." );
+            }
+        }
+
+        for ( Iterator i = microOperations.iterator(); i.hasNext(); )
+        {
+            if ( !( i.next() instanceof MicroOperation ) )
+            {
+                throw new IllegalArgumentException(
+                    "microOperations contains an element which is not a micro operation."
);
+            }
+        }
+
         if ( authenticationLevel == null )
         {
             throw new NullPointerException( "authenticationLevel" );
@@ -86,10 +107,10 @@
             throw new IllegalArgumentException( "precedence: " + precedence );
         }
 
-        this.userClasses = Collections.unmodifiableCollection( new ArrayList<UserClass>(
userClasses ) );
+        this.userClasses = Collections.unmodifiableCollection( new ArrayList( userClasses
) );
         this.authenticationLevel = authenticationLevel;
-        this.protectedItems = Collections.unmodifiableCollection( new ArrayList<ProtectedItem>(
protectedItems ) );
-        this.microOperations = Collections.unmodifiableSet( new HashSet<MicroOperation>(
microOperations ) );
+        this.protectedItems = Collections.unmodifiableCollection( new ArrayList( protectedItems
) );
+        this.microOperations = Collections.unmodifiableSet( new HashSet( microOperations
) );
         this.grant = grant;
         this.precedence = precedence;
     }
@@ -98,7 +119,7 @@
     /**
      * Returns the collection of {@link UserClass}es this tuple relates to.
      */
-    public Collection<UserClass> getUserClasses()
+    public Collection getUserClasses()
     {
         return userClasses;
     }
@@ -116,7 +137,7 @@
     /**
      * Returns the collection of {@link ProtectedItem}s this tuple relates.
      */
-    public Collection<ProtectedItem> getProtectedItems()
+    public Collection getProtectedItems()
     {
         return protectedItems;
     }
@@ -125,7 +146,7 @@
     /**
      * Returns the set of {@link MicroOperation}s this tuple relates.
      */
-    public Set<MicroOperation> getMicroOperations()
+    public Set getMicroOperations()
     {
         return microOperations;
     }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java?view=diff&rev=566513&r1=566512&r2=566513
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/aci/UserClass.java
Thu Aug 16 00:09:48 2007
@@ -25,6 +25,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
@@ -127,24 +128,33 @@
      */
     private static abstract class NamedUserClass extends UserClass
     {
-        protected final Set<javax.naming.Name> names;
+        protected final Set names;
 
 
         /**
          * Creates a new instance.
          * 
-         * @param names a set of names
+         * @param names
+         *            a set of names
          */
-        protected NamedUserClass( Set<javax.naming.Name> names )
+        protected NamedUserClass(Set names)
         {
-            this.names = Collections.unmodifiableSet( new HashSet<javax.naming.Name>(
names ) );
+            for ( Iterator i = names.iterator(); i.hasNext(); )
+            {
+                Object val = i.next();
+                if ( !( val instanceof javax.naming.Name ) )
+                {
+                    throw new IllegalArgumentException( "names contains a wrong element."
);
+                }
+            }
+            this.names = Collections.unmodifiableSet( new HashSet( names ) );
         }
 
 
         /**
          * Returns the set of all names.
          */
-        public Set<javax.naming.Name> getNames()
+        public Set getNames()
         {
             return names;
         }
@@ -180,26 +190,24 @@
         
         public void printToBuffer( StringBuffer buffer )
         {
-            boolean isFirst = true;
-            buffer.append( "{ " );
+            buffer.append( '{' );
+            buffer.append( ' ' );
             
-            for ( javax.naming.Name name:names )
+            for ( Iterator it = names.iterator(); it.hasNext(); )
             {
-                if ( isFirst )
-                {
-                    isFirst = false;
-                }
-                else
-                {
-                    buffer.append( ", " );
-                }
-                
+                javax.naming.Name name = ( javax.naming.Name ) it.next();
                 buffer.append( '"' );
                 buffer.append( name.toString() );
                 buffer.append( '"' );
+                
+                if(it.hasNext()) {
+                    buffer.append( ',' );
+                    buffer.append( ' ' );
+                }
             }
             
-            buffer.append( " }" );
+            buffer.append( ' ' );
+            buffer.append( '}' );
         }
     }
 
@@ -217,7 +225,7 @@
          * @param usernames
          *            the set of user DNs.
          */
-        public Name( Set<javax.naming.Name> usernames )
+        public Name(Set usernames)
         {
             super( usernames );
         }
@@ -231,7 +239,8 @@
         
         public void printToBuffer( StringBuffer buffer )
         {
-            buffer.append( "name " );
+            buffer.append( "name" );
+            buffer.append( ' ' );
             super.printToBuffer( buffer );
         }
     }
@@ -253,7 +262,7 @@
          * @param groupNames
          *            the set of group DNs.
          */
-        public UserGroup( Set<javax.naming.Name> groupNames )
+        public UserGroup(Set groupNames)
         {
             super( groupNames );
         }
@@ -267,7 +276,8 @@
         
         public void printToBuffer( StringBuffer buffer )
         {
-            buffer.append( "userGroup " );
+            buffer.append( "userGroup" );
+            buffer.append( ' ' );
             super.printToBuffer( buffer );
         }
     }
@@ -280,7 +290,7 @@
     {
         private static final long serialVersionUID = 3949337699049701332L;
 
-        protected final Collection<SubtreeSpecification> subtreeSpecifications;
+        protected final Collection subtreeSpecifications;
 
 
         /**
@@ -289,16 +299,24 @@
          * @param subtreeSpecs
          *            the collection of unrefined {@link SubtreeSpecification}s.
          */
-        public Subtree( Collection<SubtreeSpecification> subtreeSpecs )
+        public Subtree(Collection subtreeSpecs)
         {
-            this.subtreeSpecifications = Collections.unmodifiableCollection( new ArrayList<SubtreeSpecification>(
subtreeSpecs ) );
+            for ( Iterator i = subtreeSpecs.iterator(); i.hasNext(); )
+            {
+                Object val = i.next();
+                if ( !( val instanceof SubtreeSpecification ) )
+                {
+                    throw new IllegalArgumentException( "subtreeSpecs contains a wrong element."
);
+                }
+            }
+            this.subtreeSpecifications = Collections.unmodifiableCollection( new ArrayList(
subtreeSpecs ) );
         }
 
 
         /**
          * Returns the collection of unrefined {@link SubtreeSpecification}s.
          */
-        public Collection<SubtreeSpecification> getSubtreeSpecifications()
+        public Collection getSubtreeSpecifications()
         {
             return subtreeSpecifications;
         }
@@ -329,24 +347,24 @@
         
         public void printToBuffer( StringBuffer buffer )
         {
-            boolean isFirst = true;
-            buffer.append( "subtree { " );
+            buffer.append( "subtree" );
+            buffer.append( ' ' );
+            buffer.append( '{' );
+            buffer.append( ' ' );
             
-            for ( SubtreeSpecification ss:subtreeSpecifications )
+            for ( Iterator it = subtreeSpecifications.iterator(); it.hasNext(); )
             {
-                if ( isFirst )
-                {
-                    isFirst = false;
-                }
-                else
-                {
-                    buffer.append( ", " );
-                }
-                
+                SubtreeSpecification ss = ( SubtreeSpecification ) it.next();
                 ss.printToBuffer( buffer );
+                
+                if(it.hasNext()) {
+                    buffer.append( ',' );
+                    buffer.append( ' ' );
+                }
             }
             
-            buffer.append( " }" );
+            buffer.append( ' ' );
+            buffer.append( '}' );
         }
     }
 }



Mime
View raw message