You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2009/08/29 22:14:13 UTC
svn commit: r809196 - in /directory/shared/branches/shared-schema:
ldap-schema-loader/
ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/
ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/
lda...
Author: akarasulu
Date: Sat Aug 29 20:14:12 2009
New Revision: 809196
URL: http://svn.apache.org/viewvc?rev=809196&view=rev
Log:
fixing bugs and adding more code to properly explode the schema repository from within the jar file
Modified:
directory/shared/branches/shared-schema/ldap-schema-loader/pom.xml
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java
directory/shared/branches/shared-schema/ldap-schema/pom.xml
directory/shared/branches/shared-schema/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schema/ldif/extractor/SchemaLdifExtractorTest.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/pom.xml?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/pom.xml (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/pom.xml Sat Aug 29 20:14:12 2009
@@ -41,5 +41,29 @@
<groupId>${pom.groupId}</groupId>
<version>${pom.version}</version>
</dependency>
+
+ <dependency>
+ <artifactId>shared-ldap-schema</artifactId>
+ <groupId>${pom.groupId}</groupId>
+ <version>${pom.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>workingDirectory</name>
+ <value>${basedir}/target</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java Sat Aug 29 20:14:12 2009
@@ -49,6 +49,7 @@
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.FilenameFilter;
+import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -185,14 +186,22 @@
for ( int ii = 0; ii < ldifFiles.length; ii++ )
{
- LdifReader reader = new LdifReader( new File( schemaDirectory, ldifFiles[ii] ) );
- LdifEntry entry = reader.next();
- Schema schema = factory.getSchema( entry.getEntry() );
- schemaMap.put( schema.getSchemaName(), schema );
-
- if ( IS_DEBUG )
+ try
+ {
+ LdifReader reader = new LdifReader( new File( schemaDirectory, ldifFiles[ii] ) );
+ LdifEntry entry = reader.next();
+ Schema schema = factory.getSchema( entry.getEntry() );
+ schemaMap.put( schema.getSchemaName(), schema );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Schema Initialized ... \n{}", schema );
+ }
+ }
+ catch ( Exception e )
{
- LOG.debug( "Schema Initialized ... \n{}", schema );
+ LOG.error( "Failed to load schema LDIF file " + ldifFiles[ii], e );
+ throw e;
}
}
}
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/SchemaEntityFactory.java Sat Aug 29 20:14:12 2009
@@ -201,7 +201,7 @@
{
LdapComparator<?> comparator = null;
Class<?> clazz = null;
-
+
if ( bytecode == null )
{
clazz = Class.forName( className );
@@ -379,8 +379,8 @@
MatchingRule mr = new MatchingRule( oid );
mr.setSyntaxOid( syntaxOid );
mr.setSchemaName( schema );
- mr.applyRegistries( targetRegistries );
setSchemaObjectProperties( mr, entry );
+ mr.applyRegistries( targetRegistries );
return mr;
}
@@ -407,7 +407,6 @@
{
String oid = entry.get( MetaSchemaConstants.M_OID_AT ).getString();
ObjectClass oc = new ObjectClass( oid );
- oc.applyRegistries( targetRegistries );
oc.setSchemaName( schema );
if ( entry.get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) != null )
@@ -436,6 +435,7 @@
}
setSchemaObjectProperties( oc, entry );
+ oc.applyRegistries( targetRegistries );
return oc;
}
@@ -446,7 +446,6 @@
String oid = entry.get( MetaSchemaConstants.M_OID_AT ).getString();
AttributeType at = new AttributeType( oid );
- at.applyRegistries( targetRegistries );
at.setSchemaName( schema );
setSchemaObjectProperties( at, entry );
@@ -498,6 +497,7 @@
at.setUsage( UsageEnum.getUsage( entry.get( MetaSchemaConstants.M_USAGE_AT ).getString() ) );
}
+ at.applyRegistries( targetRegistries );
return at;
}
Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java Sat Aug 29 20:14:12 2009
@@ -24,9 +24,11 @@
import java.io.File;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-
+
/**
* Tests the LdifSchemaLoader.
*
@@ -35,8 +37,14 @@
*/
public class LdifSchemaLoaderTest extends TestCase
{
- public static void testConstructor() throws Exception
+ public static void testLoader() throws Exception
{
- LdifSchemaLoader loader = new LdifSchemaLoader( new File( "/Users/akarasulu/schema" ) );
+ File workingDirectory = new File( System.getProperty( "workingDirectory" ) );
+ SchemaLdifExtractor extractor = new SchemaLdifExtractor( workingDirectory );
+ extractor.extractOrCopy();
+
+ LdifSchemaLoader loader = new LdifSchemaLoader( new File( workingDirectory, "schema" ) );
+ Registries registries = new Registries();
+ loader.loadAllEnabled( registries );
}
}
Modified: directory/shared/branches/shared-schema/ldap-schema/pom.xml
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema/pom.xml?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema/pom.xml (original)
+++ directory/shared/branches/shared-schema/ldap-schema/pom.xml Sat Aug 29 20:14:12 2009
@@ -31,10 +31,25 @@
<packaging>jar</packaging>
<description>
- A special jar file that contains pre-loaded partition data with schema
- information. The schema partition data is in LDIF format and so can use
- the LDIF partition implementation to mount. This data will be presented
- at a fixed location in the directory information tree off of the ou=schema
- namingContext. This artifact contains the LDIF files for this partition.
+ Jar bundled LDIF files containing schema data using the Apache Directory
+ specific meta schema for describing schema information using LDAP. This
+ jar can be used by clients as well as by ApacheDS' schema partition.
</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <configuration>
+ <systemProperties>
+ <property>
+ <name>workingDirectory</name>
+ <value>${basedir}/target</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
Modified: directory/shared/branches/shared-schema/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schema/ldif/extractor/SchemaLdifExtractorTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schema/ldif/extractor/SchemaLdifExtractorTest.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schema/ldif/extractor/SchemaLdifExtractorTest.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schema/ldif/extractor/SchemaLdifExtractorTest.java Sat Aug 29 20:14:12 2009
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-
+
/**
* Tests the SchemaLdifExtractor class.
*
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java Sat Aug 29 20:14:12 2009
@@ -207,13 +207,27 @@
{
AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
- sup = atRegistry.lookup( supOid );
+ if ( supOid != null )
+ {
+ sup = atRegistry.lookup( supOid );
+ }
MatchingRuleRegistry mrRegistry = registries.getMatchingRuleRegistry();
- equality = mrRegistry.lookup( equalityOid );
- ordering = mrRegistry.lookup( orderingOid );
- substr = mrRegistry.lookup( substrOid );
+ if ( equalityOid != null )
+ {
+ equality = mrRegistry.lookup( equalityOid );
+ }
+
+ if ( orderingOid != null )
+ {
+ ordering = mrRegistry.lookup( orderingOid );
+ }
+
+ if ( substrOid != null )
+ {
+ substr = mrRegistry.lookup( substrOid );
+ }
LdapSyntaxRegistry lsRegistry = registries.getLdapSyntaxRegistry();
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java Sat Aug 29 20:14:12 2009
@@ -87,10 +87,19 @@
*/
public final void loadAllEnabled( Registries registries ) throws Exception
{
+ Map<String,Schema> notloaded = new HashMap<String,Schema>( schemaMap );
+ for ( String schemaName : schemaMap.keySet() )
+ {
+ if ( registries.isSchemaLoaded( schemaName ) )
+ {
+ notloaded.remove( schemaName );
+ }
+ }
+
for ( Schema schema : schemaMap.values() )
{
loadDepsFirst( schema, new Stack<String>(),
- new HashMap<String,Schema>(), schema, registries );
+ notloaded, schema, registries );
}
}
Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java?rev=809196&r1=809195&r2=809196&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java Sat Aug 29 20:14:12 2009
@@ -167,6 +167,11 @@
*/
public T lookup( String oid ) throws NamingException
{
+ if ( oid == null )
+ {
+ return null;
+ }
+
T schemaObject = byOid.get( oid );
if ( schemaObject == null )