directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r937839 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry: DefaultServerEntry.java client/DefaultClientEntry.java
Date Sun, 25 Apr 2010 17:49:16 GMT
Author: elecharny
Date: Sun Apr 25 17:49:15 2010
New Revision: 937839

URL: http://svn.apache.org/viewvc?rev=937839&view=rev
Log:
Moved all the add() 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/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=937839&r1=937838&r2=937839&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 17:49:15 2010
@@ -84,36 +84,6 @@ public final class DefaultServerEntry ex
 
     
     /**
-     * Get the UpId if it was null.
-     */
-    public static String getUpId( String upId, AttributeType attributeType )
-    {
-        String normUpId = StringTools.trim( upId );
-
-        if ( ( attributeType == null ) )
-        {
-            if ( StringTools.isEmpty( normUpId ) )
-            {
-                String message = I18n.err( I18n.ERR_04458 );
-                LOG.error( message );
-                throw new IllegalArgumentException( message );
-            }
-        }
-        else if ( StringTools.isEmpty( normUpId ) )
-        {
-            upId = attributeType.getName();
-            
-            if ( StringTools.isEmpty( upId ) )
-            {
-                upId = attributeType.getOid();
-            }
-        }
-        
-        return upId;
-    }
-
-    
-    /**
      * This method is used to initialize the OBJECT_CLASS_AT attributeType.
      * 
      * We want to do it only once, so it's a synchronized method. Note that
@@ -451,178 +421,6 @@ public final class DefaultServerEntry ex
     // API
     //-------------------------------------------------------------------------
     /**
-     * <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
-     */
-    public void add( String upId, AttributeType attributeType, byte[]... values ) throws
LdapException
-    {
-        // 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 = (EntryAttribute)attributes.get( attributeType.getOid()
);
-        
-        upId = getUpId( upId, attributeType );
-        
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-            attribute.setUpId( upId, attributeType );
-        }
-        else
-        {
-            // We have to create a new Attribute and set the values
-            // and the upId
-            createAttribute( upId, attributeType, values );
-        }
-    }
-
-
-    /**
-     * <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
-     */
-    public void add( String upId, AttributeType attributeType, Value<?>... values )
throws LdapException
-    {
-        if ( attributeType == null )
-        {
-            String message = I18n.err( I18n.ERR_04460 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-        
-        upId = getUpId( upId, attributeType );
-        
-        EntryAttribute attribute = (EntryAttribute)attributes.get( attributeType.getOid()
);
-    
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-            attribute.setUpId( upId, attributeType );
-        }
-        else
-        {
-            createAttribute( upId, attributeType, values );
-        }
-    }
-
-    
-    /**
-     * 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 
-     */
-    public void add( String upId, AttributeType attributeType, String... values ) throws
LdapException
-    {
-        if ( attributeType == null )
-        {
-            String message = I18n.err( I18n.ERR_04460 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-        
-        upId = getUpId( upId, attributeType );
-
-        EntryAttribute attribute = (EntryAttribute)attributes.get( attributeType.getOid()
);
-        
-        if ( attribute != null )
-        {
-            // This Attribute already exist, we add the values 
-            // into it
-            attribute.add( values );
-            attribute.setUpId( upId, attributeType );
-        }
-        else
-        {
-            // We have to create a new Attribute and set the values
-            // and the upId
-            createAttribute( upId, attributeType, values );
-        }
-    }
-
-
-    /**                 
-     * 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
-     */
-    public void add( String upId, byte[]... values ) throws LdapException
-    {
-        add( upId, getAttributeType( upId ), values );
-    }
-
-
-    /**
-     * Add an attribute (represented by its ID and string values) into an entry. 
-     *
-     * @param upId The attribute ID
-     * @param values The list of string values to inject. It can be empty
-     * @throws LdapException If the attribute does not exist
-     */
-    public void add( String upId, String... values ) throws LdapException
-    {
-        add( upId, getAttributeType( upId ), values );
-    }
-
-
-    /**
-     * 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
-     */
-    public void add( String upId, Value<?>... values ) throws LdapException
-    {
-        add( upId, getAttributeType( upId ), values );
-    }
-
-
-    /**
      * Checks if an entry contains an attribute with some given binary values.
      *
      * @param attributeType The Attribute we are looking for.

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=937839&r1=937838&r2=937839&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 17:49:15 2010
@@ -167,6 +167,36 @@ public class DefaultClientEntry implemen
 
     
     /**
+     * Get the UpId if it was null.
+     */
+    public static String getUpId( String upId, AttributeType attributeType )
+    {
+        String normUpId = StringTools.trim( upId );
+
+        if ( ( attributeType == null ) )
+        {
+            if ( StringTools.isEmpty( normUpId ) )
+            {
+                String message = I18n.err( I18n.ERR_04458 );
+                LOG.error( message );
+                throw new IllegalArgumentException( message );
+            }
+        }
+        else if ( StringTools.isEmpty( normUpId ) )
+        {
+            upId = attributeType.getName();
+            
+            if ( StringTools.isEmpty( upId ) )
+            {
+                upId = attributeType.getOid();
+            }
+        }
+        
+        return upId;
+    }
+
+    
+    /**
      * Add a new EntryAttribute, with its upId. If the upId is null,
      * default to the AttributeType name.
      * 
@@ -310,6 +340,139 @@ 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
+     */
+    public void add( String upId, AttributeType attributeType, byte[]... values ) throws
LdapException
+    {
+        // 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 = (EntryAttribute)attributes.get( attributeType.getOid()
);
+        
+        upId = getUpId( upId, attributeType );
+        
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+            attribute.setUpId( upId, attributeType );
+        }
+        else
+        {
+            // We have to create a new Attribute and set the values
+            // and the upId
+            createAttribute( upId, attributeType, values );
+        }
+    }
+
+
+    /**
+     * <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
+     */
+    public void add( String upId, AttributeType attributeType, Value<?>... values )
throws LdapException
+    {
+        if ( attributeType == null )
+        {
+            String message = I18n.err( I18n.ERR_04460 );
+            LOG.error( message );
+            throw new IllegalArgumentException( message );
+        }
+        
+        upId = getUpId( upId, attributeType );
+        
+        EntryAttribute attribute = (EntryAttribute)attributes.get( attributeType.getOid()
);
+    
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+            attribute.setUpId( upId, attributeType );
+        }
+        else
+        {
+            createAttribute( upId, attributeType, values );
+        }
+    }
+
+    
+    /**
+     * 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 
+     */
+    public void add( String upId, AttributeType attributeType, String... values ) throws
LdapException
+    {
+        if ( attributeType == null )
+        {
+            String message = I18n.err( I18n.ERR_04460 );
+            LOG.error( message );
+            throw new IllegalArgumentException( message );
+        }
+        
+        upId = getUpId( upId, attributeType );
+
+        EntryAttribute attribute = (EntryAttribute)attributes.get( attributeType.getOid()
);
+        
+        if ( attribute != null )
+        {
+            // This Attribute already exist, we add the values 
+            // into it
+            attribute.add( values );
+            attribute.setUpId( upId, attributeType );
+        }
+        else
+        {
+            // We have to create a new Attribute and set the values
+            // and the upId
+            createAttribute( upId, attributeType, values );
+        }
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     public void add( EntryAttribute... attributes ) throws LdapException
@@ -378,22 +541,29 @@ public class DefaultClientEntry implemen
         // First, transform the upID to a valid ID
         String id = getId( upId );
         
-        // Now, check to see if we already have such an attribute
-        EntryAttribute attribute = attributes.get( id );
-        
-        if ( attribute != null )
+        if ( schemaManager != null )
         {
-            // This Attribute already exist, we add the values 
-            // into it. (If the values already exists, they will
-            // not be added, but this is done in the add() method)
-            attribute.add( values );
-            attribute.setUpId( upId );
+            add( upId, schemaManager.lookupAttributeTypeRegistry( id ), values );
         }
         else
         {
-            // We have to create a new Attribute and set the values
-            // and the upId
-            attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            // Now, check to see if we already have such an attribute
+            EntryAttribute attribute = attributes.get( id );
+            
+            if ( attribute != null )
+            {
+                // This Attribute already exist, we add the values 
+                // into it. (If the values already exists, they will
+                // not be added, but this is done in the add() method)
+                attribute.add( values );
+                attribute.setUpId( upId );
+            }
+            else
+            {
+                // We have to create a new Attribute and set the values
+                // and the upId
+                attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            }
         }
     }
 
