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/10/01 18:53:50 UTC

svn commit: r451766 - /directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java

Author: akarasulu
Date: Sun Oct  1 09:53:49 2006
New Revision: 451766

URL: http://svn.apache.org/viewvc?view=rev&rev=451766
Log:
making capacity command create ou=users under example partition if it does not already exist

Modified:
    directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java

Modified: directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java?view=diff&rev=451766&r1=451765&r2=451766
==============================================================================
--- directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java (original)
+++ directory/branches/apacheds/1.0/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java Sun Oct  1 09:53:49 2006
@@ -24,6 +24,8 @@
 import java.io.PrintWriter;
 import java.util.Hashtable;
 
+import javax.naming.NameAlreadyBoundException;
+import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
@@ -97,6 +99,9 @@
 
         LdapContext ctx = new InitialLdapContext( env, null );
 
+        // create the base dn if it does not exist
+        createBase( ctx );
+        
         StringBuffer dnBuf = new StringBuffer();
         StringBuffer outBuf = new StringBuffer();
         int counter = 0;
@@ -128,6 +133,23 @@
     }
     
     
+    private boolean createBase( LdapContext ctx ) throws NamingException
+    {
+        Attributes attrs = new BasicAttributes( "objectClass", "organizationalUnit", true );
+        attrs.put( "ou", "users" );
+        
+        try
+        {
+            ctx.createSubcontext( "ou=users,dc=example,dc=com", attrs );
+            return true;
+        }
+        catch( NameAlreadyBoundException e )
+        {
+            return false;
+        }
+    }
+
+
     private Attributes generateLdif( int counter )
     {
         BasicAttributes attrs = new BasicAttributes( "objectClass", "top", true );