directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
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 GMT
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;
     }
 
-    
-    /**
-     * <p>
-     * Returns the attribute with the specified AttributeType. The return value
-     * is <code>null</code> if no match is found.  
-     * </p>
-     *
-     * @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;
-        }
-    }
-
-
-    /**
-     * <p>
-     * Returns the attribute with the specified alias. The return value
-     * is <code>null</code> if no match is found.  
-     * </p>
-     * <p>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'.
-     * </p>
-     * <p>
-     * If the attributeType is not found, returns null.
-     * </p>
-     *
-     * @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 );
 
+    
+    /**
+     * <p>
+     * Returns the attribute with the specified AttributeType. The return value
+     * is <code>null</code> if no match is found.  
+     * </p>
+     *
+     * @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 );
+
 
     /**
      * <p>
@@ -199,6 +217,72 @@ public interface Entry extends Cloneable
 
     
     /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some binary values) into an

+     * entry. Set the User Provider ID at the same time
+     * </p>
+     * <p> 
+     * If we already have an attribute with the same values, the duplicated values 
+     * are not added (duplicated values are not allowed)
+     * </p>
+     * <p>
+     * If the value cannot be added, or if the AttributeType is null or invalid, 
+     * a LdapException is thrown.
+     * </p>
+     *
+     * @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;
+
+    
+    /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some String values) into an

+     * entry. Set the User Provider ID at the same time
+     * </p>
+     * <p> 
+     * If we already have an attribute with the same values, the duplicated values 
+     * are not added (duplicated values are not allowed)
+     * </p>
+     * <p>
+     * If the value cannot be added, or if the AttributeType is null or invalid, 
+     * a LdapException is thrown.
+     * </p>
+     *
+     * @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;
+
+    
+    /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some values) into an 
+     * entry. Set the User Provider ID at the same time
+     * </p>
+     * <p> 
+     * If we already have an attribute with the same values, nothing is done 
+     * (duplicated values are not allowed)
+     * </p>
+     * <p>
+     * If the value cannot be added, or if the AttributeType is null or invalid, 
+     * a LdapException is thrown.
+     * </p>
+     *
+     * @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
 {
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some binary values) into an

-     * entry. Set the User Provider ID at the same time
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same values, the duplicated values 
-     * are not added (duplicated values are not allowed)
-     * </p>
-     * <p>
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *
-     * @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;
-
-    
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some String values) into an

-     * entry. Set the User Provider ID at the same time
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same values, the duplicated values 
-     * are not added (duplicated values are not allowed)
-     * </p>
-     * <p>
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *
-     * @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;
-
-    
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some values) into an 
-     * entry. Set the User Provider ID at the same time
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same values, nothing is done 
-     * (duplicated values are not allowed)
-     * </p>
-     * <p>
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *
-     * @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
 
     
     /**
-     * <p>
-     * Returns the attribute with the specified AttributeType. The return value
-     * is <code>null</code> if no match is found.  
-     * </p>
-     *
-     * @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
 
 
     /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some binary values) into an

-     * entry. Set the User Provider ID at the same time
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same values, nothing is done 
-     * (duplicated values are not allowed)
-     * </p>
-     * <p>
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *
-     * @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
 
 
     /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some values) into an 
-     * entry. Set the User Provider ID at the same time
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same values, nothing is done 
-     * (duplicated values are not allowed)
-     * </p>
-     * <p>
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *
-     * @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" ) );
     }



Mime
View raw message