You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Stefan Zoerner <st...@labeo.de> on 2008/11/03 21:11:54 UTC
Trying to write a simple partition example
Hi all,
I try to write a very (!) simple example for a custom partition, in
order tom provide a starting point in the docs. Unfortunately I fail to
add my implementation to the DirectoryService, and I have no idea why.
This is how I add my partition ...
--8<--
directoryService = new DefaultDirectoryService();
directoryService.setShutdownHookEnabled(true);
// Determine an appropriate working directory
File workingDir = new File("work");
directoryService.setWorkingDirectory(workingDir);
// Create a new partition
EnvironmentPartition envPartition = new EnvironmentPartition();
envPartition.setId("env");
envPartition.setSuffix("ou=env");
envPartition.init(directoryService);
directoryService.addPartition(envPartition);
directoryService.startup();
-->8--
EnvironmentPartition is my implementation of the Partition interface.
Currently it does not make a lot, I was just trying to add it and start
the server. Adding is successful, but calling the startUp() method
causes an exception:
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.688
sec <<< FAILURE!
testAddPartition(org.apache.directory.samples.partition.env.EnvironmentPartitionTest)
Time elapsed: 2.64 sec <<< ERROR!
org.apache.directory.shared.ldap.exception.LdapNameNotFoundException: ou=env
at
org.apache.directory.server.core.partition.DefaultPartitionNexus.getPartition(DefaultPartitionNexus.java:1097)
at
org.apache.directory.server.core.partition.DefaultPartitionNexus.search(DefaultPartitionNexus.java:964)
at
org.apache.directory.server.core.authz.TupleCache.initialize(TupleCache.java:138)
at
org.apache.directory.server.core.authz.TupleCache.<init>(TupleCache.java:111)
at
org.apache.directory.server.core.authz.AciAuthorizationInterceptor.init(AciAuthorizationInterceptor.java:210)
at
org.apache.directory.server.core.interceptor.InterceptorChain.register0(InterceptorChain.java:439)
at
org.apache.directory.server.core.interceptor.InterceptorChain.register(InterceptorChain.java:395)
at
org.apache.directory.server.core.interceptor.InterceptorChain.init(InterceptorChain.java:255)
at
org.apache.directory.server.core.DefaultDirectoryService.initialize(DefaultDirectoryService.java:1385)
at
org.apache.directory.server.core.DefaultDirectoryService.startup(DefaultDirectoryService.java:840)
at
org.apache.directory.samples.partition.env.EnvironmentPartitionTest.testAddPartition(EnvironmentPartitionTest.java:29)
---
Although it is totally clear to my, that my partition won't work (most
methost throw an OperationNotSupportedException), I thought about
starting by simply adding it and starting the server correctly.
I was able to determin that getUpSuffixDn() and getSuffixDn() have been
called fom my partition. I assume, that I
a) do not return valid values
b) adding as described above is not sufficient
Does anybody have any idea. I have provided my code as a maven project here:
https://svn.apache.org/repos/asf/directory/sandbox/szoerner/envpartition
Thanks in advance,
Stefan
Re: Trying to write a simple partition example
Posted by Stefan Zoerner <st...@labeo.de>.
Kiran Ayyagari wrote:
> hi Stefan,
>
> the partition impl requires few changes(at least to pass the test)
> which I have attached as a patch.
>
> HTH
> Kiran Ayyagari
Hi Kiran,
it helps a lot! I was able to add my partition to the directory service
and I even see it in the Root DSE :-)
Now I start to implement some read ops.
Thank you very much + Greetings from Hamburg,
Stefan
Re: Trying to write a simple partition example
Posted by Stefan Zoerner <st...@labeo.de>.
Kiran Ayyagari wrote:
> hi Stefan,
>
> the partition impl requires few changes(at least to pass the test)
> which I have attached as a patch.
>
> HTH
> Kiran Ayyagari
Hi Kiran,
thanks for the immediate help, I will look at the changes this afternoon.
Greetings from Hamburg,
Stefan
Re: Trying to write a simple partition example
Posted by Kiran Ayyagari <ay...@gmail.com>.
hi Stefan,
the partition impl requires few changes(at least to pass the test)
which I have attached as a patch.
HTH
Kiran Ayyagari
Stefan Zoerner wrote:
> Hi all,
>
> I try to write a very (!) simple example for a custom partition, in
> order tom provide a starting point in the docs. Unfortunately I fail to
> add my implementation to the DirectoryService, and I have no idea why.
>
> This is how I add my partition ...
>
> --8<--
>
> directoryService = new DefaultDirectoryService();
> directoryService.setShutdownHookEnabled(true);
>
> // Determine an appropriate working directory
> File workingDir = new File("work");
> directoryService.setWorkingDirectory(workingDir);
>
> // Create a new partition
> EnvironmentPartition envPartition = new EnvironmentPartition();
> envPartition.setId("env");
> envPartition.setSuffix("ou=env");
> envPartition.init(directoryService);
>
> directoryService.addPartition(envPartition);
> directoryService.startup();
>
> -->8--
>
> EnvironmentPartition is my implementation of the Partition interface.
> Currently it does not make a lot, I was just trying to add it and start
> the server. Adding is successful, but calling the startUp() method
> causes an exception:
>
> Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.688
> sec <<< FAILURE!
> testAddPartition(org.apache.directory.samples.partition.env.EnvironmentPartitionTest)
> Time elapsed: 2.64 sec <<< ERROR!
> org.apache.directory.shared.ldap.exception.LdapNameNotFoundException:
> ou=env
> at
> org.apache.directory.server.core.partition.DefaultPartitionNexus.getPartition(DefaultPartitionNexus.java:1097)
>
> at
> org.apache.directory.server.core.partition.DefaultPartitionNexus.search(DefaultPartitionNexus.java:964)
>
> at
> org.apache.directory.server.core.authz.TupleCache.initialize(TupleCache.java:138)
>
> at
> org.apache.directory.server.core.authz.TupleCache.<init>(TupleCache.java:111)
>
> at
> org.apache.directory.server.core.authz.AciAuthorizationInterceptor.init(AciAuthorizationInterceptor.java:210)
>
> at
> org.apache.directory.server.core.interceptor.InterceptorChain.register0(InterceptorChain.java:439)
>
> at
> org.apache.directory.server.core.interceptor.InterceptorChain.register(InterceptorChain.java:395)
>
> at
> org.apache.directory.server.core.interceptor.InterceptorChain.init(InterceptorChain.java:255)
>
> at
> org.apache.directory.server.core.DefaultDirectoryService.initialize(DefaultDirectoryService.java:1385)
>
> at
> org.apache.directory.server.core.DefaultDirectoryService.startup(DefaultDirectoryService.java:840)
>
> at
> org.apache.directory.samples.partition.env.EnvironmentPartitionTest.testAddPartition(EnvironmentPartitionTest.java:29)
>
>
> ---
>
> Although it is totally clear to my, that my partition won't work (most
> methost throw an OperationNotSupportedException), I thought about
> starting by simply adding it and starting the server correctly.
>
> I was able to determin that getUpSuffixDn() and getSuffixDn() have been
> called fom my partition. I assume, that I
>
> a) do not return valid values
> b) adding as described above is not sufficient
>
> Does anybody have any idea. I have provided my code as a maven project
> here:
>
> https://svn.apache.org/repos/asf/directory/sandbox/szoerner/envpartition
>
> Thanks in advance,
> Stefan
>
>
>
>
>