You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/08/10 07:52:07 UTC
svn commit: r430262 - in /directory/trunks/apacheds:
core/src/main/java/org/apache/directory/server/core/schema/
server-unit/src/test/java/org/apache/directory/server/
Author: akarasulu
Date: Wed Aug 9 22:52:07 2006
New Revision: 430262
URL: http://svn.apache.org/viewvc?rev=430262&view=rev
Log:
Fix for DIRSERVER-702: Trying to remove an attribute which is part of the RDN does not cause an error. This was a bug caused by the move to using OIDs instead of the more faulty first alias.
Modified:
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java?rev=430262&r1=430261&r2=430262&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java Wed Aug 9 22:52:07 2006
@@ -328,7 +328,7 @@
* @param attribute the attribute being modified
* @throws NamingException if the modify operation is removing an Rdn attribute
*/
- public static void preventRdnChangeOnModifyReplace( Name name, int mod, Attribute attribute )
+ public static void preventRdnChangeOnModifyReplace( Name name, int mod, Attribute attribute, OidRegistry oidRegistry )
throws NamingException
{
if ( mod != DirContext.REPLACE_ATTRIBUTE )
@@ -337,7 +337,7 @@
}
Set rdnAttributes = getRdnAttributes( name );
- String id = attribute.getID();
+ String id = oidRegistry.getOid( ( String ) attribute.getID() );
if ( !rdnAttributes.contains( id ) )
{
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=430262&r1=430261&r2=430262&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Wed Aug 9 22:52:07 2006
@@ -873,7 +873,8 @@
break;
case DirContext.REPLACE_ATTRIBUTE :
- SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, change );
+ SchemaChecker.preventRdnChangeOnModifyReplace( name, modOp, change,
+ globalRegistries.getOidRegistry() );
SchemaChecker.preventStructuralClassRemovalOnModifyReplace( ocRegistry, name, modOp, change );
attr = tmpEntry.get( change.getID() );
Modified: directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java?rev=430262&r1=430261&r2=430262&view=diff
==============================================================================
--- directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java (original)
+++ directory/trunks/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java Wed Aug 9 22:52:07 2006
@@ -375,4 +375,95 @@
ctx.destroySubcontext( rdn );
}
+
+
+ /**
+ * Create a person entry and try to remove an attribute value from the RDN
+ * by Replacement
+ */
+ public void testReplaceRdnByEmptyValueAttribute() throws NamingException
+ {
+
+ // Create an entry
+ Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext( rdn, attrs );
+
+ // replace attribute cn with empty value (=> deletion)
+ Attribute attr = new BasicAttribute( "cn" );
+ ModificationItem item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+
+ try
+ {
+ ctx.modifyAttributes( rdn, new ModificationItem[]
+ { item } );
+ fail( "modify should fail" );
+ }
+ catch ( SchemaViolationException e )
+ {
+ // Expected behaviour
+ }
+
+ ctx.destroySubcontext( rdn );
+ }
+
+
+ /**
+ * Create a person entry and try to remove an attribute from the RDN
+ */
+ public void testRemoveRdnAttribute() throws NamingException
+ {
+
+ // Create an entry
+ Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext( rdn, attrs );
+
+ // replace attribute cn with empty value (=> deletion)
+ Attribute attr = new BasicAttribute( "cn" );
+ ModificationItem item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );
+
+ try
+ {
+ ctx.modifyAttributes( rdn, new ModificationItem[]
+ { item } );
+ fail( "modify should fail" );
+ }
+ catch ( SchemaViolationException e )
+ {
+ // Expected behaviour
+ }
+
+ ctx.destroySubcontext( rdn );
+ }
+
+
+ /**
+ * Create a person entry and try to remove an attribute from the RDN
+ */
+ public void testRemoveRdnAttributeValue() throws NamingException
+ {
+
+ // Create an entry
+ Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext( rdn, attrs );
+
+ // replace attribute cn with empty value (=> deletion)
+ Attribute attr = new BasicAttribute( "cn", "Kate Bush" );
+ ModificationItem item = new ModificationItem( DirContext.REMOVE_ATTRIBUTE, attr );
+
+ try
+ {
+ ctx.modifyAttributes( rdn, new ModificationItem[]
+ { item } );
+ fail( "modify should fail" );
+ }
+ catch ( SchemaViolationException e )
+ {
+ // Expected behaviour
+ }
+
+ ctx.destroySubcontext( rdn );
+ }
}