You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2006/08/22 00:47:45 UTC
svn commit: r433408 - in /directory/branches/apacheds/1.0:
core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
Author: ersiner
Date: Mon Aug 21 15:47:44 2006
New Revision: 433408
URL: http://svn.apache.org/viewvc?rev=433408&view=rev
Log:
Fix and tests for https://issues.apache.org/jira/browse/DIRSERVER-709
Modified:
directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
Modified: directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java?rev=433408&r1=433407&r2=433408&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java (original)
+++ directory/branches/apacheds/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaChecker.java Mon Aug 21 15:47:44 2006
@@ -194,6 +194,17 @@
{
return;
}
+
+ // check if there is any attribute value as "".
+ // if there is remove it so that it will be considered as not even provided.
+ for( int ii = 0; ii < attribute.size(); ii++ )
+ {
+ Object value = attribute.get( ii );
+ if ( "".equals( value ) )
+ {
+ attribute.remove( ii );
+ }
+ }
// whoever issued the modify operation is insane they want to delete
// all the objectClass values in which case we must throw an exception
@@ -264,6 +275,17 @@
if ( objectClass == null )
{
return;
+ }
+
+ // check if there is any attribute value as "".
+ // if there is remove it so that it will be considered as not even provided.
+ for( int ii = 0; ii < objectClass.size(); ii++ )
+ {
+ Object value = objectClass.get( ii );
+ if ( "".equals( value ) )
+ {
+ objectClass.remove( ii );
+ }
}
// whoever issued the modify operation is insane they want to delete
Modified: directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java?rev=433408&r1=433407&r2=433408&view=diff
==============================================================================
--- directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java (original)
+++ directory/branches/apacheds/1.0/server-unit/src/test/java/org/apache/directory/server/ModifyRemoveTest.java Mon Aug 21 15:47:44 2006
@@ -27,6 +27,7 @@
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InvalidAttributeIdentifierException;
+import javax.naming.directory.InvalidAttributeValueException;
import javax.naming.directory.ModificationItem;
import javax.naming.directory.NoSuchAttributeException;
import javax.naming.directory.SchemaViolationException;
@@ -465,5 +466,54 @@
}
ctx.destroySubcontext( rdn );
+ }
+
+ /**
+ * Create a person entry and try to remove objectClass attribute
+ */
+ public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgperson() throws NamingException {
+
+ // Create an entry
+ Attributes attrs = getInetOrgPersonAttributes("Bush", "Kate Bush");
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext(rdn, attrs);
+
+ ModificationItem delModOp = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute("objectclass", ""));
+
+ try {
+ ctx.modifyAttributes(rdn, new ModificationItem[] { delModOp });
+ fail("deletion of objectclass should fail");
+ } catch (SchemaViolationException e) {
+ // expected
+ } catch (NoSuchAttributeException e) {
+ // expected
+ } catch (InvalidAttributeValueException e) {
+ // expected
+ }
+
+ ctx.destroySubcontext(rdn);
+ }
+
+ /**
+ * Create a person entry and try to remove objectClass attribute. A variant
+ * which works.
+ */
+ public void testDeleteOclAttrWithTopPersonOrganizationalpersonInetorgpersonVariant() throws NamingException {
+
+ // Create an entry
+ Attributes attrs = getInetOrgPersonAttributes("Bush", "Kate Bush");
+ String rdn = "cn=Kate Bush";
+ ctx.createSubcontext(rdn, attrs);
+
+ ModificationItem delModOp = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, new BasicAttribute("objectclass"));
+
+ try {
+ ctx.modifyAttributes(rdn, new ModificationItem[] { delModOp });
+ fail("deletion of objectclass should fail");
+ } catch (SchemaViolationException e) {
+ // expected
+ }
+
+ ctx.destroySubcontext(rdn);
}
}