Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 68734 invoked from network); 2 Feb 2007 20:20:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Feb 2007 20:20:26 -0000 Received: (qmail 66729 invoked by uid 500); 2 Feb 2007 20:20:33 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 66688 invoked by uid 500); 2 Feb 2007 20:20:33 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 66677 invoked by uid 99); 2 Feb 2007 20:20:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 12:20:33 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Feb 2007 12:20:26 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id B78CA1A981D; Fri, 2 Feb 2007 12:20:05 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070202202005.B78CA1A981D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; }