directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r504403 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective: CollectiveAttributeService.java CollectiveAttributesSchemaChecker.java
Date Wed, 07 Feb 2007 01:16:41 GMT
Author: elecharny
Date: Tue Feb  6 17:16:41 2007
New Revision: 504403

URL: http://svn.apache.org/viewvc?view=rev&rev=504403
Log:
Code refactoring.
Using generic instead of Java 1.4 constructions.

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java?view=diff&rev=504403&r1=504402&r2=504403
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeService.java
Tue Feb  6 17:16:41 2007
@@ -20,7 +20,6 @@
 package org.apache.directory.server.core.collective;
 
 
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -57,12 +56,15 @@
  * collectiveAttributeInnerAreas.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
- * @version $Rev:$
+ * @version $Rev$
  */
 public class CollectiveAttributeService extends BaseInterceptor
 {
     public static final String COLLECTIVE_ATTRIBUTE_SUBENTRIES = "collectiveAttributeSubentries";
     
+    public static final String EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_OID = "2.5.18.0";
+    public static final String EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES = "excludeAllCollectiveAttributes";
+    
     /**
      * the search result filter to use for collective attribute injection
      */
@@ -127,11 +129,12 @@
          * may have case variance.
          */
         Attribute collectiveExclusions = entry.get( "collectiveExclusions" );
-        Set exclusions;
+        Set<String> exclusions = new HashSet<String>();
+        
         if ( collectiveExclusions != null )
         {
-            if ( collectiveExclusions.contains( "2.5.18.0" )
-                || collectiveExclusions.contains( "excludeAllCollectiveAttributes" ) )
+            if ( collectiveExclusions.contains( EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES_OID )
+                || collectiveExclusions.contains( EXCLUDE_ALL_COLLECTIVE_ATTRIBUTES ) )
             {
                 /*
                  * This entry does not allow any collective attributes
@@ -140,17 +143,14 @@
                 return;
             }
 
-            exclusions = new HashSet();
+            exclusions = new HashSet<String>();
+            
             for ( int ii = 0; ii < collectiveExclusions.size(); ii++ )
             {
                 AttributeType attrType = attrTypeRegistry.lookup( ( String ) collectiveExclusions.get(
ii ) );
                 exclusions.add( attrType.getOid() );
             }
         }
-        else
-        {
-            exclusions = Collections.EMPTY_SET;
-        }
         
         /*
          * If no attributes are requested specifically
@@ -165,10 +165,11 @@
         /*
          * Construct a set of requested attributes for easier tracking.
          */ 
-        HashSet retIdsSet = new HashSet( retAttrs.length );
-        for ( int ii = 0; ii < retAttrs.length; ii++ )
+        Set<String> retIdsSet = new HashSet<String>( retAttrs.length );
+        
+        for ( String retAttr:retAttrs )
         {
-            retIdsSet.add( retAttrs[ii].toLowerCase() );
+            retIdsSet.add( retAttr.toLowerCase() );
         }
 
         /*
@@ -182,6 +183,7 @@
             LdapDN subentryDn = new LdapDN( subentryDnStr );
             Attributes subentry = nexus.lookup( subentryDn );
             NamingEnumeration attrIds = subentry.getIDs();
+            
             while ( attrIds.hasMore() )
             {
                 String attrId = ( String ) attrIds.next();
@@ -249,10 +251,12 @@
     public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name ) throws NamingException
     {
         Attributes result = nextInterceptor.lookup( name );
+        
         if ( result == null )
         {
             return null;
         }
+        
         addCollectiveAttributes( name, result, new String[] { "*" } );
         return result;
     }
@@ -261,10 +265,12 @@
     public Attributes lookup( NextInterceptor nextInterceptor, LdapDN name, String[] attrIds
) throws NamingException
     {
         Attributes result = nextInterceptor.lookup( name, attrIds );
+        
         if ( result == null )
         {
             return null;
         }
+        
         addCollectiveAttributes( name, result, attrIds );
         return result;
     }
@@ -309,6 +315,4 @@
         collectiveAttributesSchemaChecker.checkModify( normName, mods );
         super.modify( next, normName, mods );
     }
-    
-
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java?view=diff&rev=504403&r1=504402&r2=504403
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java
Tue Feb  6 17:16:41 2007
@@ -79,6 +79,7 @@
         ModificationItemImpl[] modsAsArray = new ModificationItemImpl[ mods.size() ];
         NamingEnumeration allAttrs = mods.getAll();
         int i = 0;
+        
         while ( allAttrs.hasMoreElements() )
         {
             Attribute attr = ( Attribute ) allAttrs.nextElement();
@@ -115,14 +116,14 @@
     
     private boolean addsAnyCollectiveAttributes( ModificationItemImpl[] mods ) throws NamingException
     {
-        for ( int i = 0; i < mods.length; i++ )
+        for ( ModificationItemImpl mod:mods )
         {
-            Attribute attr = mods[i].getAttribute();
+            Attribute attr = mod.getAttribute();
             String attrID = attr.getID();
             AttributeType attrType = attrTypeRegistry.lookup( attrID );
-            int modOp = mods[i].getModificationOp();
+            int modOp = mod.getModificationOp();
             
-            if ( ( modOp == DirContext.ADD_ATTRIBUTE || modOp == DirContext.REPLACE_ATTRIBUTE
) &&
+            if ( ( ( modOp == DirContext.ADD_ATTRIBUTE ) || ( modOp == DirContext.REPLACE_ATTRIBUTE
) ) &&
                 attrType.isCollective() )
             {
                 return true;
@@ -136,10 +137,12 @@
     private boolean containsAnyCollectiveAttributes( Attributes entry ) throws NamingException
     {
         NamingEnumeration allIDs = entry.getIDs();
+        
         while ( allIDs.hasMoreElements() )
         {
             String attrTypeStr = ( String ) allIDs.nextElement();
             AttributeType attrType = attrTypeRegistry.lookup( attrTypeStr );
+            
             if ( attrType.isCollective() )
             {
                 return true;
@@ -148,6 +151,4 @@
         
         return false;
     }
-    
-
 }



Mime
View raw message