directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r230580 - in /directory/apacheds/trunk/core/src: main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java
Date Sat, 06 Aug 2005 20:27:26 GMT
Author: akarasulu
Date: Sat Aug  6 13:27:21 2005
New Revision: 230580

URL: http://svn.apache.org/viewcvs?rev=230580&view=rev
Log:
changes ...

 o added test case to make sure extensibleObjects can have any entries
 o added code to create configuration regions within the DIT to be populated
   later by administrative or setup UI's 

Added:
    directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java?rev=230580&r1=230579&r2=230580&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
Sat Aug  6 13:27:21 2005
@@ -440,6 +440,85 @@
         }
 
         // -------------------------------------------------------------------
+        // create system configuration area
+        // -------------------------------------------------------------------
+
+        if ( !partitionNexus.hasEntry( new LdapName( "ou=configuration,ou=system" ) ) )
+        {
+            firstStart = true;
+            checkPermissionToCreateBootstrapEntries();
+
+            Attributes attributes = new LockableAttributesImpl();
+            attributes.put( "objectClass", "top" );
+            attributes.put( "objectClass", "organizationalUnit" );
+            attributes.put( "ou", "configuration" );
+            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            partitionNexus.add( "ou=configuration,ou=system", new LdapName( "ou=configuration,ou=system"
), attributes );
+        }
+
+        // -------------------------------------------------------------------
+        // create system configuration area for partition information
+        // -------------------------------------------------------------------
+
+        if ( !partitionNexus.hasEntry( new LdapName( "ou=partitions,ou=configuration,ou=system"
) ) )
+        {
+            firstStart = true;
+            checkPermissionToCreateBootstrapEntries();
+
+            Attributes attributes = new LockableAttributesImpl();
+            attributes.put( "objectClass", "top" );
+            attributes.put( "objectClass", "organizationalUnit" );
+            attributes.put( "ou", "partitions" );
+            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            partitionNexus.add( "ou=partitions,ou=configuration,ou=system",
+                    new LdapName( "ou=partitions,ou=configuration,ou=system" ), attributes
);
+        }
+
+        // -------------------------------------------------------------------
+        // create system configuration area for services
+        // -------------------------------------------------------------------
+
+        if ( !partitionNexus.hasEntry( new LdapName( "ou=services,ou=configuration,ou=system"
) ) )
+        {
+            firstStart = true;
+            checkPermissionToCreateBootstrapEntries();
+
+            Attributes attributes = new LockableAttributesImpl();
+            attributes.put( "objectClass", "top" );
+            attributes.put( "objectClass", "organizationalUnit" );
+            attributes.put( "ou", "services" );
+            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            partitionNexus.add( "ou=services,ou=configuration,ou=system",
+                    new LdapName( "ou=services,ou=configuration,ou=system" ), attributes
);
+        }
+
+        // -------------------------------------------------------------------
+        // create system configuration area for interceptors
+        // -------------------------------------------------------------------
+
+        if ( !partitionNexus.hasEntry( new LdapName( "ou=interceptors,ou=configuration,ou=system"
) ) )
+        {
+            firstStart = true;
+            checkPermissionToCreateBootstrapEntries();
+
+            Attributes attributes = new LockableAttributesImpl();
+            attributes.put( "objectClass", "top" );
+            attributes.put( "objectClass", "organizationalUnit" );
+            attributes.put( "ou", "configuration" );
+            attributes.put( "creatorsName", ContextPartitionNexus.ADMIN_PRINCIPAL );
+            attributes.put( "createTimestamp", DateUtils.getGeneralizedTime() );
+
+            partitionNexus.add( "ou=interceptors,ou=configuration,ou=system",
+                    new LdapName( "ou=interceptors,ou=configuration,ou=system" ), attributes
);
+        }
+
+        // -------------------------------------------------------------------
         // create system preferences area
         // -------------------------------------------------------------------
 

Added: directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java?rev=230580&view=auto
==============================================================================
--- directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java
(added)
+++ directory/apacheds/trunk/core/src/test/org/apache/ldap/server/jndi/ExtensibleObjectTest.java
Sat Aug  6 13:27:21 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2004 Solarsis Group LLC.
+ *
+ * Licensed under the Open Software License, Version 2.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://opensource.org/licenses/osl-2.1.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ldap.server.jndi;
+
+
+import org.apache.ldap.server.AbstractAdminTestCase;
+
+import javax.naming.directory.*;
+
+
+/**
+ * @author <a href="mailto:akarasulu@safehaus.org">Alex Karasulu</a>
+ * @version $Rev$
+ */
+public class ExtensibleObjectTest extends AbstractAdminTestCase
+{
+    public void testExtensibleObjectModify() throws Exception
+    {
+        Attributes attributes = new BasicAttributes();
+        Attribute attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", "testing00" );
+        DirContext ctx = sysRoot.createSubcontext( "ou=testing00", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing00", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+        
+        Attributes newattribs = new BasicAttributes();
+        Attribute freeform = new BasicAttribute( "freeform" );
+        freeform.add( "testing" );
+        newattribs.put( freeform );
+        Attribute objectClass = new BasicAttribute( "objectClass" );
+        objectClass.add( "top" );
+        objectClass.add( "extensibleObject" );
+        objectClass.add( "organizationalUnit" );
+        newattribs.put( objectClass );
+        ctx.modifyAttributes( "", DirContext.REPLACE_ATTRIBUTE, newattribs );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing00", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+        assertTrue( attribute.contains( "extensibleObject" ) );
+        attribute = attributes.get( "freeform" );
+        assertTrue( attribute.contains( "testing" ) );
+    }
+
+    public void testExtensibleObjectAdd() throws Exception
+    {
+        Attributes attributes = new BasicAttributes();
+        Attribute attribute = new BasicAttribute( "objectClass" );
+        attribute.add( "top" );
+        attribute.add( "extensibleObject" );
+        attribute.add( "organizationalUnit" );
+        attributes.put( attribute );
+        attributes.put( "ou", "testing00" );
+        attributes.put( "freeform", "testing" );
+        DirContext ctx = sysRoot.createSubcontext( "ou=testing00", attributes );
+        assertNotNull( ctx );
+
+        ctx = ( DirContext ) sysRoot.lookup( "ou=testing00" );
+        assertNotNull( ctx );
+
+        attributes = ctx.getAttributes( "" );
+        assertNotNull( attributes );
+        assertEquals( "testing00", attributes.get( "ou" ).get() );
+        attribute = attributes.get( "objectClass" );
+        assertNotNull( attribute );
+        assertTrue( attribute.contains( "top" ) );
+        assertTrue( attribute.contains( "extensibleObject" ) );
+        assertTrue( attribute.contains( "organizationalUnit" ) );
+        attribute = attributes.get( "freeform" );
+        assertTrue( attribute.contains( "testing" ) );
+    }
+}



Mime
View raw message