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 2012/04/28 00:57:22 UTC
svn commit: r1331623 - in /directory:
apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/
apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/
shared/trunk/integ/src...
Author: elecharny
Date: Fri Apr 27 22:57:21 2012
New Revision: 1331623
URL: http://svn.apache.org/viewvc?rev=1331623&view=rev
Log:
The Entry.removeAttributes() method does not return the removed attributes, it's costly and never used.
Modified:
directory/apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/ClonedServerEntry.java
directory/apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.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
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifEntry.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifReaderTest.java
Modified: directory/apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/ClonedServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/ClonedServerEntry.java?rev=1331623&r1=1331622&r2=1331623&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/ClonedServerEntry.java (original)
+++ directory/apacheds/branches/index-work/core-api/src/main/java/org/apache/directory/server/core/api/entry/ClonedServerEntry.java Fri Apr 27 22:57:21 2012
@@ -235,9 +235,9 @@ public class ClonedServerEntry implement
}
- public List<Attribute> removeAttributes( AttributeType... attributes )
+ public void removeAttributes( AttributeType... attributes )
{
- return clonedEntry.removeAttributes( attributes );
+ clonedEntry.removeAttributes( attributes );
}
@@ -376,9 +376,9 @@ public class ClonedServerEntry implement
}
- public List<Attribute> removeAttributes( String... attributes )
+ public void removeAttributes( String... attributes )
{
- return clonedEntry.removeAttributes( attributes );
+ clonedEntry.removeAttributes( attributes );
}
Modified: directory/apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java?rev=1331623&r1=1331622&r2=1331623&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java (original)
+++ directory/apacheds/branches/index-work/core-api/src/test/java/org/apache/directory/server/core/api/entry/SchemaAwareEntryTest.java Fri Apr 27 22:57:21 2012
@@ -3351,12 +3351,6 @@ public class SchemaAwareEntryTest
assertFalse( entry.containsAttribute( "cn", "sn" ) );
assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );
-
- List<Attribute> removed = entry.removeAttributes( ( AttributeType ) null );
- assertNull( removed );
-
- removed = entry.removeAttributes( atC );
- assertNull( removed );
}
@@ -3380,14 +3374,9 @@ public class SchemaAwareEntryTest
assertFalse( entry.containsAttribute( "cn", "sn" ) );
assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );
- List<Attribute> removed = entry.removeAttributes( "badId" );
- assertNull( removed );
-
- removed = entry.removeAttributes( "l" );
- assertNull( removed );
-
- removed = entry.removeAttributes( ( String ) null );
- assertNull( removed );
+ entry.removeAttributes( "badId" );
+ entry.removeAttributes( "l" );
+ entry.removeAttributes( ( String ) null );
}
@@ -3515,8 +3504,7 @@ public class SchemaAwareEntryTest
Value<byte[]> testB2 = new BinaryValue( atPassword, b2 );
// test a removal of an non existing attribute
- List<Attribute> removed = entry.removeAttributes( atCN );
- assertNull( removed );
+ entry.removeAttributes( atCN );
// Test a simple removal
entry.add( "cN", atCN, test1 );
@@ -3548,9 +3536,7 @@ public class SchemaAwareEntryTest
assertNotNull( entry.get( atCN ) );
assertNotNull( entry.get( atPassword ) );
- removed = entry.removeAttributes( "badAttribute" );
-
- assertNull( removed );
+ entry.removeAttributes( "badAttribute" );
}
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=1331623&r1=1331622&r2=1331623&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 Fri Apr 27 22:57:21 2012
@@ -971,11 +971,9 @@ public class SchemaAwareEntryTest
assertFalse( entry.containsAttribute( "cn", "sn" ) );
assertTrue( entry.containsAttribute( "objectclass", "userpassword" ) );
- List<Attribute> removed = entry.removeAttributes( "badId" );
- assertNull( removed );
+ entry.removeAttributes( "badId" );
- removed = entry.removeAttributes( ( String ) null );
- assertNull( removed );
+ entry.removeAttributes( ( String ) null );
}
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=1331623&r1=1331622&r2=1331623&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 Fri Apr 27 22:57:21 2012
@@ -1929,15 +1929,13 @@ public final class DefaultEntry implemen
* @param attributes the AttributeTypes to be removed
* @return the removed attributes, if any, as a list; otherwise <code>null</code>
*/
- public List<Attribute> removeAttributes( AttributeType... attributes )
+ public void removeAttributes( AttributeType... attributes )
{
if ( ( attributes == null ) || ( attributes.length == 0 ) || ( schemaManager == null ) )
{
- return null;
+ return;
}
- List<Attribute> removed = new ArrayList<Attribute>( attributes.length );
-
for ( AttributeType attributeType : attributes )
{
if ( attributeType == null )
@@ -1945,21 +1943,7 @@ public final class DefaultEntry implemen
continue;
}
- Attribute attr = this.attributes.remove( attributeType.getOid() );
-
- if ( attr != null )
- {
- removed.add( attr );
- }
- }
-
- if ( removed.size() == 0 )
- {
- return null;
- }
- else
- {
- return removed;
+ this.attributes.remove( attributeType.getOid() );
}
}
@@ -1967,15 +1951,13 @@ public final class DefaultEntry implemen
/**
* {@inheritDoc}
*/
- public List<Attribute> removeAttributes( String... attributes )
+ public void removeAttributes( String... attributes )
{
if ( attributes.length == 0 )
{
- return null;
+ return;
}
- List<Attribute> removed = new ArrayList<Attribute>( attributes.length );
-
if ( schemaManager == null )
{
for ( String attribute : attributes )
@@ -1984,7 +1966,7 @@ public final class DefaultEntry implemen
if ( attr != null )
{
- removed.add( this.attributes.remove( attr.getId() ) );
+ this.attributes.remove( attr.getId() );
}
else
{
@@ -2011,23 +1993,9 @@ public final class DefaultEntry implemen
continue;
}
- Attribute attr = this.attributes.remove( attributeType.getOid() );
-
- if ( attr != null )
- {
- removed.add( attr );
- }
+ this.attributes.remove( attributeType.getOid() );
}
}
-
- if ( removed.size() == 0 )
- {
- return null;
- }
- else
- {
- return removed;
- }
}
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=1331623&r1=1331622&r2=1331623&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 Fri Apr 27 22:57:21 2012
@@ -622,7 +622,7 @@ public interface Entry extends Cloneable
* @param attributes the AttributeTypes to be removed
* @return the removed attributes, if any, as a list; otherwise <code>null</code>
*/
- List<Attribute> removeAttributes( AttributeType... attributes );
+ void removeAttributes( AttributeType... attributes );
/**
@@ -713,7 +713,7 @@ public interface Entry extends Cloneable
* @param attributes an aliased name of the attribute to be removed
* @return the removed attributes, if any, as a list; otherwise <code>null</code>
*/
- List<Attribute> removeAttributes( String... attributes );
+ void removeAttributes( String... attributes );
// -----------------------------------------------------------------------
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=1331623&r1=1331622&r2=1331623&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 Fri Apr 27 22:57:21 2012
@@ -442,7 +442,7 @@ public class ImmutableEntry implements E
* @param attributes the AttributeTypes to be removed
* @return the removed attributes, if any, as a list; otherwise <code>null</code>
*/
- public List<Attribute> removeAttributes( AttributeType... attributes )
+ public void removeAttributes( AttributeType... attributes )
{
new Exception().printStackTrace();
throw new NotImplementedException( "Cannot remove a value : the entry " + entry.getDn() + " is immutable." );
@@ -452,7 +452,7 @@ public class ImmutableEntry implements E
/**
* {@inheritDoc}
*/
- public List<Attribute> removeAttributes( String... attributes )
+ public void removeAttributes( String... attributes )
{
new Exception().printStackTrace();
throw new NotImplementedException( "Cannot remove a value : the entry " + entry.getDn() + " is immutable." );
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifEntry.java?rev=1331623&r1=1331622&r2=1331623&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifEntry.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifEntry.java Fri Apr 27 22:57:21 2012
@@ -462,15 +462,11 @@ public class LdifEntry implements Clonea
* @param ids The Attributes to remove
* @return The list of removed EntryAttributes
*/
- public List<Attribute> removeAttribute( String... ids )
+ public void removeAttribute( String... ids )
{
if ( entry.containsAttribute( ids ) )
{
- return entry.removeAttributes( ids );
- }
- else
- {
- return null;
+ entry.removeAttributes( ids );
}
}
Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifReaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifReaderTest.java?rev=1331623&r1=1331622&r2=1331623&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifReaderTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/ldif/LdifReaderTest.java Fri Apr 27 22:57:21 2012
@@ -1775,7 +1775,7 @@ public class LdifReaderTest
LdifEntry entry = entries.get( 0 );
assertNotNull( entry.get( "uid" ) );
- assertNotNull( entry.removeAttribute( "uid" ) );
+ entry.removeAttribute( "uid" );
assertNull( entry.get( "uid" ) );
}