Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 11506 invoked from network); 4 Feb 2010 04:30:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 4 Feb 2010 04:30:07 -0000 Received: (qmail 66553 invoked by uid 500); 4 Feb 2010 04:30:07 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 66489 invoked by uid 500); 4 Feb 2010 04:30:06 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 66480 invoked by uid 99); 4 Feb 2010 04:30:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Feb 2010 04:30:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Feb 2010 04:30:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D048A23889BB; Thu, 4 Feb 2010 04:29:41 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r906359 - in /directory/clients/ldap/trunk: ./ ldap-client-api/ ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ ldap-client-test/src/test/java/org/apache/directory/shared/client/api/ Date: Thu, 04 Feb 2010 04:29:41 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100204042941.D048A23889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: kayyagari Date: Thu Feb 4 04:29:41 2010 New Revision: 906359 URL: http://svn.apache.org/viewvc?rev=906359&view=rev Log: o added support for loading the default schema present in the shared-ldap-schema jar using JarLdifLoader o added the necessary dependencies Modified: directory/clients/ldap/trunk/ldap-client-api/pom.xml directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java directory/clients/ldap/trunk/pom.xml Modified: directory/clients/ldap/trunk/ldap-client-api/pom.xml URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/pom.xml?rev=906359&r1=906358&r2=906359&view=diff ============================================================================== --- directory/clients/ldap/trunk/ldap-client-api/pom.xml (original) +++ directory/clients/ldap/trunk/ldap-client-api/pom.xml Thu Feb 4 04:29:41 2010 @@ -43,8 +43,27 @@ org.apache.directory.shared - shared-all - ${org.apache.directory.shared.version} + shared-ldap + + + + org.apache.directory.shared + shared-cursor + + + + org.apache.directory.shared + shared-ldap-schema + + + + org.apache.directory.shared + shared-ldap-schema-manager + + + + org.apache.directory.shared + shared-ldap-schema-loader Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=906359&r1=906358&r2=906359&view=diff ============================================================================== --- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original) +++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Thu Feb 4 04:29:41 2010 @@ -128,6 +128,9 @@ import org.apache.directory.shared.ldap.message.control.Control; import org.apache.directory.shared.ldap.name.LdapDN; import org.apache.directory.shared.ldap.name.RDN; +import org.apache.directory.shared.ldap.schema.SchemaManager; +import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader; +import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager; import org.apache.directory.shared.ldap.util.LdapURL; import org.apache.directory.shared.ldap.util.StringTools; import org.apache.mina.core.filterchain.IoFilter; @@ -204,6 +207,8 @@ /** A flag indicating that the BindRequest has been issued and successfully authenticated the user */ private boolean authenticated = false; + /** the schema manager */ + private SchemaManager schemaManager; // ~~~~~~~~~~~~~~~~~ common error messages ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2863,6 +2868,44 @@ return supportedControls; } + + /** + * loads the default schema that is bundled in the shared-ldap-schema.jar + * + * @throws LdapException in case of problems while loading the schema + */ + public void loadSchema() throws LdapException + { + try + { + JarLdifSchemaLoader jarSchemaLoader = new JarLdifSchemaLoader(); + + schemaManager = new DefaultSchemaManager( jarSchemaLoader ); + schemaManager.loadAllEnabled(); + if( ! schemaManager.getErrors().isEmpty() ) + { + String msg = "there are errors while loading the schema"; + LOG.error( msg + " {}", schemaManager.getErrors() ); + throw new LdapException( msg ); + } + } + catch( LdapException le ) + { + throw le; + } + catch( Exception e ) + { + LOG.error( "failed to load the schema", e ); + throw new LdapException( e ); + } + } + + + public SchemaManager getSchemaManager() + { + return schemaManager; + } + /** * fetches the rootDSE from the server Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=906359&r1=906358&r2=906359&view=diff ============================================================================== --- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original) +++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Thu Feb 4 04:29:41 2010 @@ -45,6 +45,7 @@ import org.apache.directory.shared.ldap.entry.client.ClientStringValue; import org.apache.directory.shared.ldap.filter.EqualityNode; import org.apache.directory.shared.ldap.filter.SearchScope; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.junit.After; import org.junit.Before; import org.junit.Ignore; @@ -181,4 +182,13 @@ assertTrue( Arrays.equals( "secret".getBytes(), entry.get( SchemaConstants.USER_PASSWORD_AT ).getBytes() ) ); } + + @Test + public void testLoadSchema() throws LdapException + { + connection.loadSchema(); + SchemaManager manager = connection.getSchemaManager(); + assertNotNull( manager ); + assertTrue( manager.isEnabled( "system" ) ); + } } Modified: directory/clients/ldap/trunk/pom.xml URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/pom.xml?rev=906359&r1=906358&r2=906359&view=diff ============================================================================== --- directory/clients/ldap/trunk/pom.xml (original) +++ directory/clients/ldap/trunk/pom.xml Thu Feb 4 04:29:41 2010 @@ -78,6 +78,24 @@ + org.apache.directory.shared + shared-ldap-schema + ${org.apache.directory.shared.version} + + + + org.apache.directory.shared + shared-ldap-schema-manager + ${org.apache.directory.shared.version} + + + + org.apache.directory.shared + shared-ldap-schema-loader + ${org.apache.directory.shared.version} + + + commons-pool commons-pool ${commons.pool.version}