directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r883809 - in /directory: apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/ shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/ shared...
Date Tue, 24 Nov 2009 18:39:17 GMT
Author: elecharny
Date: Tue Nov 24 18:39:15 2009
New Revision: 883809

URL: http://svn.apache.org/viewvc?rev=883809&view=rev
Log:
o Added a method taking a (String... schemaNames) parameter for each registry
o Used varargs for Schema loading 

Modified:
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java
    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/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/SchemaLoader.java

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?rev=883809&r1=883808&r2=883809&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java Tue Nov 24 18:39:15 2009
@@ -23,7 +23,6 @@
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -323,31 +322,32 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadAttributeTypes( Schema schema ) throws Exception
+    public List<Entry> loadAttributeTypes( Schema... schemas ) throws Exception
     {
-        LinkedList<AttributeType> deferred = new LinkedList<AttributeType>();
-        
-        LdapDN dn = updateDNs( staticAttributeTypeDNs, SchemaConstants.ATTRIBUTES_TYPE_PATH, schema );
-        
         List<Entry> attributeTypeList = new ArrayList<Entry>();
 
-        // Check that we don't have an entry in the Dit for this schema
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
-        {
-            // No : get out, no AttributeType to load
-            return attributeTypeList;
-        }
-        
-        LOG.debug( "{} schema: loading attributeTypes", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        // Loop on all the AttributeTypes and add them to the list
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ServerEntry result = list.get();
+            LdapDN dn = updateDNs( staticAttributeTypeDNs, SchemaConstants.ATTRIBUTES_TYPE_PATH, schema );
+            
+            // Check that we don't have an entry in the Dit for this schema
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                // No : get out, no AttributeType to load
+                return attributeTypeList;
+            }
             
-            attributeTypeList.add( result );
+            LOG.debug( "{} schema: loading attributeTypes", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            // Loop on all the AttributeTypes and add them to the list
+            while ( list.next() )
+            {
+                ServerEntry result = list.get();
+                
+                attributeTypeList.add( result );
+            }
         }
         
         return attributeTypeList;
@@ -357,26 +357,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadComparators( Schema schema ) throws Exception
+    public List<Entry> loadComparators( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticComparatorsDNs, SchemaConstants.COMPARATORS_PATH, schema );
-        
         List<Entry> comparatorList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return comparatorList;
         }
         
-        LOG.debug( "{} schema: loading comparators", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ClonedServerEntry entry = list.get();
+            LdapDN dn = updateDNs( staticComparatorsDNs, SchemaConstants.COMPARATORS_PATH, schema );
+            
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return comparatorList;
+            }
             
-            comparatorList.add( entry );
+            LOG.debug( "{} schema: loading comparators", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            while ( list.next() )
+            {
+                ClonedServerEntry entry = list.get();
+                
+                comparatorList.add( entry );
+            }
         }
         
         return comparatorList;
