directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spark Shen" <smallsmallor...@gmail.com>
Subject Re: [ldapserver][schema] How to programmatically extract schema information from a server context
Date Wed, 14 Nov 2007 04:05:34 GMT
Indeed, I plan to start a apacheds server, no matter embedded or standalone.
And then construct a context to connect to the server.
Then extract the schema definition from the server.

And I got the java.lang.UnsupportedOperationException.
I am not quite sure whether its my program is wrong or the retrieving schema

operation is not supported.

Besides the file you mentioned, I looked into another file:
http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/connect/test/ADSEmbeddedConnectionTest.java

and find a code snippet:

LdapContext schemaContext = adsEmbeddedConnection.
			connect(configuration.
					getSchemaPartitionName());

then what I want to do is:
schemaContext.list("")

The test case itself relies on many third party jars. I did not have a
maven env, and am trying to configure one.
Seems it will take me some efforts to find all the dependent jars, and
then play with it.
Where can I find the developer guide?
http://incubator.apache.org/tuscany/starting-with-das.htmll ?

If it will not cost you too much energy, would you give me a
standalone main file which can start an apacheds server,
and then get the schemaContext, and at last list all the schema entries?

Thanks in advance.

2007/11/14, Ole Ersoy <ole.ersoy@gmail.com>:
>
> Yes - you nailed it.  Please let me know if you have any detailed
> questions, and I'll do my best to answer.  I think the following test will
> fit what you are looking for:
>
>
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/schema/emf/create/test/EObjectClassCreatorTest.java
>
> Spark Shen wrote:
> > I guess those test cases you mentioned resides in:
> >
> >
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/
> > <
> http://svn.apache.org/repos/asf/incubator/tuscany/java/das/ldap/das.ldap/src/test/java/org/apache/tuscany/das/ldap/
> >
> >
> > 2007/11/5, Ole Ersoy <ole.ersoy@gmail.com <mailto:ole.ersoy@gmail.com>>:
> >
> >     Hi Spark,
> >
> >     There are a lot of of Schema Unit tests for the LDAP DAS in Apache
> >     Tuscany. They all pass on ADS 1.51, run the server embedded, and
> >     seem to fit with what you have listed below.
> >
> >     Cheers,
> >     - Ole
> >
> >     Emmanuel Lecharny wrote:
> >      > Spark Shen wrote:
> >      >> I noticed 1.5 and 1.0 are two separate product version. I'd like
> to
> >      >> have a try on 1.5. What is the counter-part jar on 1.5?
> >      > 1.5 includes may improvements (performances, stability) and
> >     regarding
> >      > schema, they are now self contained (each objectclass and
> >     attribute is
> >      > an entry in the cn=schema,ou=system partition)
> >      >
> >      > Be aware that we currently don't have described yet how to design
> >     unit
> >      > tests for 1.5, due to lack of time ... (even if the site claims
> so ;)
> >      >> BTW, is my code correct to extract schema info?
> >      > I have no idea, I haven't looked at it yet :)
> >      >
> >      > If you are following the JNDI tutorial
> >      >
> >     (http://java.sun.com/products/jndi/tutorial/ldap/schema/index.html),
> it
> >      > should be OK. Otherwise, if you have a problem, then it may be a
> >     bug,
> >      > and it will deserve a JIRA.
> >      >
> >      > I must also admit I don't have time to copy/paste the code into
> >     my dev
> >      > env to check the code.
> >      >>
> >      >> 2007/11/1, Emmanuel Lecharny < elecharny@gmail.com
> >     <mailto:elecharny@gmail.com>
> >      >> <mailto:elecharny@gmail.com <mailto:elecharny@gmail.com>>>:
> >      >>
> >      >>     Spark Shen wrote:
> >      >>     > Hi
> >      >>     >
> >      >>     > I am now using DS server ( apacheds-main-0.9.3.jar) for
> >     writing test
> >      >>     > cases. But I encounter problems when listing schema.
> >      >>     > Problem Description:
> >      >>     > 1. Construct server context
> >      >>     > configuration = new MutableServerStartupConfiguration();
> >      >>     > configuration.setWorkingDirectory(new File(workingDir));
> >      >>     > cleanWorkingDir(configuration.getWorkingDirectory());
> >      >>     > port = AvailablePortFinder.getNextAvailable (1024);
> >      >>     > configuration.setLdapPort(port);
> >      >>     >         // configuration.setShutdownHookEnabled(false);
> >      >>     > serverEnv = new Hashtable<String, Object>(configuration
> >      >>     >                 .toJndiEnvironment());
> >      >>     >
> >      >>     > serverEnv.put(Context.INITIAL_CONTEXT_FACTORY,
> >      >>     >                 ServerContextFactory.class.getName());
> >      >>     >
> >      >>     > serverEnv.put (Context.PROVIDER_URL, "");
> >      >>     >
> >      >>     > serverEnv.put (Context.SECURITY_PRINCIPAL,
> >     "uid=admin,ou=system");
> >      >>     > serverEnv.put(Context.SECURITY_CREDENTIALS , "secret");
> >      >>     > serverEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
> >      >>     > rootDSE = new InitialLdapContext(serverEnv, null);
> >      >>     >
> >      >>     > 2. List schema for this context
> >      >>     >
> >      >>     >             DirContext pairs = super.rootDSE.getSchema
> ("");
> >      >>     >             NamingEnumeration<NameClassPair> ps =
> >      >>     > pairs.list ("objectClasses");
> >      >>     >             while(ps.hasMore()) {
> >      >>     >                 System.out.println(ps.next());
> >      >>     >             }
> >      >>     >
> >      >>     > And ' java.lang.UnsupportedOperationException' was thrown.
> >     I did not
> >      >>     > find a quick instruction
> >      >>     > on how to list schemas, would anyone give a hand?
> >      >>     What about switching to ADS 1.0.2 instead of a badly
> >     outdated 0.9.3
> >      >>     version ?
> >      >>
> >      >>     >
> >      >>     > --
> >      >>     > Spark Shen
> >      >>     > China Software Development Lab, IBM
> >      >>
> >      >>
> >      >>     --
> >      >>     --
> >      >>     cordialement, regards,
> >      >>     Emmanuel L├ęcharny
> >      >>     www.iktek.com <http://www.iktek.com> < http://www.iktek.com>
> >      >>     directory.apache.org <http://directory.apache.org>
> >     <http://directory.apache.org>
> >      >>
> >      >>
> >      >>
> >      >>
> >      >>
> >      >> --
> >      >> Spark Shen
> >      >> China Software Development Lab, IBM
> >      >
> >      >
> >
> >
> >
> >
> > --
> > Spark Shen
> > China Software Development Lab, IBM
>



-- 
Spark Shen
China Software Development Lab, IBM

Mime
View raw message