org.apache.directory.shared.ldap.schema.registries
Class AbstractSchemaLoader

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.registries.AbstractSchemaLoader
All Implemented Interfaces:
SchemaLoader
Direct Known Subclasses:
JarLdifSchemaLoader, LdifSchemaLoader

public abstract class AbstractSchemaLoader
extends java.lang.Object
implements SchemaLoader

An abstract class with a utility method and setListener() implemented.

Version:
$Rev$
Author:
Apache Directory Project

Field Summary
protected  SchemaLoaderListener listener
           
protected  java.util.Map<java.lang.String,Schema> schemaMap
          A map of all available schema names to schema objects.
 
Constructor Summary
AbstractSchemaLoader()
           
 
Method Summary
 void addSchema(Schema schema)
          Add a new schema to the schema's list
 java.util.Collection<Schema> getAllEnabled()
          
 java.util.Collection<Schema> getAllSchemas()
          
 java.lang.Object getDao()
           public List loadWithDependencies( Registries registries, boolean check, Schema...
protected  Schema getSchema(Entry entry)
           
 Schema getSchema(java.lang.String schemaName)
          Gets a schema object based on it's name.
 java.util.List<Entry> loadAttributeTypes(java.lang.String... schemaNames)
          Build a list of AttributeTypes read from the underlying storage for a list of specific schema, using their name
 java.util.List<Entry> loadComparators(java.lang.String... schemaNames)
          Build a list of Comparators read from the underlying storage for a list of specific schema, using their name
 java.util.List<Entry> loadDitContentRules(java.lang.String... schemaNames)
          Build a list of DitContentRules read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadDitStructureRules(java.lang.String... schemaNames)
          Build a list of DitStructureRules read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadMatchingRules(java.lang.String... schemaNames)
          Build a list of MatchingRules read from the underlying storage for a list of specific schema, using their name
 java.util.List<Entry> loadMatchingRuleUses(java.lang.String... schemaNames)
          Build a list of MatchingRuleUses read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadNameForms(java.lang.String... schemaNames)
          Build a list of NameForms read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadNormalizers(java.lang.String... schemaNames)
          Build a list of Normalizers read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadObjectClasses(java.lang.String... schemaNames)
          Build a list of ObjectClasses read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadSyntaxCheckers(java.lang.String... schemaNames)
          Build a list of SyntaxCheckers read from the underlying storage for a list of specified schema names
 java.util.List<Entry> loadSyntaxes(java.lang.String... schemaNames)
          Build a list of Syntaxes read from the underlying storage for a list of specified schema names
protected  void notifyListenerOrRegistries(Schema schema, Registries registries)
           
 void removeSchema(Schema schema)
          Remove a schema from the schema's list
 void setListener(SchemaLoaderListener listener)
          Sets listener used to notify of newly loaded schemas.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.schema.registries.SchemaLoader
loadAttributeTypes, loadComparators, loadDitContentRules, loadDitStructureRules, loadMatchingRules, loadMatchingRuleUses, loadNameForms, loadNormalizers, loadObjectClasses, loadSyntaxCheckers, loadSyntaxes
 

Field Detail

listener

protected SchemaLoaderListener listener

schemaMap

protected final java.util.Map<java.lang.String,Schema> schemaMap
A map of all available schema names to schema objects. This map is populated when this class is created with all the schemas present in the LDIF based schema repository.

Constructor Detail

AbstractSchemaLoader

public AbstractSchemaLoader()
Method Detail

setListener

public void setListener(SchemaLoaderListener listener)
Description copied from interface: SchemaLoader
Sets listener used to notify of newly loaded schemas.

Specified by:
setListener in interface SchemaLoader
Parameters:
listener - the listener to notify (only one is enough for us)

notifyListenerOrRegistries

protected final void notifyListenerOrRegistries(Schema schema,
                                                Registries registries)

getAllEnabled

public final java.util.Collection<Schema> getAllEnabled()
                                                 throws java.lang.Exception

Specified by:
getAllEnabled in interface SchemaLoader
Returns:
the list of enabled schemas
Throws:
java.lang.Exception - TODO

getAllSchemas

public final java.util.Collection<Schema> getAllSchemas()
                                                 throws java.lang.Exception

Specified by:
getAllSchemas in interface SchemaLoader
Returns:
the list of all schemas
Throws:
java.lang.Exception - TODO

getSchema

public Schema getSchema(java.lang.String schemaName)
Gets a schema object based on it's name.

Specified by:
getSchema in interface SchemaLoader
Parameters:
schemaName - the name of the schema to load
Returns:
the Schema object associated with the name

addSchema

public void addSchema(Schema schema)
Add a new schema to the schema's list

Specified by:
addSchema in interface SchemaLoader

removeSchema

public void removeSchema(Schema schema)
Remove a schema from the schema's list

Specified by:
removeSchema in interface SchemaLoader

getSchema

protected Schema getSchema(Entry entry)
                    throws java.lang.Exception
Throws:
java.lang.Exception

getDao

public java.lang.Object getDao()
public List loadWithDependencies( Registries registries, boolean check, Schema... schemas ) throws Exception { // Relax the controls at first List errors = new ArrayList(); boolean wasRelaxed = registries.isRelaxed(); registries.setRelaxed( true ); Map notLoaded = new HashMap(); for ( Schema schema : schemas ) { if ( ! registries.isSchemaLoaded( schema.getSchemaName() ) ) { notLoaded.put( schema.getSchemaName(), schema ); } } for ( Schema schema : notLoaded.values() ) { Stack beenthere = new Stack(); loadDepsFirst( schema, beenthere, notLoaded, schema, registries ); } // At the end, check the registries if required if ( check ) { errors = registries.checkRefInteg(); } // Restore the Registries isRelaxed flag registries.setRelaxed( wasRelaxed ); return errors; } /** Register the comparator contained in the given LdifEntry into the registries.

Parameters:
registries - The Registries
entry - The LdifEntry containing the comparator description
schema - The associated schema
registries - The Registries
entry - The Entry containing the comparator description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the SyntaxChecker description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the Normalizer description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the MatchingRule description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the Syntax description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the AttributeType description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the MatchingRuleUse description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the NameForm description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the DitContentRule description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the DitStructureRule description
schema - The associated schema
registries - The Registries
entry - The LdifEntry containing the ObjectClass description
schema - The associated schema
registries - The Registries
entry - The Entry containing the ObjectClass description
schema - The associated schema
Returns:
the created SyntaxChecker instance
Throws:
java.lang.Exception - If the registering failed protected LdapComparator registerComparator( Registries registries, LdifEntry entry, Schema schema ) throws Exception { return registerComparator( registries, entry.getEntry(), schema ); } /** Register the comparator contained in the given Entry into the registries.
java.lang.Exception - If the registering failed protected LdapComparator registerComparator( Registries registries, Entry entry, Schema schema ) throws Exception { LdapComparator comparator = factory.getLdapComparator( entry, registries, schema.getSchemaName() ); comparator.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( comparator ); } else if ( schema.isEnabled() && comparator.isEnabled() ) { registries.register( comparator ); } } else { if ( schema.isEnabled() && comparator.isEnabled() ) { registries.register( comparator ); } } return comparator; } /** Register the SyntaxChecker contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected SyntaxChecker registerSyntaxChecker( Registries registries, LdifEntry entry, Schema schema) throws Exception { SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry.getEntry(), registries, schema.getSchemaName() ); syntaxChecker.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( syntaxChecker ); } else if ( schema.isEnabled() && syntaxChecker.isEnabled() ) { registries.register( syntaxChecker ); } } else { if ( schema.isEnabled() && syntaxChecker.isEnabled() ) { registries.register( syntaxChecker ); } } return syntaxChecker; } /** Register the Normalizer contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected Normalizer registerNormalizer( Registries registries, LdifEntry entry, Schema schema) throws Exception { Normalizer normalizer = factory.getNormalizer( entry.getEntry(), registries, schema.getSchemaName() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( normalizer ); } else if ( schema.isEnabled() && normalizer.isEnabled() ) { registries.register( normalizer ); } } else { if ( schema.isEnabled() && normalizer.isEnabled() ) { registries.register( normalizer ); } } return normalizer; } /** Register the MatchingRule contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected MatchingRule registerMatchingRule( Registries registries, LdifEntry entry, Schema schema) throws Exception { MatchingRule matchingRule = factory.getMatchingRule( entry.getEntry(), registries, schema.getSchemaName() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( matchingRule ); } else if ( schema.isEnabled() && matchingRule.isEnabled() ) { registries.register( matchingRule ); } } else { if ( schema.isEnabled() && matchingRule.isEnabled() ) { registries.register( matchingRule ); } } return matchingRule; } /** Register the Syntax contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected LdapSyntax registerSyntax( Registries registries, LdifEntry entry, Schema schema) throws Exception { LdapSyntax syntax = factory.getSyntax( entry.getEntry(), registries, schema.getSchemaName() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( syntax ); } else if ( schema.isEnabled() && syntax.isEnabled() ) { registries.register( syntax ); } } else { if ( schema.isEnabled() && syntax.isEnabled() ) { registries.register( syntax ); } } return syntax; } /** Register the AttributeType contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected AttributeType registerAttributeType( Registries registries, LdifEntry entry, Schema schema ) throws Exception { AttributeType attributeType = factory.getAttributeType( entry.getEntry(), registries, schema.getSchemaName() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( attributeType ); } else if ( schema.isEnabled() && attributeType.isEnabled() ) { registries.register( attributeType ); } } else { if ( schema.isEnabled() && attributeType.isEnabled() ) { registries.register( attributeType ); } } return attributeType; } /** Register the MatchingRuleUse contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected MatchingRuleUse registerMatchingRuleUse( Registries registries, LdifEntry entry, Schema schema) throws Exception { throw new NotImplementedException( "Need to implement factory " + "method for creating a MatchingRuleUse" ); } /** Register the NameForm contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected NameForm registerNameForm( Registries registries, LdifEntry entry, Schema schema) throws Exception { throw new NotImplementedException( "Need to implement factory " + "method for creating a NameForm" ); } /** Register the DitContentRule contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected DITContentRule registerDitContentRule( Registries registries, LdifEntry entry, Schema schema) throws Exception { throw new NotImplementedException( "Need to implement factory " + "method for creating a DitContentRule" ); } /** Register the DitStructureRule contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected DITStructureRule registerDitStructureRule( Registries registries, LdifEntry entry, Schema schema) throws Exception { throw new NotImplementedException( "Need to implement factory " + "method for creating a DitStructureRule" ); } /** Register the ObjectClass contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected ObjectClass registerObjectClass( Registries registries, LdifEntry entry, Schema schema) throws Exception { return registerObjectClass( registries, entry.getEntry(), schema ); } /** Register the ObjectClass contained in the given LdifEntry into the registries.
java.lang.Exception - If the registering failed protected ObjectClass registerObjectClass( Registries registries, Entry entry, Schema schema) throws Exception { ObjectClass objectClass = factory.getObjectClass( entry, registries, schema.getSchemaName() ); if ( registries.isRelaxed() ) { if ( registries.acceptDisabled() ) { registries.register( objectClass ); } else if ( schema.isEnabled() && objectClass.isEnabled() ) { registries.register( objectClass ); } } else { if ( schema.isEnabled() && objectClass.isEnabled() ) { registries.register( objectClass ); } } return objectClass; } public EntityFactory getFactory() { return factory; }

loadAttributeTypes

public java.util.List<Entry> loadAttributeTypes(java.lang.String... schemaNames)
                                         throws java.lang.Exception
Build a list of AttributeTypes read from the underlying storage for a list of specific schema, using their name

Specified by:
loadAttributeTypes in interface SchemaLoader
Parameters:
schemaNames - the schema names from which AttributeTypes are loaded
Throws:
java.lang.Exception - if there are failures accessing AttributeType information

loadComparators

public java.util.List<Entry> loadComparators(java.lang.String... schemaNames)
                                      throws java.lang.Exception
Build a list of Comparators read from the underlying storage for a list of specific schema, using their name

Specified by:
loadComparators in interface SchemaLoader
Parameters:
schemaNames - the schema names from which Comparators are loaded
Throws:
java.lang.Exception - if there are failures accessing Comparator information

loadDitContentRules

public java.util.List<Entry> loadDitContentRules(java.lang.String... schemaNames)
                                          throws java.lang.Exception
Build a list of DitContentRules read from the underlying storage for a list of specified schema names

Specified by:
loadDitContentRules in interface SchemaLoader
Throws:
java.lang.Exception - if there are failures accessing DitContentRule information

loadDitStructureRules

public java.util.List<Entry> loadDitStructureRules(java.lang.String... schemaNames)
                                            throws java.lang.Exception
Build a list of DitStructureRules read from the underlying storage for a list of specified schema names

Specified by:
loadDitStructureRules in interface SchemaLoader
Throws:
java.lang.Exception - if there are failures accessing DitStructureRule information

loadMatchingRules

public java.util.List<Entry> loadMatchingRules(java.lang.String... schemaNames)
                                        throws java.lang.Exception
Build a list of MatchingRules read from the underlying storage for a list of specific schema, using their name

Specified by:
loadMatchingRules in interface SchemaLoader
Parameters:
schemaNames - the schema names from which MatchingRules are loaded
Throws:
java.lang.Exception - if there are failures accessing MatchingRule information

loadMatchingRuleUses

public java.util.List<Entry> loadMatchingRuleUses(java.lang.String... schemaNames)
                                           throws java.lang.Exception
Build a list of MatchingRuleUses read from the underlying storage for a list of specified schema names

Specified by:
loadMatchingRuleUses in interface SchemaLoader
Throws:
java.lang.Exception - if there are failures accessing MatchingRuleUses information

loadNameForms

public java.util.List<Entry> loadNameForms(java.lang.String... schemaNames)
                                    throws java.lang.Exception
Build a list of NameForms read from the underlying storage for a list of specified schema names

Specified by:
loadNameForms in interface SchemaLoader
Throws:
java.lang.Exception - if there are failures accessing NameForms information

loadNormalizers

public java.util.List<Entry> loadNormalizers(java.lang.String... schemaNames)
                                      throws java.lang.Exception
Build a list of Normalizers read from the underlying storage for a list of specified schema names

Specified by:
loadNormalizers in interface SchemaLoader
Parameters:
schemaNames - the schema names from which Normalizers are loaded
Throws:
java.lang.Exception - if there are failures accessing Normalizer information

loadObjectClasses

public java.util.List<Entry> loadObjectClasses(java.lang.String... schemaNames)
                                        throws java.lang.Exception
Build a list of ObjectClasses read from the underlying storage for a list of specified schema names

Specified by:
loadObjectClasses in interface SchemaLoader
Parameters:
schemaNames - the schema names from which ObjectClasses are loaded
Throws:
java.lang.Exception - if there are failures accessing ObjectClasses information

loadSyntaxes

public java.util.List<Entry> loadSyntaxes(java.lang.String... schemaNames)
                                   throws java.lang.Exception
Build a list of Syntaxes read from the underlying storage for a list of specified schema names

Specified by:
loadSyntaxes in interface SchemaLoader
Parameters:
schemaNames - the schema names from which Syntaxes are loaded
Throws:
java.lang.Exception - if there are failures accessing Syntax information

loadSyntaxCheckers

public java.util.List<Entry> loadSyntaxCheckers(java.lang.String... schemaNames)
                                         throws java.lang.Exception
Build a list of SyntaxCheckers read from the underlying storage for a list of specified schema names

Specified by:
loadSyntaxCheckers in interface SchemaLoader
Throws:
java.lang.Exception - if there are failures accessing SyntaxChecker information


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.