You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/04/25 18:56:07 UTC

svn commit: r937820 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry: DefaultServerEntry.java Entry.java ServerEntry.java client/DefaultClientEntry.java

Author: elecharny
Date: Sun Apr 25 16:56:06 2010
New Revision: 937820

URL: http://svn.apache.org/viewvc?rev=937820&view=rev
Log:
o Moved the add(AttributeType...) methods 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

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=937820&r1=937819&r2=937820&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 16:56:06 2010
@@ -143,48 +143,6 @@ public final class DefaultServerEntry ex
     }
 
     
-    /**
-     * Add a new ServerAttribute, with its upId. If the upId is null,
-     * default to the AttributeType name.
-     * 
-     * Updates the serverAttributeMap.
-     */
-    private void createAttribute( String upId, AttributeType attributeType, byte[]... values ) 
-    {
-        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
-        attribute.setUpId( upId, attributeType );
-        attributes.put( attributeType.getOid(), attribute );
-    }
-    
-    
-    /**
-     * Add a new ServerAttribute, with its upId. If the upId is null,
-     * default to the AttributeType name.
-     * 
-     * Updates the serverAttributeMap.
-     */
-    private void createAttribute( String upId, AttributeType attributeType, String... values ) 
-    {
-        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
-        attribute.setUpId( upId, attributeType );
-        attributes.put( attributeType.getOid(), attribute );
-    }
-    
-    
-    /**
-     * Add a new ServerAttribute, with its upId. If the upId is null,
-     * default to the AttributeType name.
-     * 
-     * Updates the serverAttributeMap.
-     */
-    private void createAttribute( String upId, AttributeType attributeType, Value<?>... values ) 
-    {
-        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
-        attribute.setUpId( upId, attributeType );
-        attributes.put( attributeType.getOid(), attribute );
-    }
-    
-    
     //-------------------------------------------------------------------------
     // Constructors
     //-------------------------------------------------------------------------
