You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Alex Karasulu <ak...@apache.org> on 2007/04/23 20:17:15 UTC
Re: [LS] Bug? Jenny Tutone entry not showing up in hot partition
Hmmm sounds like you're following my 867-5309 :) example. Try another
browser to see what happens ... like ldapbrowser.
Alex
On 4/23/07, Ole Ersoy <ol...@gmail.com> wrote:
>
> Hey Guys,
>
> I ran some more hot partition code from the
> PartitionApplication.java adding
> the cn=Jenny Tutone entry.
>
> When I refresh the hot partition in LS
> cn=Jenny Tutone does not show up (I also tried
> disconnecting and reconnecting),
> although the test code says she's there.
>
> Here's my test log:
> Embedded ApacheDS started in 1057 milliseconds
> cn=Jenny Tutone,ou=das already exists
> Jenny's phone number is 867-5309
>
> Cheers,
> - Ole
>
>
>
>
Re: [LS] Bug? Jenny Tutone entry not showing up in hot partition
Posted by Ole Ersoy <ol...@gmail.com>.
Alex Karasulu wrote:
> Hmmm sounds like you're following my 867-5309 :) example.
Indeed :-)
Try another
> browser to see what happens ... like ldapbrowser.
I tried installing JXPlorer earlier, but
got all sorts of complaints about my java installation.
I ended up doing a lot of hacking with my java install.
I need to unhack this machine.
Can someone who has an alternative browser run this test
code, and see if the cn=Jenny Tutone entry shows up?
Here are the maven dependencies needed:
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>nlog4j</artifactId>
<version>1.2.25</version>
</dependency>
Here's the junit test:
package org.apache.tuscany.das.ldap.prototype.learning;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Set;
import javax.naming.Context;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import org.apache.directory.server.core.configuration.Configuration;
import
org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
import
org.apache.directory.server.core.configuration.MutableStartupConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
public class LearningTest extends TestCase
{
private static final Logger log = LoggerFactory.getLogger(
"partition" );
// Create the mutable configuration
MutableStartupConfiguration configuration = new
MutableStartupConfiguration();
// Create the partition configuration to fill in
MutablePartitionConfiguration partition = new
MutablePartitionConfiguration();
public void testDynamicPartitioning()
throws NamingException
{
// Get the start time
long startTime = System.currentTimeMillis();
partition.setName( "das" );
partition.setSuffix( "ou=das" );
// Set the non-system indices to create for the partition
Set indices = new HashSet();
indices.add( "objectClass" );
indices.add( "cn" );
partition.setIndexedAttributes( indices );
// Assemble the partition's suffix entry
Attributes suffixAttributes = new BasicAttributes(
"objectClass", "top", true );
suffixAttributes.get( "objectClass" ).add( "organizationalUnit" );
suffixAttributes.put( "ou", "das" );
partition.setContextEntry( suffixAttributes );
// Add the new partition configuration to the configuration bean
Set partitions = new HashSet();
partitions.add( partition );
configuration.setContextPartitionConfigurations( partitions );
// ------------------------------------------------------------
// Setup environment using the configuration with extra partition
// ------------------------------------------------------------
Hashtable env = new Hashtable();
// Notice that the provider URL is not really a URL but a DN
// This time instead of ou=system we're accessing the apachecon
partition
env.put( Context.PROVIDER_URL, "ou=das" );
// User the ApacheDS core InitialContextFactory implementation
env.put( Context.INITIAL_CONTEXT_FACTORY,
"org.apache.directory.server.core.jndi.CoreContextFactory" );
// Fixed uber admin user is always present and initial password
is set to "secret"
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.SECURITY_AUTHENTICATION, "simple" );
// Put extended configuration into environment
env.put( Configuration.JNDI_KEY, configuration );
// Startup the server core by getting the first InitialDirContext.
InitialDirContext ictx = new InitialDirContext( env );
System.out.println( "Embedded ApacheDS started in " + (
System.currentTimeMillis() - startTime ) + " milliseconds" );
DirContext jenny = null;
try
{
// Get context on jenny if she exists.
jenny = ( DirContext ) ictx.lookup( "cn=Jenny Tutone" );
System.out.println( jenny.getNameInNamespace() + " already
exists" );
}
catch ( NameNotFoundException e2 )
{
// Create a new entry under ou=system since jenny does not
// already exist.
System.out.println( "jenny does not exist" );
Attributes newEntry = new BasicAttributes( "objectClass",
"top", true );
newEntry.get( "objectClass" ).add( "person" );
newEntry.put( "sn", "Tutone" );
newEntry.put( "cn", "Jenny Tutone" );
newEntry.put( "telephoneNumber", "867-5309" );
jenny = ( DirContext ) ictx.createSubcontext( "cn=Jenny
Tutone", newEntry );
System.out.println( "created " + jenny.getNameInNamespace() );
}
Attribute number = jenny.getAttributes( "" ).get(
"telephoneNumber" );
System.out.println( "Jenny's phone number is " + number.get() );
}
}
Thanks,
- Ole