@@ -386,7 +394,7 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadDitContentRules( Schema schema ) throws Exception
+    public List<Entry> loadDitContentRules( Schema... schemas ) throws Exception
     {
         LOG.error( "DitContentRule loading NYI" );
         
@@ -397,7 +405,7 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadDitStructureRules( Schema schema ) throws Exception
+    public List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception
     {
         LOG.error( "DitStructureRule loading NYI" );
         
@@ -408,26 +416,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRules( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRules( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticMatchingRulesDNs, SchemaConstants.MATCHING_RULES_PATH, schema );
-        
         List<Entry> matchingRuleList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return matchingRuleList;
         }
         
-        LOG.debug( "{} schema: loading matchingRules", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ServerEntry entry = list.get();
-
-            matchingRuleList.add( entry );
+            LdapDN dn = updateDNs( staticMatchingRulesDNs, SchemaConstants.MATCHING_RULES_PATH, schema );
+            
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return matchingRuleList;
+            }
+            
+            LOG.debug( "{} schema: loading matchingRules", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            while ( list.next() )
+            {
+                ServerEntry entry = list.get();
+    
+                matchingRuleList.add( entry );
+            }
         }
         
         return matchingRuleList;
@@ -437,7 +453,7 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRuleUses( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws Exception
     {
         LOG.error( "MatchingRuleUse loading NYI" );
         
@@ -448,7 +464,7 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadNameForms( Schema schema ) throws Exception
+    public List<Entry> loadNameForms( Schema... schemas ) throws Exception
     {
         LOG.error( "NameForm loading NYI" );
         
@@ -459,26 +475,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadNormalizers( Schema schema ) throws Exception
+    public List<Entry> loadNormalizers( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticNormalizersDNs, SchemaConstants.NORMALIZERS_PATH, schema );
-        
         List<Entry> normalizerList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return normalizerList;
         }
         
-        LOG.debug( "{} schema: loading normalizers", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ClonedServerEntry entry = list.get();
+            LdapDN dn = updateDNs( staticNormalizersDNs, SchemaConstants.NORMALIZERS_PATH, schema );
+            
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return normalizerList;
+            }
             
-            normalizerList.add( entry );
+            LOG.debug( "{} schema: loading normalizers", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            while ( list.next() )
+            {
+                ClonedServerEntry entry = list.get();
+                
+                normalizerList.add( entry );
+            }
         }
         
         return normalizerList;
@@ -488,26 +512,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadObjectClasses( Schema schema ) throws Exception
+    public List<Entry> loadObjectClasses( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticObjectClassesDNs, SchemaConstants.OBJECT_CLASSES_PATH, schema );
-        
         List<Entry> objectClassList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return objectClassList;
         }
         
-        LOG.debug( "{} schema: loading objectClasses", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ClonedServerEntry entry = list.get();
+            LdapDN dn = updateDNs( staticObjectClassesDNs, SchemaConstants.OBJECT_CLASSES_PATH, schema );
+            
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return objectClassList;
+            }
             
-            objectClassList.add( entry );
+            LOG.debug( "{} schema: loading objectClasses", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            while ( list.next() )
+            {
+                ClonedServerEntry entry = list.get();
+                
+                objectClassList.add( entry );
+            }
         }
         
         return objectClassList;
@@ -517,26 +549,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxes( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxes( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticSyntaxesDNs, SchemaConstants.SYNTAXES_PATH, schema );
-        
         List<Entry> syntaxList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return syntaxList;
         }
         
-        LOG.debug( "{} schema: loading syntaxes", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ServerEntry entry = list.get();
+            LdapDN dn = updateDNs( staticSyntaxesDNs, SchemaConstants.SYNTAXES_PATH, schema );
             
-            syntaxList.add( entry );
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return syntaxList;
+            }
+            
+            LOG.debug( "{} schema: loading syntaxes", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+            
+            while ( list.next() )
+            {
+                ServerEntry entry = list.get();
+                
+                syntaxList.add( entry );
+            }
         }
         
         return syntaxList;
@@ -546,26 +586,34 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxCheckers( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception
     {
-        LdapDN dn = updateDNs( staticSyntaxCheckersDNs, SchemaConstants.SYNTAX_CHECKERS_PATH, schema );
-        
         List<Entry> syntaxCheckerList = new ArrayList<Entry>();
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+        
+        if ( schemas == null )
         {
             return syntaxCheckerList;
         }
         
-        LOG.debug( "{} schema: loading syntaxCsheckers", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
+        for ( Schema schema : schemas )
         {
-            ServerEntry entry = list.get();
+            LdapDN dn = updateDNs( staticSyntaxCheckersDNs, SchemaConstants.SYNTAX_CHECKERS_PATH, schema );
+            
+            if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
+            {
+                return syntaxCheckerList;
+            }
+            
+            LOG.debug( "{} schema: loading syntaxCsheckers", schema.getSchemaName() );
+            
+            EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
             
-            syntaxCheckerList.add( entry );
+            while ( list.next() )
+            {
+                ServerEntry entry = list.get();
+                
+                syntaxCheckerList.add( entry );
+            }
         }
         
         return syntaxCheckerList;

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.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/JarLdifSchemaLoader.java?rev=883809&r1=883808&r2=883809&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java Tue Nov 24 18:39:15 2009
@@ -156,25 +156,33 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadComparators( Schema schema ) throws Exception
+    public List<Entry> loadComparators( Schema... schemas ) throws Exception
     {
-        String comparatorsDirectory = getSchemaDirectory( schema ) 
-            + "/" + SchemaConstants.COMPARATORS_PATH;
-        
         List<Entry> comparatorList = new ArrayList<Entry>();
         
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        if ( schemas == null )
+        {
+            return comparatorList;
+        }
+        
+        for ( Schema schema : schemas )
         {
-            Pattern regex = Pattern.compile( ".*" + comparatorsDirectory + "/m-oid=.*\\." + LDIF_EXT );
+            String comparatorsDirectory = getSchemaDirectory( schema ) 
+                + "/" + SchemaConstants.COMPARATORS_PATH;
             
-            if ( regex.matcher( resourcePath ).matches() )
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "comparator LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                comparatorList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + comparatorsDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "comparator LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    comparatorList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -183,32 +191,35 @@
     
     
     /**
-     * Loads the SyntaxCheckers from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which syntaxCheckers are loaded
-     * @throws Exception if there are failures accessing syntaxChecker 
-     * information stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxCheckers( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception
     {
-        String syntaxCheckersDirectory = getSchemaDirectory( schema ) 
-            +  "/" + SchemaConstants.SYNTAX_CHECKERS_PATH;
-
         List<Entry> syntaxCheckerList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + syntaxCheckersDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return syntaxCheckerList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String syntaxCheckersDirectory = getSchemaDirectory( schema ) 
+                +  "/" + SchemaConstants.SYNTAX_CHECKERS_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "syntaxChecker LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
+                Pattern regex = Pattern.compile( ".*" + syntaxCheckersDirectory + "/m-oid=.*\\." + LDIF_EXT );
                 
-                syntaxCheckerList.add( entry.getEntry() );
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "syntaxChecker LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+                    
+                    syntaxCheckerList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -217,32 +228,35 @@
     
     
     /**
-     * Loads the Normalizers from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which normalizers are loaded
-     * @throws Exception if there are failures accessing normalizer information
-     * stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadNormalizers( Schema schema ) throws Exception
+    public List<Entry> loadNormalizers( Schema... schemas ) throws Exception
     {
-        String normalizersDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.NORMALIZERS_PATH;
-
         List<Entry> normalizerList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + normalizersDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return normalizerList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String normalizersDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.NORMALIZERS_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "normalizer LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
+                Pattern regex = Pattern.compile( ".*" + normalizersDirectory + "/m-oid=.*\\." + LDIF_EXT );
                 
-                normalizerList.add( entry.getEntry() );
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "normalizer LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+                    
+                    normalizerList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -251,32 +265,35 @@
     
     
     /**
-     * Loads the MatchingRules from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which matchingRules are loaded
-     * @throws Exception if there are failures accessing matchingRule 
-     * information stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRules( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRules( Schema... schemas ) throws Exception
     {
-        String matchingRulesDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.MATCHING_RULES_PATH;
-        
         List<Entry> matchingRuleList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + matchingRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+            return matchingRuleList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String matchingRulesDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.MATCHING_RULES_PATH;
             
-            if ( regex.matcher( resourcePath ).matches() )
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "matchingRules LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                matchingRuleList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + matchingRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "matchingRules LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    matchingRuleList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -285,32 +302,35 @@
     
     
     /**
-     * Loads the Syntaxes from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which syntaxes are loaded
-     * @throws Exception if there are failures accessing comparator information
-     * stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxes( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxes( Schema... schemas ) throws Exception
     {
-        String syntaxesDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.SYNTAXES_PATH;
-
         List<Entry> syntaxList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + syntaxesDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return syntaxList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String syntaxesDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.SYNTAXES_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "syntax LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
+                Pattern regex = Pattern.compile( ".*" + syntaxesDirectory + "/m-oid=.*\\." + LDIF_EXT );
                 
-                syntaxList.add( entry.getEntry() );
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "syntax LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+                    
+                    syntaxList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -319,34 +339,37 @@
 
     
     /**
-     * Loads the AttributeTypes from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which attributeTypes are loaded
-     * @throws Exception if there are failures accessing attributeTypes 
-     * information stored in LDIF files
-     */
-    public List<Entry> loadAttributeTypes( Schema schema ) throws Exception
-    {
-    	// check that the attributeTypes directory exists for the schema
-        String attributeTypesDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.ATTRIBUTES_TYPE_PATH;
-        
+     * {@inheritDoc}
+     */
+    public List<Entry> loadAttributeTypes( Schema... schemas ) throws Exception
+    {
         List<Entry> attributeTypeList = new ArrayList<Entry>();
 
-        // get list of attributeType LDIF schema files in attributeTypes
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        if ( schemas == null )
+        {
+            return attributeTypeList;
+        }
+        
+        for ( Schema schema : schemas )
         {
-            Pattern regex = Pattern.compile( ".*" + attributeTypesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+        	// check that the attributeTypes directory exists for the schema
+            String attributeTypesDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.ATTRIBUTES_TYPE_PATH;
             
-            if ( regex.matcher( resourcePath ).matches() )
+            // get list of attributeType LDIF schema files in attributeTypes
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "attributeType LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                attributeTypeList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + attributeTypesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "attributeType LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    attributeTypeList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -355,32 +378,35 @@
 
 
     /**
-     * Loads the MatchingRuleUses from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which matchingRuleUses are loaded
-     * @throws Exception if there are failures accessing matchingRuleUse 
-     * information stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRuleUses( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws Exception
     {
-        String matchingRuleUsesDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.MATCHING_RULE_USE_PATH;
-        
         List<Entry> matchingRuleUseList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
+        {
+            return matchingRuleUseList;
+        }
+        
+        for ( Schema schema : schemas )
         {
-            Pattern regex = Pattern.compile( ".*" + matchingRuleUsesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+            String matchingRuleUsesDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.MATCHING_RULE_USE_PATH;
             
-            if ( regex.matcher( resourcePath ).matches() )
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "matchingRuleUse LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                matchingRuleUseList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + matchingRuleUsesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "matchingRuleUse LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    matchingRuleUseList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -389,31 +415,34 @@
 
 
     /**
-     * Loads the NameForms from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which nameForms are loaded
-     * @throws Exception if there are failures accessing nameForm information
-     * stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadNameForms( Schema schema ) throws Exception
+    public List<Entry> loadNameForms( Schema... schemas ) throws Exception
     {
-        String nameFormsDirectory = getSchemaDirectory( schema ) + "/" + SchemaConstants.NAME_FORMS_PATH;
-
         List<Entry> nameFormList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + nameFormsDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return nameFormList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String nameFormsDirectory = getSchemaDirectory( schema ) + "/" + SchemaConstants.NAME_FORMS_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "nameForm LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                nameFormList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + nameFormsDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "nameForm LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    nameFormList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -422,32 +451,35 @@
 
 
     /**
-     * Loads the DitContentRules from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which ditContentRules are loaded
-     * @throws Exception if there are failures accessing ditContentRules 
-     * information stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadDitContentRules( Schema schema ) throws Exception
+    public List<Entry> loadDitContentRules( Schema... schemas ) throws Exception
     {
-        String ditContentRulesDirectory = getSchemaDirectory( schema ) + "/" + 
-            SchemaConstants.DIT_CONTENT_RULES_PATH;
-
         List<Entry> ditContentRulesList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + ditContentRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return ditContentRulesList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String ditContentRulesDirectory = getSchemaDirectory( schema ) + "/" + 
+                SchemaConstants.DIT_CONTENT_RULES_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "ditContentRule LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
+                Pattern regex = Pattern.compile( ".*" + ditContentRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
                 
-                ditContentRulesList.add( entry.getEntry() );
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "ditContentRule LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+                    
+                    ditContentRulesList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -456,32 +488,35 @@
 
 
     /**
-     * Loads the ditStructureRules from LDIF files in the supplied schema into 
-     * the supplied registries.
-     *
-     * @param schema the schema for which ditStructureRules are loaded
-     * @throws Exception if there are failures accessing ditStructureRule 
-     * information stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadDitStructureRules( Schema schema ) throws Exception
+    public List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception
     {
-        String ditStructureRulesDirectory = getSchemaDirectory( schema )
-            + "/" + SchemaConstants.DIT_STRUCTURE_RULES_PATH;
-
         List<Entry> ditStructureRuleList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + ditStructureRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return ditStructureRuleList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+            String ditStructureRulesDirectory = getSchemaDirectory( schema )
+                + "/" + SchemaConstants.DIT_STRUCTURE_RULES_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "ditStructureRule LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
+                Pattern regex = Pattern.compile( ".*" + ditStructureRulesDirectory + "/m-oid=.*\\." + LDIF_EXT );
                 
-                ditStructureRuleList.add( entry.getEntry() );
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "ditStructureRule LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+                    
+                    ditStructureRuleList.add( entry.getEntry() );
+                }
             }
         }
         
@@ -490,32 +525,35 @@
 
 
     /**
-     * Loads the ObjectClasses from LDIF files in the supplied schema into the 
-     * supplied registries.
-     *
-     * @param schema the schema for which objectClasses are loaded
-     * @throws Exception if there are failures accessing objectClass information
-     * stored in LDIF files
+     * {@inheritDoc}
      */
-    public List<Entry> loadObjectClasses( Schema schema ) throws Exception
+    public List<Entry> loadObjectClasses( Schema... schemas ) throws Exception
     {
-    	// get objectClasses directory, check if exists, return if not
-    	String objectClassesDirectory = getSchemaDirectory( schema ) + "/" + SchemaConstants.OBJECT_CLASSES_PATH;
-
         List<Entry> objectClassList = new ArrayList<Entry>();
-
-        for ( String resourcePath : RESOURCE_MAP.keySet() )
+        
+        if ( schemas == null )
         {
-            Pattern regex = Pattern.compile( ".*" + objectClassesDirectory + "/m-oid=.*\\." + LDIF_EXT );
-            
-            if ( regex.matcher( resourcePath ).matches() )
+            return objectClassList;
+        }
+        
+        for ( Schema schema : schemas )
+        {
+        	// get objectClasses directory, check if exists, return if not
+        	String objectClassesDirectory = getSchemaDirectory( schema ) + "/" + SchemaConstants.OBJECT_CLASSES_PATH;
+    
+            for ( String resourcePath : RESOURCE_MAP.keySet() )
             {
-                URL resource = getResource( resourcePath, "objectClass LDIF file" );
-                LdifReader reader = new LdifReader( resource.openStream() );
-                LdifEntry entry = reader.next();
-                reader.close();
-
-                objectClassList.add( entry.getEntry() );
+                Pattern regex = Pattern.compile( ".*" + objectClassesDirectory + "/m-oid=.*\\." + LDIF_EXT );
+                
+                if ( regex.matcher( resourcePath ).matches() )
+                {
+                    URL resource = getResource( resourcePath, "objectClass LDIF file" );
+                    LdifReader reader = new LdifReader( resource.openStream() );
+                    LdifEntry entry = reader.next();
+                    reader.close();
+    
+                    objectClassList.add( entry.getEntry() );
+                }
             }
         }
         

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=883809&r1=883808&r2=883809&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 Tue Nov 24 18:39:15 2009
@@ -319,27 +319,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadComparators( Schema schema ) throws Exception
+    public List<Entry> loadComparators( Schema... schemas ) throws Exception
     {
-        File comparatorsDirectory = new File( getSchemaDirectory( schema ), 
-            SchemaConstants.COMPARATORS_PATH );
-        
         List<Entry> comparatorList = new ArrayList<Entry>();
-        
-        if ( ! comparatorsDirectory.exists() )
+
+        if ( schemas == null )
         {
             return comparatorList;
         }
         
-        File[] comparators = comparatorsDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : comparators )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File comparatorsDirectory = new File( getSchemaDirectory( schema ), 
+                SchemaConstants.COMPARATORS_PATH );
             
-            comparatorList.add( entry.getEntry() );
+            if ( ! comparatorsDirectory.exists() )
+            {
+                return comparatorList;
+            }
+            
+            File[] comparators = comparatorsDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : comparators )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                comparatorList.add( entry.getEntry() );
+            }
         }
         
         return comparatorList;
@@ -349,27 +357,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxCheckers( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception
     {
-        File syntaxCheckersDirectory = new File( getSchemaDirectory( schema ), 
-            SchemaConstants.SYNTAX_CHECKERS_PATH );
-        
         List<Entry> syntaxCheckerList = new ArrayList<Entry>();
 
-        if ( ! syntaxCheckersDirectory.exists() )
+        if ( schemas == null )
         {
             return syntaxCheckerList;
         }
         
-        File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : syntaxCheckerFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File syntaxCheckersDirectory = new File( getSchemaDirectory( schema ), 
+                SchemaConstants.SYNTAX_CHECKERS_PATH );
             
-            syntaxCheckerList.add( entry.getEntry() );
+            if ( ! syntaxCheckersDirectory.exists() )
+            {
+                return syntaxCheckerList;
+            }
+            
+            File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : syntaxCheckerFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                syntaxCheckerList.add( entry.getEntry() );
+            }
         }
         
         return syntaxCheckerList;
@@ -379,27 +395,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadNormalizers( Schema schema ) throws Exception
+    public List<Entry> loadNormalizers( Schema... schemas ) throws Exception
     {
-        File normalizersDirectory = new File( getSchemaDirectory( schema ), 
-            SchemaConstants.NORMALIZERS_PATH );
-        
         List<Entry> normalizerList = new ArrayList<Entry>();
 
-        if ( ! normalizersDirectory.exists() )
+        if ( schemas == null )
         {
             return normalizerList;
         }
         
-        File[] normalizerFiles = normalizersDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : normalizerFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File normalizersDirectory = new File( getSchemaDirectory( schema ), 
+                SchemaConstants.NORMALIZERS_PATH );
             
-            normalizerList.add( entry.getEntry() );
+            if ( ! normalizersDirectory.exists() )
+            {
+                return normalizerList;
+            }
+            
+            File[] normalizerFiles = normalizersDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : normalizerFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                normalizerList.add( entry.getEntry() );
+            }
         }
         
         return normalizerList;
@@ -409,27 +433,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRules( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRules( Schema... schemas ) throws Exception
     {
-        File matchingRulesDirectory = new File( getSchemaDirectory( schema ), 
-            SchemaConstants.MATCHING_RULES_PATH );
-        
         List<Entry> matchingRuleList = new ArrayList<Entry>();
 
-        if ( ! matchingRulesDirectory.exists() )
+        if ( schemas == null )
         {
             return matchingRuleList;
         }
         
-        File[] matchingRuleFiles = matchingRulesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : matchingRuleFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
-
-            matchingRuleList.add( entry.getEntry() );
+            File matchingRulesDirectory = new File( getSchemaDirectory( schema ), 
+                SchemaConstants.MATCHING_RULES_PATH );
+            
+            if ( ! matchingRulesDirectory.exists() )
+            {
+                return matchingRuleList;
+            }
+            
+            File[] matchingRuleFiles = matchingRulesDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : matchingRuleFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+    
+                matchingRuleList.add( entry.getEntry() );
+            }
         }
         
         return matchingRuleList;
@@ -439,27 +471,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadSyntaxes( Schema schema ) throws Exception
+    public List<Entry> loadSyntaxes( Schema... schemas ) throws Exception
     {
-        File syntaxesDirectory = new File( getSchemaDirectory( schema ), 
-            SchemaConstants.SYNTAXES_PATH );
-        
         List<Entry> syntaxList = new ArrayList<Entry>();
-
-        if ( ! syntaxesDirectory.exists() )
+        
+        if ( schemas == null )
         {
             return syntaxList;
         }
         
-        File[] syntaxFiles = syntaxesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : syntaxFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
-
-            syntaxList.add( entry.getEntry() );
+            File syntaxesDirectory = new File( getSchemaDirectory( schema ), 
+                SchemaConstants.SYNTAXES_PATH );
+            
+            if ( ! syntaxesDirectory.exists() )
+            {
+                return syntaxList;
+            }
+            
+            File[] syntaxFiles = syntaxesDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : syntaxFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+    
+                syntaxList.add( entry.getEntry() );
+            }
         }
         
         return syntaxList;
@@ -469,28 +509,36 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadAttributeTypes( Schema schema ) throws Exception
+    public List<Entry> loadAttributeTypes( Schema... schemas ) throws Exception
     {
-    	// check that the attributeTypes directory exists for the schema
-        File attributeTypesDirectory = new File ( getSchemaDirectory( schema ), SchemaConstants.ATTRIBUTES_TYPE_PATH );
-        
         List<Entry> attributeTypeList = new ArrayList<Entry>();
 
-        if ( ! attributeTypesDirectory.exists() )
+        if ( schemas == null )
         {
             return attributeTypeList;
         }
         
-        // get list of attributeType LDIF schema files in attributeTypes
-        File[] attributeTypeFiles = attributeTypesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : attributeTypeFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+        	// check that the attributeTypes directory exists for the schema
+            File attributeTypesDirectory = new File ( getSchemaDirectory( schema ), SchemaConstants.ATTRIBUTES_TYPE_PATH );
+            
+            if ( ! attributeTypesDirectory.exists() )
+            {
+                return attributeTypeList;
+            }
+            
+            // get list of attributeType LDIF schema files in attributeTypes
+            File[] attributeTypeFiles = attributeTypesDirectory.listFiles( ldifFilter );
             
-            attributeTypeList.add( entry.getEntry() );
+            for ( File ldifFile : attributeTypeFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                attributeTypeList.add( entry.getEntry() );
+            }
         }
         
         return attributeTypeList;
@@ -500,27 +548,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadMatchingRuleUses( Schema schema ) throws Exception
+    public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws Exception
     {
-        File matchingRuleUsesDirectory = new File( getSchemaDirectory( schema ),
-            SchemaConstants.MATCHING_RULE_USE_PATH );
-        
         List<Entry> matchingRuleUseList = new ArrayList<Entry>();
-
-        if ( ! matchingRuleUsesDirectory.exists() )
+        
+        if ( schemas == null )
         {
             return matchingRuleUseList;
         }
         
-        File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : matchingRuleUseFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File matchingRuleUsesDirectory = new File( getSchemaDirectory( schema ),
+                SchemaConstants.MATCHING_RULE_USE_PATH );
             
-            matchingRuleUseList.add( entry.getEntry() );
+            if ( ! matchingRuleUsesDirectory.exists() )
+            {
+                return matchingRuleUseList;
+            }
+            
+            File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : matchingRuleUseFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                matchingRuleUseList.add( entry.getEntry() );
+            }
         }
         
         return matchingRuleUseList;
@@ -530,27 +586,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadNameForms( Schema schema ) throws Exception
+    public List<Entry> loadNameForms( Schema... schemas ) throws Exception
     {
-        File nameFormsDirectory = new File( getSchemaDirectory( schema ),
-            SchemaConstants.NAME_FORMS_PATH );
-        
         List<Entry> nameFormList = new ArrayList<Entry>();
-
-        if ( ! nameFormsDirectory.exists() )
+        
+        if ( schemas == null )
         {
             return nameFormList;
         }
         
-        File[] nameFormFiles = nameFormsDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : nameFormFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File nameFormsDirectory = new File( getSchemaDirectory( schema ),
+                SchemaConstants.NAME_FORMS_PATH );
+            
+            if ( ! nameFormsDirectory.exists() )
+            {
+                return nameFormList;
+            }
             
-            nameFormList.add( entry.getEntry() );
+            File[] nameFormFiles = nameFormsDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : nameFormFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                nameFormList.add( entry.getEntry() );
+            }
         }
         
         return nameFormList;
@@ -560,27 +624,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadDitContentRules( Schema schema ) throws Exception
+    public List<Entry> loadDitContentRules( Schema... schemas ) throws Exception
     {
-        File ditContentRulesDirectory = new File( getSchemaDirectory( schema ),
-            SchemaConstants.DIT_CONTENT_RULES_PATH );
-        
         List<Entry> ditContentRuleList = new ArrayList<Entry>();
         
-        if ( ! ditContentRulesDirectory.exists() )
+        if ( schemas == null )
         {
             return ditContentRuleList;
         }
         
-        File[] ditContentRuleFiles = ditContentRulesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : ditContentRuleFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File ditContentRulesDirectory = new File( getSchemaDirectory( schema ),
+                SchemaConstants.DIT_CONTENT_RULES_PATH );
+            
+            if ( ! ditContentRulesDirectory.exists() )
+            {
+                return ditContentRuleList;
+            }
             
-            ditContentRuleList.add( entry.getEntry() );
+            File[] ditContentRuleFiles = ditContentRulesDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : ditContentRuleFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                ditContentRuleList.add( entry.getEntry() );
+            }
         }
         
         return ditContentRuleList;
@@ -590,27 +662,35 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadDitStructureRules( Schema schema ) throws Exception
+    public List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception
     {
-        File ditStructureRulesDirectory = new File( getSchemaDirectory( schema ),
-            SchemaConstants.DIT_STRUCTURE_RULES_PATH );
-
         List<Entry> ditStructureRuleList = new ArrayList<Entry>();
         
-        if ( ! ditStructureRulesDirectory.exists() )
+        if ( schemas == null )
         {
             return ditStructureRuleList;
         }
         
-        File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles( ldifFilter );
-        
-        for ( File ldifFile : ditStructureRuleFiles )
+        for ( Schema schema : schemas )
         {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+            File ditStructureRulesDirectory = new File( getSchemaDirectory( schema ),
+                SchemaConstants.DIT_STRUCTURE_RULES_PATH );
             
-            ditStructureRuleList.add( entry.getEntry() );
+            if ( ! ditStructureRulesDirectory.exists() )
+            {
+                return ditStructureRuleList;
+            }
+            
+            File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles( ldifFilter );
+            
+            for ( File ldifFile : ditStructureRuleFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                ditStructureRuleList.add( entry.getEntry() );
+            }
         }
         
         return ditStructureRuleList;
@@ -620,28 +700,36 @@
     /**
      * {@inheritDoc}
      */
-    public List<Entry> loadObjectClasses( Schema schema ) throws Exception
+    public List<Entry> loadObjectClasses( Schema... schemas ) throws Exception
     {
-    	// get objectClasses directory, check if exists, return if not
-    	File objectClassesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.OBJECT_CLASSES_PATH );
-        
         List<Entry> objectClassList = new ArrayList<Entry>();
-
-        if ( ! objectClassesDirectory.exists() )
+        
+        if ( schemas == null )
         {
             return objectClassList;
         }
         
-        // get list of objectClass LDIF files from directory and load
-        File[] objectClassFiles = objectClassesDirectory.listFiles( ldifFilter );
-       
-        for ( File ldifFile : objectClassFiles )
-        {
-            LdifReader reader = new LdifReader( ldifFile );
-            LdifEntry entry = reader.next();
-            reader.close();
+        for ( Schema schema : schemas )
+        {
+        	// get objectClasses directory, check if exists, return if not
+        	File objectClassesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.OBJECT_CLASSES_PATH );
+            
+            if ( ! objectClassesDirectory.exists() )
+            {
+                return objectClassList;
+            }
             
-            objectClassList.add( entry.getEntry() );
+            // get list of objectClass LDIF files from directory and load
+            File[] objectClassFiles = objectClassesDirectory.listFiles( ldifFilter );
+           
+            for ( File ldifFile : objectClassFiles )
+            {
+                LdifReader reader = new LdifReader( ldifFile );
+                LdifEntry entry = reader.next();
+                reader.close();
+                
+                objectClassList.add( entry.getEntry() );
+            }
         }
         
         return objectClassList;

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=883809&r1=883808&r2=883809&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 Tue Nov 24 18:39:15 2009
@@ -20,9 +20,11 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -660,4 +662,172 @@
     {
         return null;
     }
+    
+    
+    private Schema[] buildSchemaArray( String... schemaNames ) throws Exception
+    {
+        Schema[] schemas = new Schema[schemaNames.length];
+        int pos = 0;
+        
+        for ( String schemaName : schemaNames )
+        {
+            schemas[pos++] = getSchema( schemaName );
+        }
+        
+        return schemas;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadAttributeTypes( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadAttributeTypes( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadComparators( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadComparators( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadDitContentRules( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadDitContentRules( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadDitStructureRules( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadDitStructureRules( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadMatchingRules( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadMatchingRules( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadMatchingRuleUses( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadMatchingRuleUses( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadNameForms( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadNameForms( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadNormalizers( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadNormalizers( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadObjectClasses( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadObjectClasses( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadSyntaxes( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadSyntaxes( buildSchemaArray( schemaNames ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadSyntaxCheckers( String... schemaNames ) throws Exception
+    {
+        if ( schemaNames == null )
+        {
+            return new ArrayList<Entry>();
+        }
+        
+        return loadSyntaxCheckers( buildSchemaArray( schemaNames ) );
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java?rev=883809&r1=883808&r2=883809&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java Tue Nov 24 18:39:15 2009
@@ -88,102 +88,223 @@
     
     
     /**
-     * Build a list of AttributeTypes read from the underlying storage
+     * Build a list of AttributeTypes read from the underlying storage for
+     * a list of specified schema
      *
-     * @param schema the schema from which AttributeTypes are loaded
+     * @param schemas the schemas from which AttributeTypes are loaded
      * @throws Exception if there are failures accessing AttributeType information
      */
-    List<Entry> loadAttributeTypes( Schema schema ) throws Exception;
+    List<Entry> loadAttributeTypes( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of Comparators read from the underlying storage
+     * Build a list of AttributeTypes read from the underlying storage for
+     * a list of specific schema, using their name
      *
-     * @param schema the schema from which Comparators are loaded
+     * @param schemaNames the schema names from which AttributeTypes are loaded
+     * @throws Exception if there are failures accessing AttributeType information
+     */
+    List<Entry> loadAttributeTypes( String... schemaNames ) throws Exception;
+    
+    
+    /**
+     * Build a list of Comparators read from the underlying storage for
+     * a list of specific schema.
+     *
+     * @param schemas the schemas from which Comparators are loaded
+     * @throws Exception if there are failures accessing Comparator information
+     */
+    List<Entry> loadComparators( Schema... schemas ) throws Exception;
+    
+    
+    /**
+     * Build a list of Comparators read from the underlying storage for
+     * a list of specific schema, using their name
+     *
+     * @param schemaNames the schema names from which Comparators are loaded
      * @throws Exception if there are failures accessing Comparator information
      */
-    List<Entry> loadComparators( Schema schema ) throws Exception;
+    List<Entry> loadComparators( String... schemaNames ) throws Exception;
+    
+    
+    /**
+     * Build a list of DitContentRules read from the underlying storage for
+     * a list of specific schema.
+     *
+     * @param schemas the schemas from which DitContentRules are loaded
+     * @throws Exception if there are failures accessing DitContentRule information
+     */
+    List<Entry> loadDitContentRules( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of DitContentRules read from the underlying storage
+     * Build a list of DitContentRules read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which DitContentRules are loaded
+     * @param schemaNames the schema names from which DitContentRules are loaded
      * @throws Exception if there are failures accessing DitContentRule information
      */
-    List<Entry> loadDitContentRules( Schema schema ) throws Exception;
+    List<Entry> loadDitContentRules( String... schemanames ) throws Exception;
+
+
+    /**
+     * Build a list of DitStructureRules read from the underlying storage for
+     * a list of specific schema.
+     *
+     * @param schemas the schemas from which DitStructureRules are loaded
+     * @throws Exception if there are failures accessing DitStructureRule information
+     */
+    List<Entry> loadDitStructureRules( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of DitStructureRules read from the underlying storage
+     * Build a list of DitStructureRules read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which DitStructureRules are loaded
+     * @param schemaNames the schema names from which DitStructureRules are loaded
      * @throws Exception if there are failures accessing DitStructureRule information
      */
-    List<Entry> loadDitStructureRules( Schema schema ) throws Exception;
+    List<Entry> loadDitStructureRules( String... schemanames ) throws Exception;
+
+
+    /**
+     * Build a list of MatchingRules read from the underlying storage for
+     * a list of specific schema
+     *
+     * @param schemas the schemas from which MatchingRules are loaded
+     * @throws Exception if there are failures accessing MatchingRule information
+     */
+    List<Entry> loadMatchingRules( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of MatchingRules read from the underlying storage
+     * Build a list of MatchingRules read from the underlying storage for
+     * a list of specific schema, using their name
      *
-     * @param schema the schema from which MatchingRules are loaded
+     * @param schemaNames the schema names from which MatchingRules are loaded
      * @throws Exception if there are failures accessing MatchingRule information
      */
-    List<Entry> loadMatchingRules( Schema schema ) throws Exception;
+    List<Entry> loadMatchingRules( String... schemaNames ) throws Exception;
     
     
     /**
-     * Build a list of MatchingRuleUses read from the underlying storage
+     * Build a list of MatchingRuleUses read from the underlying storage for
+     * a list of specific schema.
      *
-     * @param schema the schema from which MatchingRuleUses are loaded
+     * @param schemas the schemas from which MatchingRuleUses are loaded
      * @throws Exception if there are failures accessing MatchingRuleUse information
      */
-    List<Entry> loadMatchingRuleUses( Schema schema ) throws Exception;
+    List<Entry> loadMatchingRuleUses( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of NameForms read from the underlying storage
+     * Build a list of MatchingRuleUses read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which NameForms are loaded
+     * @param schemaNames the schema names from which MatchingRuleUses are loaded
+     * @throws Exception if there are failures accessing MatchingRuleUses information
+     */
+    List<Entry> loadMatchingRuleUses( String... schemanames ) throws Exception;
+
+
+    /**
+     * Build a list of NameForms read from the underlying storage for
+     * a list of specific schema.
+     *
+     * @param schemas the schemas from which NameForms are loaded
      * @throws Exception if there are failures accessing NameForm information
      */
-    List<Entry> loadNameForms( Schema schema ) throws Exception;
+    List<Entry> loadNameForms( Schema... schemas ) throws Exception;
+    
+    
+    /**
+     * Build a list of NameForms read from the underlying storage for
+     * a list of specified schema names
+     *
+     * @param schemaNames the schema names from which NameForms are loaded
+     * @throws Exception if there are failures accessing NameForms information
+     */
+    List<Entry> loadNameForms( String... schemanames ) throws Exception;
+
+
+    /**
+     * Build a list of Normalizers read from the underlying storage for
+     * a list of specified schema
+     *
+     * @param schemas the schemas from which Normalizers are loaded
+     * @throws Exception if there are failures accessing Normalizer information
+     */
+    List<Entry> loadNormalizers( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of Normalizers read from the underlying storage
+     * Build a list of Normalizers read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which Normalizers are loaded
+     * @param schemaNames the schema names from which Normalizers are loaded
      * @throws Exception if there are failures accessing Normalizer information
      */
-    List<Entry> loadNormalizers( Schema schema ) throws Exception;
+    List<Entry> loadNormalizers( String... schemaNames ) throws Exception;
     
     
     /**
-     * Build a list of ObjectClasses read from the underlying storage
+     * Build a list of ObjectClasses read from the underlying storage for
+     * a list of specific schema.
      *
-     * @param schema the schema from which ObjectClasses are loaded
+     * @param schemas the schemas from which ObjectClasses are loaded
      * @throws Exception if there are failures accessing ObjectClass information
      */
-    List<Entry> loadObjectClasses( Schema schema ) throws Exception;
+    List<Entry> loadObjectClasses( Schema... schemas ) throws Exception;
     
     
     /**
-     * Build a list of Syntaxes read from the underlying storage
+     * Build a list of ObjectClasses read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which Syntaxes are loaded
+     * @param schemaNames the schema names from which ObjectClasses are loaded
+     * @throws Exception if there are failures accessing ObjectClasses information
+     */
+    List<Entry> loadObjectClasses( String... schemaNames ) throws Exception;
+    
+    
+    /**
+     * Build a list of Syntaxes read from the underlying storage for
+     * a list of specified schema
+     *
+     * @param schemas the schemas from which Syntaxes are loaded
      * @throws Exception if there are failures accessing Syntax information
      */
-    List<Entry> loadSyntaxes( Schema schema ) throws Exception;
+    List<Entry> loadSyntaxes( Schema... schemas ) throws Exception;
+    
     
+    /**
+     * Build a list of Syntaxes read from the underlying storage for
+     * a list of specified schema names
+     *
+     * @param schemaNames the schema names from which Syntaxes are loaded
+     * @throws Exception if there are failures accessing Syntax information
+     */
+    List<Entry> loadSyntaxes( String... schemaNames ) throws Exception;
     
+    
+    /**
+     * Build a list of SyntaxCheckers read from the underlying storage for
+     * a list of specified schema
+     *
+     * @param schemas the schemas from which SyntaxCheckers are loaded
+     * @throws Exception if there are failures accessing SyntaxChecker information
+     */
+    List<Entry> loadSyntaxCheckers( Schema... schemas ) throws Exception;
+
+
     /**
-     * Build a list of SyntaxCheckers read from the underlying storage
+     * Build a list of SyntaxCheckers read from the underlying storage for
+     * a list of specified schema names
      *
-     * @param schema the schema from which SyntaxCheckers are loaded
+     * @param schemaNames the schema names from which SyntaxCheckers are loaded
      * @throws Exception if there are failures accessing SyntaxChecker information
      */
-    List<Entry> loadSyntaxCheckers( Schema schema ) throws Exception;
+    List<Entry> loadSyntaxCheckers( String... schemanames ) throws Exception;
 
 
     /**



Mime
View raw message