directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
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 GMT
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 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.directory.shared</groupId>
-      <artifactId>shared-all</artifactId>
-      <version>${org.apache.directory.shared.version}</version>
+      <artifactId>shared-ldap</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-cursor</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema-manager</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema-loader</artifactId>
     </dependency>
 
     <dependency>

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 @@
       </dependency>
 
       <dependency>
+        <groupId>org.apache.directory.shared</groupId>
+        <artifactId>shared-ldap-schema</artifactId>
+        <version>${org.apache.directory.shared.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.directory.shared</groupId>
+        <artifactId>shared-ldap-schema-manager</artifactId>
+        <version>${org.apache.directory.shared.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.directory.shared</groupId>
+        <artifactId>shared-ldap-schema-loader</artifactId>
+        <version>${org.apache.directory.shared.version}</version>
+      </dependency>
+
+      <dependency>
         <groupId>commons-pool</groupId>
         <artifactId>commons-pool</artifactId>
         <version>${commons.pool.version}</version>



Mime
View raw message