@@ -495,184 +453,6 @@ public final class DefaultServerEntry ex
     /**
      * <p>
      * Add an attribute (represented by its AttributeType and some binary values) into an 
-     * entry.
-     * </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 attributeType The attribute Type.
-     * @param values The list of binary values to inject. It can be empty.
-     * @throws LdapException If the attribute does not exist
-     */
-    public void add( AttributeType attributeType, byte[]... values ) throws LdapException
-    {
-        if ( attributeType == null )
-        {
-            String message = I18n.err( I18n.ERR_04460 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-        
-        // ObjectClass with binary values are not allowed
-        if ( attributeType.equals( OBJECT_CLASS_AT ) )
-        {
-            String message = I18n.err( I18n.ERR_04461 );
-            LOG.error(  message  );
-            throw new UnsupportedOperationException( message );
-        }
-
-        EntryAttribute attribute = attributes.get( attributeType.getOid() );
-        
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-        }
-        else
-        {
-            // We have to create a new Attribute and set the values.
-            // The upId, which is set to null, will be setup by the 
-            // createAttribute method
-            createAttribute( null, attributeType, values );
-        }
-    }
-
-
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some String values) into an 
-     * entry.
-     * </p>
-     * <p> 
-     * If we already have an attribute with public the same value, nothing is done 
-     * (duplicated values are not allowed)
-     * </p>
-     * <p>public 
-     * If the value cannot be added, or if the AttributeType is null or invalid, 
-     * a LdapException is thrown.
-     * </p>
-     *public 
-     * @param attributeType The attribute Type
-     * @param values The list of binary values to inject. It can be empty
-     * @throws LdapException If the attribute does not exist
-     */
-    public void add( AttributeType attributeType, String... values ) throws LdapException
-    {    
-        if ( attributeType == null )
-        {
-            String message = I18n.err( I18n.ERR_04460 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-        
-        EntryAttribute attribute = attributes.get( attributeType.getOid() );
-        
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-        }
-        else
-        {
-            // We have to create a new Attribute and set the values.
-            // The upId, which is set to null, will be setup by the 
-            // createAttribute method
-            createAttribute( null, attributeType, values );
-        }
-    }
-
-    
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some values) into an 
-     * entry.
-     * </p>
-     * <p> 
-     * If we already have an attribute with the same value, 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 attributeType The attribute Type
-     * @param values The list of binary values to inject. It can be empty
-     * @throws LdapException If the attribute does not exist
-     */
-    public void add( AttributeType attributeType, Value<?>... values ) throws LdapException
-    {
-        if ( attributeType == null )
-        {
-            String message = I18n.err( I18n.ERR_04460 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-        
-        EntryAttribute attribute = attributes.get( attributeType.getOid() );
-    
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-        }
-        else
-        {
-            // We have to create a new Attribute and set the values.
-            // The upId, which is set to null, will be setup by the 
-            // createAttribute method
-            createAttribute( null, attributeType, values );
-        }
-    }
-
-
-    /**
-     * Add some EntryAttributes to the current Entry.
-     *
-     * @param attributes The attributes to add
-     * @throws LdapException If we can't add any of the attributes
-     */
-    public void add( EntryAttribute... attributes ) throws LdapException
-    {
-        for ( EntryAttribute attribute:attributes )
-        {
-            AttributeType attributeType = attribute.getAttributeType();
-            
-            if ( this.attributes.containsKey( attributeType.getOid() ) )
-            {
-                // We already have an attribute with the same AttributeType
-                // Just add the new values into it.
-                EntryAttribute oldAttribute = this.attributes.get( attributeType.getOid() );
-                
-                for ( Value<?> value:attribute )
-                {
-                    oldAttribute.add( value );
-                }
-                
-                // And update the upId
-                oldAttribute.setUpId( attribute.getUpId() );
-            }
-            else
-            {
-                // The attributeType does not exist, add it
-                this.attributes.put( attributeType.getOid(), attribute );
-            }
-        }
-    }
-
-
-    /**
-     * <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> 

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=937820&r1=937819&r2=937820&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 16:56:06 2010
@@ -26,6 +26,7 @@ import java.util.List;
 import org.apache.directory.shared.ldap.exception.LdapException;
 
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 
 
 /**
@@ -135,6 +136,69 @@ public interface Entry extends Cloneable
 
 
     /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some binary values) into an 
+     * entry.
+     * </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 attributeType The attribute Type.
+     * @param values The list of binary values to inject. It can be empty.
+     * @throws LdapException If the attribute does not exist
+     */
+    void add( AttributeType attributeType, byte[]... values ) throws LdapException;
+
+    
+    /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some String values) into an 
+     * entry.
+     * </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 attributeType The attribute Type
+     * @param values The list of binary values to inject. It can be empty
+     * @throws LdapException If the attribute does not exist
+     */
+    void add( AttributeType attributeType, String... values ) throws LdapException;
+
+    
+    /**
+     * <p>
+     * Add an attribute (represented by its AttributeType and some values) into an 
+     * entry.
+     * </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 attributeType The attribute Type
+     * @param values The list of binary values to inject. It can be empty
+     * @throws LdapException If the attribute does not exist
+     */
+    void add( 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=937820&r1=937819&r2=937820&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 16:56:06 2010
@@ -37,69 +37,6 @@ public interface ServerEntry extends Ent
     /**
      * <p>
      * Add an attribute (represented by its AttributeType and some binary values) into an 
-     * entry.
-     * </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 attributeType The attribute Type.
-     * @param values The list of binary values to inject. It can be empty.
-     * @throws LdapException If the attribute does not exist
-     */
-    void add( AttributeType attributeType, byte[]... values ) throws LdapException;
-
-    
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some String values) into an 
-     * entry.
-     * </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 attributeType The attribute Type
-     * @param values The list of binary values to inject. It can be empty
-     * @throws LdapException If the attribute does not exist
-     */
-    void add( AttributeType attributeType, String... values ) throws LdapException;
-
-    
-    /**
-     * <p>
-     * Add an attribute (represented by its AttributeType and some values) into an 
-     * entry.
-     * </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 attributeType The attribute Type
-     * @param values The list of binary values to inject. It can be empty
-     * @throws LdapException If the attribute does not exist
-     */
-    void add( AttributeType attributeType, Value<?>... values ) throws LdapException;
-
-    
-    /**
-     * <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> 

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=937820&r1=937819&r2=937820&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 16:56:06 2010
@@ -166,14 +166,151 @@ public class DefaultClientEntry implemen
     }
 
     
+    /**
+     * Add a new EntryAttribute, with its upId. If the upId is null,
+     * default to the AttributeType name.
+     * 
+     * Updates the AttributeMap.
+     */
+    protected void createAttribute( String upId, AttributeType attributeType, byte[]... values ) 
+    {
+        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
+        attribute.setUpId( upId, attributeType );
+        attributes.put( attributeType.getOid(), attribute );
+    }
+    
+    
+    /**
+     * Add a new EntryAttribute, with its upId. If the upId is null,
+     * default to the AttributeType name.
+     * 
+     * Updates the AttributeMap.
+     */
+    protected void createAttribute( String upId, AttributeType attributeType, String... values ) 
+    {
+        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
+        attribute.setUpId( upId, attributeType );
+        attributes.put( attributeType.getOid(), attribute );
+    }
+    
+    
+    /**
+     * Add a new EntryAttribute, with its upId. If the upId is null,
+     * default to the AttributeType name.
+     * 
+     * Updates the AttributeMap.
+     */
+    protected void createAttribute( String upId, AttributeType attributeType, Value<?>... values ) 
+    {
+        EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
+        attribute.setUpId( upId, attributeType );
+        attributes.put( attributeType.getOid(), attribute );
+    }
+    
+    
     //-------------------------------------------------------------------------
     // Entry methods
     //-------------------------------------------------------------------------
     /**
-     * Add some Attributes to the current Entry.
-     *
-     * @param attributes The attributes to add
-     * @throws LdapException If we can't add any of the attributes
+     * {@inheritDoc}
+     */
+    public void add( AttributeType attributeType, byte[]... values ) throws LdapException
+    {
+        if ( attributeType == null )
+        {
+            String message = I18n.err( I18n.ERR_04460 );
+            LOG.error( message );
+            throw new IllegalArgumentException( message );
+        }
+        
+        // ObjectClass with binary values are not allowed
+        if ( attributeType.equals( OBJECT_CLASS_AT ) )
+        {
+            String message = I18n.err( I18n.ERR_04461 );
+            LOG.error(  message  );
+            throw new UnsupportedOperationException( message );
+        }
+
+        EntryAttribute attribute = attributes.get( attributeType.getOid() );
+        
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+        }
+        else
+        {
+            // We have to create a new Attribute and set the values.
+            // The upId, which is set to null, will be setup by the 
+            // createAttribute method
+            createAttribute( null, attributeType, values );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void add( AttributeType attributeType, String... values ) throws LdapException
+    {    
+        if ( attributeType == null )
+        {
+            String message = I18n.err( I18n.ERR_04460 );
+            LOG.error( message );
+            throw new IllegalArgumentException( message );
+        }
+        
+        EntryAttribute attribute = attributes.get( attributeType.getOid() );
+        
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+        }
+        else
+        {
+            // We have to create a new Attribute and set the values.
+            // The upId, which is set to null, will be setup by the 
+            // createAttribute method
+            createAttribute( null, attributeType, values );
+        }
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void add( AttributeType attributeType, Value<?>... values ) throws LdapException
+    {
+        if ( attributeType == null )
+        {
+            String message = I18n.err( I18n.ERR_04460 );
+            LOG.error( message );
+            throw new IllegalArgumentException( message );
+        }
+        
+        EntryAttribute attribute = attributes.get( attributeType.getOid() );
+    
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+        }
+        else
+        {
+            // We have to create a new Attribute and set the values.
+            // The upId, which is set to null, will be setup by the 
+            // createAttribute method
+            createAttribute( null, attributeType, values );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
      */
     public void add( EntryAttribute... attributes ) throws LdapException
     {