Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 69354 invoked from network); 25 Apr 2010 20:27:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Apr 2010 20:27:04 -0000 Received: (qmail 44617 invoked by uid 500); 25 Apr 2010 20:27:04 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44584 invoked by uid 500); 25 Apr 2010 20:27:04 -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 44577 invoked by uid 99); 25 Apr 2010 20:27:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 20:27:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 20:27:00 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3F9B223889F1; Sun, 25 Apr 2010 20:26:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r937868 - in /directory/shared/trunk/ldap/src: main/java/org/apache/directory/shared/ldap/entry/ main/java/org/apache/directory/shared/ldap/entry/client/ test/java/org/apache/directory/shared/ldap/entry/client/ Date: Sun, 25 Apr 2010 20:26:15 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100425202615.3F9B223889F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Sun Apr 25 20:26:14 2010 New Revision: 937868 URL: http://svn.apache.org/viewvc?rev=937868&view=rev Log: Moved the get(AttributeType) method from ServerEntry to ClientEntry Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java?rev=937868&r1=937867&r2=937868&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultServerEntry.java Sun Apr 25 20:26:14 2010 @@ -701,65 +701,6 @@ public final class DefaultServerEntry ex return true; } - - /** - *

- * Returns the attribute with the specified AttributeType. The return value - * is null if no match is found. - *

