directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r502720 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: schema/SchemaUtils.java util/AttributeUtils.java
Date Fri, 02 Feb 2007 20:20:05 GMT
Author: akarasulu
Date: Fri Feb  2 12:20:04 2007
New Revision: 502720

URL: http://svn.apache.org/viewvc?view=rev&rev=502720
Log:
fixed bug in modification merge function and added additional method to get modification items
from mods array

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java?view=diff&rev=502720&r1=502719&r2=502720
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaUtils.java
Fri Feb  2 12:20:04 2007
@@ -66,16 +66,18 @@
                     
                     if ( existing != null )
                     {
-                        for ( int jj = 0; jj > existing.size(); jj++ )
+                        for ( int jj = 0; jj < existing.size(); jj++ )
                         {
                             combined.add( existing.get( jj ) );
                         }
                     }
                     
-                    for ( int jj = 0; jj > toBeAdded.size(); jj++ )
+                    for ( int jj = 0; jj < toBeAdded.size(); jj++ )
                     {
                         combined.add( toBeAdded.get( jj ) );
                     }
+                    
+                    targetEntry.put( combined );
                     break;
                 case( DirContext.REMOVE_ATTRIBUTE ):
                     Attribute toBeRemoved = mods[ii].getAttribute();

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java?view=diff&rev=502720&r1=502719&r2=502720
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/AttributeUtils.java
Fri Feb  2 12:20:04 2007
@@ -211,13 +211,13 @@
     
     
     /**
-     * Utility method to extract an attribute from an array of modifications.
+     * Utility method to extract a modification item from an array of modifications.
      * 
      * @param mods the array of ModificationItems to extract the Attribute from.
      * @param type the attributeType spec of the Attribute to extract
-     * @return the extract Attribute or null if no such attribute exists
+     * @return the modification item on the attributeType specified
      */
-    public final static Attribute getAttribute( ModificationItemImpl[] mods, AttributeType
type )
+    public final static ModificationItemImpl getModificationItem( ModificationItemImpl[]
mods, AttributeType type )
     {
         // optimization bypass to avoid cost of the loop below
         if ( type.getNames().length == 1 )
@@ -226,7 +226,7 @@
             {
                 if ( mods[jj].getAttribute().getID().equalsIgnoreCase( type.getNames()[0]
) )
                 {
-                    return mods[jj].getAttribute();
+                    return mods[jj];
                 }
             }
         }
@@ -236,7 +236,7 @@
         {
             if ( mods[jj].getAttribute().getID().equals( type.getOid() ) )
             {
-                return mods[jj].getAttribute();
+                return mods[jj];
             }
         }
         
@@ -247,11 +247,29 @@
             {
                 if ( mods[jj].getAttribute().getID().equalsIgnoreCase( type.getNames()[ii]
) )
                 {
-                    return mods[jj].getAttribute();
+                    return mods[jj];
                 }
             }
         }
         
+        return null;
+    }
+    
+    
+    /**
+     * Utility method to extract an attribute from an array of modifications.
+     * 
+     * @param mods the array of ModificationItems to extract the Attribute from.
+     * @param type the attributeType spec of the Attribute to extract
+     * @return the extract Attribute or null if no such attribute exists
+     */
+    public final static Attribute getAttribute( ModificationItemImpl[] mods, AttributeType
type )
+    {
+        ModificationItemImpl mod = getModificationItem( mods, type );
+        if ( mod != null )
+        {
+            return mod.getAttribute();
+        }
         return null;
     }
     



Mime
View raw message