directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r546144 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Date Mon, 11 Jun 2007 13:30:01 GMT
Author: elecharny
Date: Mon Jun 11 06:30:00 2007
New Revision: 546144

URL: http://svn.apache.org/viewvc?view=rev&rev=546144
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/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?view=diff&rev=546144&r1=546143&r2=546144
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Mon Jun 11 06:30:00 2007
@@ -26,7 +26,6 @@
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.naming.Binding;
 import javax.naming.Context;
 import javax.naming.InvalidNameException;
 import javax.naming.Name;
@@ -65,9 +64,12 @@
 import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 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.AttributesImpl;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+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;
@@ -313,10 +315,34 @@
     {
         Attributes attributes = new AttributesImpl();
         LdapDN target = buildTarget( name );
-        injectRdnAttributeValues( target, attributes );
         
-        attributes.put( SchemaConstants.OBJECT_CLASS_AT, JavaLdapSupport.JCONTAINER_ATTR
);
-        attributes.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
+        Attribute attribute = new AttributeImpl( SchemaConstants.OBJECT_CLASS_AT );
+        attribute.add( SchemaConstants.TOP_OC );
+        attribute.add( JavaLdapSupport.JCONTAINER_ATTR );
+        attributes.put( attribute );
+        
+        // Now add the CN attribute, which is mandatory
+        Rdn rdn = target.getRdn();
+        
+        if ( rdn != null )
+        {
+            if ( SchemaConstants.CN_AT.equals( rdn.getNormType() )  )
+            {
+                attributes.put( rdn.getUpType(), rdn.getUpValue() );
+            }
+            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.OBJECT_CLASS_VIOLATION );
+            }
+        }
+        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.OBJECT_CLASS_VIOLATION);
+        }
 
         /*
          * Add the new context to the server which as a side effect adds 



Mime
View raw message