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 2011/04/07 01:00:12 UTC

svn commit: r1089658 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/ apacheds/trunk/core/src/main/java/org/apache/directory/ser...

Author: elecharny
Date: Wed Apr  6 23:00:11 2011
New Revision: 1089658

URL: http://svn.apache.org/viewvc?rev=1089658&view=rev
Log:
o Removed the set( String... ) method
o Fixed the impacted tests

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
    directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java Wed Apr  6 23:00:11 2011
@@ -376,12 +376,6 @@ public class ClonedServerEntry implement
     }
 
 
-    public List<Attribute> set( String... upIds )
-    {
-        return clonedEntry.set( upIds );
-    }
-
-
     public void setDn( Dn dn )
     {
         clonedEntry.setDn( dn );

Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java (original)
+++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/entry/SchemaAwareEntryTest.java Wed Apr  6 23:00:11 2011
@@ -3545,123 +3545,6 @@ public class SchemaAwareEntryTest
 
 
     /**
-     * Test the set( upId ) method
-     */
-    @Test
-    public void testSetUpID() throws Exception
-    {
-        Dn dn = new Dn( schemaManager, "cn=test" );
-        DefaultEntry entry = new DefaultEntry( schemaManager, dn );
-        List<Attribute> result = null;
-
-        // First check that this method fails if we pass a null or empty ID
-        try
-        {
-            result = entry.set( ( String ) null );
-            fail();
-        }
-        catch ( IllegalArgumentException iae )
-        {
-            // expected
-        }
-
-        result = entry.set( "  " );
-        assertNull( result );
-
-        // Now check that we can't put invalid IDs
-        result = entry.set( "ThisIsNotAnAttributeType" );
-        assertNull( result );
-
-        // Now, check what we get when adding one existing AT
-        result = entry.set( "sn" );
-
-        assertNull( result );
-
-        Attribute sa = entry.get( "sn" );
-        assertNotNull( sa );
-        assertEquals( "2.5.4.4", sa.getId() );
-
-        // Add different upIds now
-        AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
-        AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
-
-        entry.set( "L" );
-        entry.set( "CountryName" );
-        entry.set( "gn" );
-        entry.set( "2.5.4.9" );
-
-        sa = entry.get( "l" );
-        assertNotNull( sa );
-        assertEquals( atL, sa.getAttributeType() );
-        assertEquals( "2.5.4.7", sa.getId() );
-        assertEquals( "L", sa.getUpId() );
-
-        sa = entry.get( "c" );
-        assertNotNull( sa );
-        assertEquals( atC, sa.getAttributeType() );
-        assertEquals( "2.5.4.6", sa.getId() );
-        assertEquals( "CountryName", sa.getUpId() );
-
-        sa = entry.get( "2.5.4.9" );
-        assertNotNull( sa );
-        assertEquals( atStreet, sa.getAttributeType() );
-        assertEquals( "2.5.4.9", sa.getId() );
-        assertEquals( "2.5.4.9", sa.getUpId() );
-
-        sa = entry.get( "givenName" );
-        assertNotNull( sa );
-        assertEquals( atGN, sa.getAttributeType() );
-        assertEquals( "2.5.4.42", sa.getId() );
-        assertEquals( "gn", sa.getUpId() );
-
-        // Now try to add existing ATs
-        // First, set some value to the modified AT
-        sa = entry.get( "sn" );
-        sa.add( "test" );
-
-        // Check that the value has been added to the entry
-        assertEquals( "test", entry.get( "sn" ).get().getString() );
-
-        // Now add a new SN empty AT : it should replace the existing one.
-        AttributeType atSNEmpty = schemaManager.lookupAttributeTypeRegistry( "sn" );
-        sa = entry.set( atSNEmpty ).get( 0 );
-        assertEquals( "test", sa.get().getString() );
-        assertNotNull( entry.get( "sn" ) );
-        assertNull( entry.get( "sn" ).get() );
-    }
-
-
-    /**
-     * Test method for set( String... )
-     */
-    @Test
-    public void testSetStringArray() throws Exception
-    {
-        Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
-
-        entry.add( "ObjectClass", "top", "person" );
-        entry.add( "cn", "test1", "test2" );
-        entry.add( "sn", "Test" );
-
-        List<Attribute> removed = entry.set( "objectClass", "CN", "givenName" );
-
-        assertEquals( 4, entry.size() );
-        assertNotNull( entry.get( "objectclass" ) );
-        assertNotNull( entry.get( "cn" ) );
-        assertNotNull( entry.get( "givenname" ) );
-        assertNotNull( entry.get( "sn" ) );
-
-        assertNull( entry.get( "objectclass" ).get() );
-        assertNull( entry.get( "cn" ).get() );
-        assertNull( entry.get( "givenname" ).get() );
-        assertNotNull( entry.get( "sn" ).get() );
-
-        assertNotNull( removed );
-        assertEquals( 2, removed.size() );
-    }
-
-
-    /**
      * Test method for setDN( Dn )
      */
     @Test

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Wed Apr  6 23:00:11 2011
@@ -64,11 +64,11 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.cursor.EmptyCursor;
 import org.apache.directory.shared.ldap.model.cursor.SingletonCursor;
-import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.DefaultAttribute;
+import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.DefaultModification;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.entry.Value;
@@ -1076,7 +1076,7 @@ public class DefaultPartitionNexus exten
 
         if ( supportedExtension == null )
         {
-            rootDSE.set( SchemaConstants.SUPPORTED_EXTENSION_AT );
+            rootDSE.put( SchemaConstants.SUPPORTED_EXTENSION_AT, (String)null );
             supportedExtension = rootDSE.get( SchemaConstants.SUPPORTED_EXTENSION_AT );
         }
 
@@ -1096,7 +1096,7 @@ public class DefaultPartitionNexus exten
 
         if ( supportedSaslMechanismsAttribute == null )
         {
-            rootDSE.set( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT );
+            rootDSE.put( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT, (String)null );
             supportedSaslMechanismsAttribute = rootDSE.get( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT );
         }
 

Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryTest.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryTest.java Wed Apr  6 23:00:11 2011
@@ -1099,36 +1099,6 @@ public class SchemaAwareEntryTest
     
     
     /**
-     * Test method for set( String... )
-     */
-    @Test
-    public void testSet() throws LdapException
-    {
-        Entry entry = new DefaultEntry( EXAMPLE_DN );
-
-        entry.add( "ObjectClass", "top", "person" );
-        entry.add( "cn", "test1", "test2" );
-        entry.add( "sn", "Test" );
-        
-        List<Attribute> removed = entry.set( "objectClass", "CN", "givenName" );
-        
-        assertEquals( 4, entry.size() );
-        assertNotNull( entry.get( "objectclass" ) );
-        assertNotNull( entry.get( "cn" ) );
-        assertNotNull( entry.get( "givenname" ) );
-        assertNotNull( entry.get( "sn" ) );
-        
-        assertNull( entry.get( "objectclass" ).get() );
-        assertNull( entry.get( "cn" ).get() );
-        assertNull( entry.get( "givenname" ).get() );
-        assertNotNull( entry.get( "sn" ).get() );
-        
-        assertNotNull( removed );
-        assertEquals( 2, removed.size() );
-    }
-
-
-    /**
      * Test method for setDN( Dn )
      */
     @Test

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java Wed Apr  6 23:00:11 2011
@@ -1438,97 +1438,7 @@ public final class DefaultEntry implemen
 
     /**
      * {@inheritDoc}
-     */
-    public List<Attribute> set( String... upIds )
-    {
-        if ( ( upIds == null ) || ( upIds.length == 0 ) )
-        {
-            String message = I18n.err( I18n.ERR_04135 );
-            LOG.error( message );
-            throw new IllegalArgumentException( message );
-        }
-
-        List<Attribute> removed = new ArrayList<Attribute>();
-        boolean added = false;
-
-        if ( schemaManager == null )
-        {
-            // Now, loop on all the attributeType to add
-            for ( String upId : upIds )
-            {
-                if ( upId == null )
-                {
-                    String message = I18n.err( I18n.ERR_04135 );
-                    LOG.info( message );
-                    throw new IllegalArgumentException( message );
-                }
-
-                String id = getId( upId );
-
-                if ( attributes.containsKey( id ) )
-                {
-                    // Add the removed serverAttribute to the list
-                    removed.add( attributes.remove( id ) );
-                }
-
-                Attribute newAttribute = new DefaultAttribute( upId );
-                attributes.put( id, newAttribute );
-                added = true;
-            }
-        }
-        else
-        {
-            for ( String upId : upIds )
-            {
-                if ( upId == null )
-                {
-                    String message = I18n.err( I18n.ERR_04135 );
-                    LOG.info( message );
-                    throw new IllegalArgumentException( message );
-                }
-
-                // Search for the corresponding AttributeType, based on the upID
-                AttributeType attributeType = null;
-
-                try
-                {
-                    attributeType = getAttributeType( upId );
-                }
-                catch ( LdapException ne )
-                {
-                    LOG.warn( "Trying to add a bad attribute type '{}', error : ", upId, ne.getLocalizedMessage() );
-                    continue;
-                }
-                catch ( IllegalArgumentException iae )
-                {
-                    LOG.warn( "Trying to add a bad attribute type '{}', error : ", upId, iae.getLocalizedMessage() );
-                    continue;
-                }
-
-                String oid = attributeType.getOid();
-
-                if ( attributes.containsKey( oid ) )
-                {
-                    removed.add( attributes.get( oid ) );
-                }
-
-                attributes.put( oid, new DefaultAttribute( upId, attributeType ) );
-                added = true;
-            }
-        }
-
-        if ( ( !added ) || ( removed.size() == 0 ) )
-        {
-            return null;
-        }
-
-        return removed;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     **/
+     **
     public List<Attribute> set( AttributeType... attributeTypes )
     {
         List<Attribute> removed = new ArrayList<Attribute>();

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Entry.java Wed Apr  6 23:00:11 2011
@@ -128,22 +128,6 @@ public interface Entry extends Cloneable
     
     
     /**
-     * <p>
-     * Put some new ClientAttribute using the User Provided ID. 
-     * No value is inserted. 
-     * </p>
-     * <p>
-     * If an existing Attribute is found, it will be replaced by an
-     * empty attribute, and returned to the caller.
-     * </p>
-     * 
-     * @param upIds The user provided IDs of the AttributeTypes to add.
-     * @return A list of replaced Attributes.
-     */
-    List<Attribute> set( String... upIds );
-
-
-    /**
      * Set this entry's Dn.
      *
      * @param dn The Dn associated with this entry

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java?rev=1089658&r1=1089657&r2=1089658&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/ImmutableEntry.java Wed Apr  6 23:00:11 2011
@@ -317,26 +317,6 @@ public class ImmutableEntry implements E
     /**
      * {@inheritDoc}
      */
-    public List<Attribute> set( String... upIds )
-    {
-        new Exception().printStackTrace();
-        throw new NotImplementedException( "Cannot set a value : the entry " + entry.getDn() + " is immutable." );
-    }
-
-
-    /**
-     * {@inheritDoc}     
-     **/
-    public List<Attribute> set( AttributeType... attributeTypes )
-    {
-        new Exception().printStackTrace();
-        throw new NotImplementedException( "Cannot set a value : the entry " + entry.getDn() + " is immutable." );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public List<Attribute> put( Attribute... attributes ) throws LdapException
     {
         new Exception().printStackTrace();