@@ -411,22 +581,29 @@ public class DefaultClientEntry implemen
         // First, transform the upID to a valid ID
         String id = getId( upId );
 
-        // Now, check to see if we already have such an attribute
-        EntryAttribute attribute = attributes.get( id );
-        
-        if ( attribute != null )
+        if ( schemaManager != null )
         {
-            // This Attribute already exist, we add the values 
-            // into it. (If the values already exists, they will
-            // not be added, but this is done in the add() method)
-            attribute.add( values );
-            attribute.setUpId( upId );
+            add( upId, schemaManager.lookupAttributeTypeRegistry( upId ), values );
         }
         else
         {
-            // We have to create a new Attribute and set the values
-            // and the upId
-            attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            // Now, check to see if we already have such an attribute
+            EntryAttribute attribute = attributes.get( id );
+            
+            if ( attribute != null )
+            {
+                // This Attribute already exist, we add the values 
+                // into it. (If the values already exists, they will
+                // not be added, but this is done in the add() method)
+                attribute.add( values );
+                attribute.setUpId( upId );
+            }
+            else
+            {
+                // We have to create a new Attribute and set the values
+                // and the upId
+                attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            }
         }
     }
 
@@ -443,22 +620,29 @@ public class DefaultClientEntry implemen
         // First, transform the upID to a valid ID
         String id = getId( upId );
 
-        // Now, check to see if we already have such an attribute
-        EntryAttribute attribute = attributes.get( id );
-        
-        if ( attribute != null )
+        if ( schemaManager != null )
         {
-            // This Attribute already exist, we add the values 
-            // into it. (If the values already exists, they will
-            // not be added, but this is done in the add() method)
-            attribute.add( values );
-            attribute.setUpId( upId );
+            add( upId, schemaManager.lookupAttributeTypeRegistry( upId ), values );
         }
         else
         {
-            // We have to create a new Attribute and set the values
-            // and the upId
-            attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            // Now, check to see if we already have such an attribute
+            EntryAttribute attribute = attributes.get( id );
+            
+            if ( attribute != null )
+            {
+                // This Attribute already exist, we add the values 
+                // into it. (If the values already exists, they will
+                // not be added, but this is done in the add() method)
+                attribute.add( values );
+                attribute.setUpId( upId );
+            }
+            else
+            {
+                // We have to create a new Attribute and set the values
+                // and the upId
+                attributes.put( id, new DefaultEntryAttribute( upId, values ) );
+            }
         }
     }
 



Mime
View raw message