Author: elecharny Date: Mon Jun 11 06:29:35 2007 New Revision: 546142 URL: http://svn.apache.org/viewvc?view=rev&rev=546142 Log: Fixed a bug in createSubContext( name ) : the JavaContainer ObjectClass was added but overloaded by the 'top' objectClass Added three tests in CreateContextITest Fixed ExceptionServiceITest to handle the correct exception Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?view=diff&rev=546142&r1=546141&r2=546142 ============================================================================== --- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original) +++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Mon Jun 11 06:29:35 2007 @@ -52,9 +52,12 @@ import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.partition.PartitionNexusProxy; import org.apache.directory.shared.ldap.exception.LdapNoPermissionException; +import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException; import org.apache.directory.shared.ldap.filter.ExprNode; import org.apache.directory.shared.ldap.filter.PresenceNode; +import org.apache.directory.shared.ldap.message.LockableAttributeImpl; import org.apache.directory.shared.ldap.message.LockableAttributesImpl; +import org.apache.directory.shared.ldap.message.ResultCodeEnum; import org.apache.directory.shared.ldap.name.AttributeTypeAndValue; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.name.Rdn; @@ -292,10 +295,34 @@ { Attributes attributes = new LockableAttributesImpl(); LdapDN target = buildTarget( name ); - injectRdnAttributeValues( target, attributes ); - attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.JCONTAINER_ATTR ); - attributes.put( JavaLdapSupport.OBJECTCLASS_ATTR, JavaLdapSupport.TOP_ATTR ); + Attribute attribute = new LockableAttributeImpl( "objectClass" ); + attribute.add( "top" ); + attribute.add( JavaLdapSupport.JCONTAINER_ATTR ); + attributes.put( attribute ); + + // Now add the CN attribute, which is mandatory + Rdn rdn = target.getRdn(); + + if ( rdn != null ) + { + if ( "cn".equals( rdn.getNormType() ) ) + { + attributes.put( rdn.getUpType(), rdn.getValue() ); + } + else + { + // No CN in the rdn, this is an error + throw new LdapSchemaViolationException( name + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!", + ResultCodeEnum.OBJECTCLASSVIOLATION ); + } + } + else + { + // No CN in the rdn, this is an error + throw new LdapSchemaViolationException( name + " does not contains the mandatory 'cn' attribute for JavaContainer ObjectClass!", + ResultCodeEnum.OBJECTCLASSVIOLATION ); + } /* * Add the new context to the server which as a side effect adds