- * - * @param attributeType The attributeType we are looking for. - * @return the attribute associated with the AttributeType. - */ - /** - * Returns the attribute associated with an AttributeType - * - * @param attributeType the AttributeType we are looking for - * @return the associated attribute - */ - public EntryAttribute get( AttributeType attributeType ) - { - if ( attributeType != null ) - { - return attributes.get( attributeType.getOid() ); - } - else - { - return null; - } - } - - - /** - *

- * Returns the attribute with the specified alias. The return value - * is null if no match is found. - *

- *

An Attribute with an id different from the supplied alias may - * be returned: for example a call with 'cn' may in some implementations - * return an Attribute whose getId() field returns 'commonName'. - *

- *

- * If the attributeType is not found, returns null. - *

- * - * @param alias an aliased name of the attribute identifier - * @return the attribute associated with the alias - */ - public EntryAttribute get( String alias ) - { - try - { - return get( schemaManager.lookupAttributeTypeRegistry( StringTools.trim( StringTools.toLowerCase( alias ) ) ) ); - } - catch ( LdapException ne ) - { - String message = ne.getLocalizedMessage(); - LOG.error( message ); - return null; - } - } - /** * Gets all the attributes type Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java?rev=937868&r1=937867&r2=937868&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Entry.java Sun Apr 25 20:26:14 2010 @@ -91,6 +91,24 @@ public interface Entry extends Cloneable */ EntryAttribute get( String alias ); + + /** + *

+ * Returns the attribute with the specified AttributeType. The return value + * is null if no match is found. + *

+ * + * @param attributeType The attributeType we are looking for. + * @return the attribute associated with the AttributeType. + */ + /** + * Returns the attribute associated with an AttributeType + * + * @param the AttributeType we are looking for + * @return the associated attribute + */ + EntryAttribute get( AttributeType attributeType ); + /** *

@@ -199,6 +217,72 @@ public interface Entry extends Cloneable /** + *

+ * Add an attribute (represented by its AttributeType and some binary values) into an + * entry. Set the User Provider ID at the same time + *

+ *

+ * If we already have an attribute with the same values, the duplicated values + * are not added (duplicated values are not allowed) + *

+ *

+ * If the value cannot be added, or if the AttributeType is null or invalid, + * a LdapException is thrown. + *

+ * + * @param upId The user provided ID for the added AttributeType + * @param attributeType The attribute Type. + * @param values The list of binary values to add. It can be empty. + * @throws LdapException If the attribute does not exist + */ + void add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException; + + + /** + *

+ * Add an attribute (represented by its AttributeType and some String values) into an + * entry. Set the User Provider ID at the same time + *

+ *

+ * If we already have an attribute with the same values, the duplicated values + * are not added (duplicated values are not allowed) + *

+ *

+ * If the value cannot be added, or if the AttributeType is null or invalid, + * a LdapException is thrown. + *

+ * + * @param upId The user provided ID for the added AttributeType + * @param attributeType The attribute Type. + * @param values The list of binary values to add. It can be empty. + * @throws LdapException If the attribute does not exist + */ + void add( String upId, AttributeType attributeType, String... values ) throws LdapException; + + + /** + *

+ * Add an attribute (represented by its AttributeType and some values) into an + * entry. Set the User Provider ID at the same time + *

+ *

+ * If we already have an attribute with the same values, nothing is done + * (duplicated values are not allowed) + *

+ *

+ * If the value cannot be added, or if the AttributeType is null or invalid, + * a LdapException is thrown. + *

+ * + * @param upId The user provided ID for the added AttributeType + * @param attributeType The attribute Type. + * @param values The list of values to add. It can be empty. + * @throws LdapException If the attribute does not exist + */ + void add( String upId, AttributeType attributeType, Value... values ) throws LdapException; + + + /** * Add some String values to the current Entry. * * @param upId The user provided ID of the attribute we want to add Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java?rev=937868&r1=937867&r2=937868&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/ServerEntry.java Sun Apr 25 20:26:14 2010 @@ -34,72 +34,6 @@ import org.apache.directory.shared.ldap. */ public interface ServerEntry extends Entry, Cloneable { - /** - *

- * Add an attribute (represented by its AttributeType and some binary values) into an - * entry. Set the User Provider ID at the same time - *

- *

- * If we already have an attribute with the same values, the duplicated values - * are not added (duplicated values are not allowed) - *

- *

- * If the value cannot be added, or if the AttributeType is null or invalid, - * a LdapException is thrown. - *

- * - * @param upId The user provided ID for the added AttributeType - * @param attributeType The attribute Type. - * @param values The list of binary values to add. It can be empty. - * @throws LdapException If the attribute does not exist - */ - void add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException; - - - /** - *

- * Add an attribute (represented by its AttributeType and some String values) into an - * entry. Set the User Provider ID at the same time - *

- *

- * If we already have an attribute with the same values, the duplicated values - * are not added (duplicated values are not allowed) - *

- *

- * If the value cannot be added, or if the AttributeType is null or invalid, - * a LdapException is thrown. - *

- * - * @param upId The user provided ID for the added AttributeType - * @param attributeType The attribute Type. - * @param values The list of binary values to add. It can be empty. - * @throws LdapException If the attribute does not exist - */ - void add( String upId, AttributeType attributeType, String... values ) throws LdapException; - - - /** - *

- * Add an attribute (represented by its AttributeType and some values) into an - * entry. Set the User Provider ID at the same time - *

- *

- * If we already have an attribute with the same values, nothing is done - * (duplicated values are not allowed) - *

- *

- * If the value cannot be added, or if the AttributeType is null or invalid, - * a LdapException is thrown. - *

- * - * @param upId The user provided ID for the added AttributeType - * @param attributeType The attribute Type. - * @param values The list of values to add. It can be empty. - * @throws LdapException If the attribute does not exist - */ - void add( String upId, AttributeType attributeType, Value... values ) throws LdapException; - - // ----------------------------------------------------------------------- // Container (get/put/remove) Methods // ----------------------------------------------------------------------- @@ -149,24 +83,6 @@ public interface ServerEntry extends Ent /** - *

- * Returns the attribute with the specified AttributeType. The return value - * is null if no match is found. - *

- * - * @param attributeType The attributeType we are looking for. - * @return the attribute associated with the AttributeType. - */ - /** - * Returns the attribute associated with an AttributeType - * - * @param the AttributeType we are looking for - * @return the associated attribute - */ - EntryAttribute get( AttributeType attributeType ); - - - /** * Gets all the attributes type * * @return The combined set of all the attributes. Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java?rev=937868&r1=937867&r2=937868&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java (original) +++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java Sun Apr 25 20:26:14 2010 @@ -340,23 +340,7 @@ public class DefaultClientEntry implemen /** - *

- * Add an attribute (represented by its AttributeType and some binary values) into an - * entry. Set the User Provider ID at the same time - *

- *

- * If we already have an attribute with the same values, nothing is done - * (duplicated values are not allowed) - *

- *

- * If the value cannot be added, or if the AttributeType is null or invalid, - * a LdapException is thrown. - *

- * - * @param upId The user provided ID for the added AttributeType - * @param attributeType The attribute Type. - * @param values The list of binary values to add. It can be empty. - * @throws LdapException If the attribute does not exist + * {@inheritDoc} */ public void add( String upId, AttributeType attributeType, byte[]... values ) throws LdapException { @@ -389,23 +373,7 @@ public class DefaultClientEntry implemen /** - *

- * Add an attribute (represented by its AttributeType and some values) into an - * entry. Set the User Provider ID at the same time - *

- *

- * If we already have an attribute with the same values, nothing is done - * (duplicated values are not allowed) - *

- *

- * If the value cannot be added, or if the AttributeType is null or invalid, - * a LdapException is thrown. - *

- * - * @param upId The user provided ID for the added AttributeType - * @param attributeType The attribute Type. - * @param values The list of values to add. It can be empty. - * @throws LdapException If the attribute does not exist + * {@inheritDoc} */ public void add( String upId, AttributeType attributeType, Value... values ) throws LdapException { @@ -435,13 +403,7 @@ public class DefaultClientEntry implemen /** - * Adds a new attribute with some String values into an entry, setting - * the User Provided ID in the same time. - * - * @param upId The User provided ID - * @param attributeType The associated AttributeType - * @param values The String values to store into the new Attribute - * @throws LdapException + * {@inheritDoc} */ public void add( String upId, AttributeType attributeType, String... values ) throws LdapException { @@ -530,11 +492,7 @@ public class DefaultClientEntry implemen /** - * Add an attribute (represented by its ID and binary values) into an entry. - * - * @param upId The attribute ID - * @param values The list of binary values to inject. It can be empty - * @throws LdapException If the attribute does not exist + * {@inheritDoc} */ public void add( String upId, byte[]... values ) throws LdapException { @@ -569,12 +527,7 @@ public class DefaultClientEntry implemen /** - * Add some String values to the current Entry. - * - * @param upId The user provided ID of the attribute we want to add - * some values to - * @param values The list of String values to add - * @throws LdapException If we can't add any of the values + * {@inheritDoc} */ public void add( String upId, String... values ) throws LdapException { @@ -609,11 +562,7 @@ public class DefaultClientEntry implemen /** - * Add an attribute (represented by its ID and Value values) into an entry. - * - * @param upId The attribute ID - * @param values The list of Value values to inject. It can be empty - * @throws LdapException If the attribute does not exist + * {@inheritDoc} */ public void add( String upId, Value... values ) throws LdapException { @@ -851,7 +800,25 @@ public class DefaultClientEntry implemen { String id = getId( alias ); - return attributes.get( id ); + if ( schemaManager != null ) + { + try + { + AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); + + return attributes.get( attributeType.getOid() ); + } + catch ( LdapException ne ) + { + String message = ne.getLocalizedMessage(); + LOG.error( message ); + return null; + } + } + else + { + return attributes.get( id ); + } } catch( IllegalArgumentException iea ) { @@ -859,6 +826,22 @@ public class DefaultClientEntry implemen return null; } } + + + /** + * {@inheritDoc} + */ + public EntryAttribute get( AttributeType attributeType ) + { + if ( attributeType != null ) + { + return attributes.get( attributeType.getOid() ); + } + else + { + return null; + } + } /** Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java?rev=937868&r1=937867&r2=937868&view=diff ============================================================================== --- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java (original) +++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntryTest.java Sun Apr 25 20:26:14 2010 @@ -702,7 +702,7 @@ public class DefaultClientEntryTest assertEquals( attribute, attrCN ); - assertNull( entry.get( null ) ); + assertNull( entry.get( (String)null ) ); assertNull( entry.get( " " ) ); assertNull( entry.get( "l" ) ); }