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

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.registries.Registries
All Implemented Interfaces:
java.lang.Cloneable, SchemaLoaderListener

public class Registries
extends java.lang.Object
implements SchemaLoaderListener, java.lang.Cloneable

Document this class.

Version:
$Rev: 927122 $
Author:
Apache Directory Project

Field Summary
protected  AttributeTypeRegistry attributeTypeRegistry
          The AttributeType registry
protected  ComparatorRegistry comparatorRegistry
          The LdapSyntax registry
protected  DITContentRuleRegistry ditContentRuleRegistry
          The DitContentRule registry
protected  DITStructureRuleRegistry ditStructureRuleRegistry
          The DitStructureRule registry
protected  OidRegistry globalOidRegistry
          The global OID registry
protected  LdapSyntaxRegistry ldapSyntaxRegistry
          The LdapSyntax registry
protected  java.util.Map<java.lang.String,Schema> loadedSchemas
          A String name to Schema object map for the schemas loaded into this registry.
protected  MatchingRuleRegistry matchingRuleRegistry
          The MatchingRule registry
protected  MatchingRuleUseRegistry matchingRuleUseRegistry
          The MatchingRuleUse registry
protected  NameFormRegistry nameFormRegistry
          The NameForm registry
protected  NormalizerRegistry normalizerRegistry
          The Normalizer registry
protected  ObjectClassRegistry objectClassRegistry
          The ObjectClass registry
static boolean RELAXED
           
static boolean STRICT
          Two flags for RELAXED and STRUCT
protected  SyntaxCheckerRegistry syntaxCheckerRegistry
          The SyntaxChecker registry
protected  java.util.Map<SchemaObjectWrapper,java.util.Set<SchemaObjectWrapper>> usedBy
          A map storing a relation between a SchemaObject and all the referencing SchemaObjects.
protected  java.util.Map<SchemaObjectWrapper,java.util.Set<SchemaObjectWrapper>> using
          A map storing a relation between a SchemaObject and all the SchemaObjects it uses.
 
Constructor Summary
Registries(SchemaManager schemaManager)
          Creates a new instance of Registries.
 
Method Summary
 java.util.List<java.lang.Throwable> add(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Applies the added SchemaObject to the given register
 void addReference(SchemaObject base, SchemaObject referenced)
          Add an association between a SchemaObject an the SchemaObject it refers
 java.util.Set<SchemaObjectWrapper> addSchema(java.lang.String schemaName)
          Create a new schema association with its content
 void associateWithSchema(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Store the given SchemaObject in the Map associating SchemaObjetcs to their related Schema.
 void buildReference(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Build the SchemaObject references
 java.util.List<java.lang.Throwable> buildReferences()
          Build the usedBy and using references from the stored elements.
 boolean check()
          Check the registries for invalid relations.
 java.util.List<java.lang.Throwable> checkRefInteg()
          Attempts to resolve the dependent schema objects of all entities that refer to other objects within the registries.
 void clear()
          Clear the registries from all its elements
 Registries clone()
          Clone the Registries.
 boolean contains(SchemaObject schemaObject)
          Tells if the given SchemaObject is present in one schema.
 void delCrossReferences(AttributeType attributeType)
          Add the SchemaObjectReferences.
 void delCrossReferences(MatchingRule matchingRule)
          Delete the MR references (using and usedBy) : MR -> C MR -> N MR -> S
 java.util.List<java.lang.Throwable> delete(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Remove the given SchemaObject from the registries
 void delReference(SchemaObject base, SchemaObject referenced)
          Delete an association between a SchemaObject an the SchemaObject it refers
 void dissociateFromSchema(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Store the given SchemaObject in the Map associating SchemaObjetcs to their related Schema.
 void dissociateFromSchema(SchemaObject schemaObject)
          Remove the given SchemaObject from the Map associating SchemaObjetcs to their related Schema.
 java.lang.String dumpUsedBy()
          Dump the UsedBy data structure as a String
 java.lang.String dumpUsing()
          Dump the Using data structure as a String
 AttributeTypeRegistry getAttributeTypeRegistry()
           
 ComparatorRegistry getComparatorRegistry()
           
 DITContentRuleRegistry getDitContentRuleRegistry()
           
 DITStructureRuleRegistry getDitStructureRuleRegistry()
           
 OidRegistry getGlobalOidRegistry()
           
 LdapSyntaxRegistry getLdapSyntaxRegistry()
           
 Schema getLoadedSchema(java.lang.String schemaName)
          Gets a schema that has been loaded into these Registries.
 java.util.Map<java.lang.String,Schema> getLoadedSchemas()
          Gets an unmodifiable Map of schema names to loaded Schema objects.
 MatchingRuleRegistry getMatchingRuleRegistry()
           
 MatchingRuleUseRegistry getMatchingRuleUseRegistry()
           
 NameFormRegistry getNameFormRegistry()
           
 NormalizerRegistry getNormalizerRegistry()
           
 java.util.Map<java.lang.String,java.util.Set<SchemaObjectWrapper>> getObjectBySchemaName()
           
 ObjectClassRegistry getObjectClassRegistry()
           
 java.lang.String getOid(java.lang.String name)
          Get an OID from a name.
 java.util.Set<SchemaObjectWrapper> getReferencing(SchemaObject schemaObject)
          Check that we can remove a given SchemaObject without breaking some of its references.
 SyntaxCheckerRegistry getSyntaxCheckerRegistry()
           
 java.util.Set<SchemaObjectWrapper> getUsedBy(SchemaObject schemaObject)
          Gets the Set of SchemaObjects referencing the given SchemaObject
 java.util.Set<SchemaObjectWrapper> getUsing(SchemaObject schemaObject)
          Gets the Set of SchemaObjects referenced by the given SchemaObject
 boolean isDisabledAccepted()
          Tells if the Registries accept disabled elements.
 boolean isReferenced(SchemaObject schemaObject)
          Checks if a specific SchemaObject is referenced by any other SchemaObject.
 boolean isRelaxed()
          Tells if the Registries is permissive or if it must be checked against inconsistencies.
 boolean isSchemaLoaded(java.lang.String schemaName)
          Checks to see if a particular Schema is loaded.
 boolean isStrict()
          Tells if the Registries is strict.
 void removeReference(java.util.List<java.lang.Throwable> errors, SchemaObject schemaObject)
          Unlink the SchemaObject references
 void schemaLoaded(Schema schema)
          Merely adds the schema to the set of loaded schemas.
 void schemaUnloaded(Schema schema)
          Merely removes the schema from the set of loaded schemas.
 void setDisabledAccepted(boolean disabledAccepted)
          Change the Registries behavior regarding disabled SchemaObject element.
 void setRelaxed()
          Change the Registries to a relaxed mode, where invalid SchemaObjects can be registered.
 void setStrict()
          Change the Registries to a strict mode, where invalid SchemaObjects cannot be registered.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loadedSchemas

protected java.util.Map<java.lang.String,Schema> loadedSchemas
A String name to Schema object map for the schemas loaded into this registry. The loaded schemas may be disabled.


attributeTypeRegistry

protected AttributeTypeRegistry attributeTypeRegistry
The AttributeType registry


objectClassRegistry

protected ObjectClassRegistry objectClassRegistry
The ObjectClass registry


comparatorRegistry

protected ComparatorRegistry comparatorRegistry
The LdapSyntax registry


ditContentRuleRegistry

protected DITContentRuleRegistry ditContentRuleRegistry
The DitContentRule registry


ditStructureRuleRegistry

protected DITStructureRuleRegistry ditStructureRuleRegistry
The DitStructureRule registry


matchingRuleRegistry

protected MatchingRuleRegistry matchingRuleRegistry
The MatchingRule registry


matchingRuleUseRegistry

protected MatchingRuleUseRegistry matchingRuleUseRegistry
The MatchingRuleUse registry


nameFormRegistry

protected NameFormRegistry nameFormRegistry
The NameForm registry


normalizerRegistry

protected NormalizerRegistry normalizerRegistry
The Normalizer registry


globalOidRegistry

protected OidRegistry globalOidRegistry
The global OID registry


syntaxCheckerRegistry

protected SyntaxCheckerRegistry syntaxCheckerRegistry
The SyntaxChecker registry


ldapSyntaxRegistry

protected LdapSyntaxRegistry ldapSyntaxRegistry
The LdapSyntax registry


STRICT

public static final boolean STRICT
Two flags for RELAXED and STRUCT

See Also:
Constant Field Values

RELAXED

public static final boolean RELAXED
See Also:
Constant Field Values

usedBy

protected java.util.Map<SchemaObjectWrapper,java.util.Set<SchemaObjectWrapper>> usedBy
A map storing a relation between a SchemaObject and all the referencing SchemaObjects.


using

protected java.util.Map<SchemaObjectWrapper,java.util.Set<SchemaObjectWrapper>> using
A map storing a relation between a SchemaObject and all the SchemaObjects it uses.

Constructor Detail

Registries

public Registries(SchemaManager schemaManager)
Creates a new instance of Registries.

Parameters:
oidRegistry - the OID registry
Method Detail

getAttributeTypeRegistry

public AttributeTypeRegistry getAttributeTypeRegistry()
Returns:
The AttributeType registry

getComparatorRegistry

public ComparatorRegistry getComparatorRegistry()
Returns:
The Comparator registry

getDitContentRuleRegistry

public DITContentRuleRegistry getDitContentRuleRegistry()
Returns:
The DITContentRule registry

getDitStructureRuleRegistry

public DITStructureRuleRegistry getDitStructureRuleRegistry()
Returns:
The DITStructureRule registry

getMatchingRuleRegistry

public MatchingRuleRegistry getMatchingRuleRegistry()
Returns:
The MatchingRule registry

getMatchingRuleUseRegistry

public MatchingRuleUseRegistry getMatchingRuleUseRegistry()
Returns:
The MatchingRuleUse registry

getNameFormRegistry

public NameFormRegistry getNameFormRegistry()
Returns:
The NameForm registry

getNormalizerRegistry

public NormalizerRegistry getNormalizerRegistry()
Returns:
The Normalizer registry

getObjectClassRegistry

public ObjectClassRegistry getObjectClassRegistry()
Returns:
The ObjectClass registry

getGlobalOidRegistry

public OidRegistry getGlobalOidRegistry()
Returns:
The global Oid registry

getSyntaxCheckerRegistry

public SyntaxCheckerRegistry getSyntaxCheckerRegistry()
Returns:
The SyntaxChecker registry

getLdapSyntaxRegistry

public LdapSyntaxRegistry getLdapSyntaxRegistry()
Returns:
The LdapSyntax registry

getOid

public java.lang.String getOid(java.lang.String name)
Get an OID from a name. As we have many possible registries, we have to look in all of them to get the one containing the OID.

Parameters:
name - The name we are looking at
Returns:
The associated OID

getLoadedSchema

public Schema getLoadedSchema(java.lang.String schemaName)
Gets a schema that has been loaded into these Registries.

Parameters:
schemaName - the name of the schema to lookup
Returns:
the loaded Schema if one corresponding to the name exists

isSchemaLoaded

public boolean isSchemaLoaded(java.lang.String schemaName)
Checks to see if a particular Schema is loaded.

Parameters:
schemaName - the name of the Schema to check
Returns:
true if the Schema is loaded, false otherwise

checkRefInteg

public java.util.List<java.lang.Throwable> checkRefInteg()
Attempts to resolve the dependent schema objects of all entities that refer to other objects within the registries. Null references will be handed appropriately. The order in which the SchemaObjects must be :
  • 1) Normalizers, Comparators and SyntaxCheckers (as they depend on nothing)
  • 2) Syntaxes (depend on SyntaxCheckers)
  • 3) MatchingRules (depend on Syntaxes, Normalizers and Comparators
  • 4) AttributeTypes (depend on MatchingRules, Syntaxes and AttributeTypes : in this case, we first handle the superior)
  • 5) ObjectClasses (depend on AttributeTypes and ObjectClasses)

    Later, when we will support them :
  • 6) MatchingRuleUses (depend on matchingRules and AttributeTypes)
  • 7) DitContentRules (depend on ObjectClasses and AttributeTypes)
  • 8) NameForms (depends on ObjectClasses and AttributeTypes)
  • 9) DitStructureRules (depends onNameForms and DitStructureRules) *

    Returns:
    a list of exceptions encountered while resolving entities

  • delCrossReferences

    public void delCrossReferences(AttributeType attributeType)
    Add the SchemaObjectReferences. This method does nothing, it's just a catch all. The other methods will be called for each specific schemaObject public void addCrossReferences( SchemaObject schemaObject ) { // Do nothing : it's a catch all method. } /** Delete the AT references (using and usedBy) : AT -> MR (for EQUALITY, ORDERING and SUBSTR) AT -> S AT -> AT


    delCrossReferences

    public void delCrossReferences(MatchingRule matchingRule)
    Delete the MR references (using and usedBy) : MR -> C MR -> N MR -> S


    buildReference

    public void buildReference(java.util.List<java.lang.Throwable> errors,
                               SchemaObject schemaObject)
    Build the SchemaObject references


    removeReference

    public void removeReference(java.util.List<java.lang.Throwable> errors,
                                SchemaObject schemaObject)
    Unlink the SchemaObject references


    buildReferences

    public java.util.List<java.lang.Throwable> buildReferences()
    Build the usedBy and using references from the stored elements.

    Returns:
    A list of all the errors we met during the cross reference update

    add

    public java.util.List<java.lang.Throwable> add(java.util.List<java.lang.Throwable> errors,
                                                   SchemaObject schemaObject)
                                            throws LdapException
    Applies the added SchemaObject to the given register

    Throws:
    LdapException

    delete

    public java.util.List<java.lang.Throwable> delete(java.util.List<java.lang.Throwable> errors,
                                                      SchemaObject schemaObject)
                                               throws LdapException
    Remove the given SchemaObject from the registries

    Throws:
    LdapException

    schemaLoaded

    public void schemaLoaded(Schema schema)
    Merely adds the schema to the set of loaded schemas. Does not actually do any work to add schema objects to registries. Listener method called to indicate a loader or other agent finished loading the schema objects for a schema into the Registries.

    Specified by:
    schemaLoaded in interface SchemaLoaderListener
    Parameters:
    schema - the Schema that was loaded

    schemaUnloaded

    public void schemaUnloaded(Schema schema)
    Merely removes the schema from the set of loaded schemas. Does not actually do any work to remove schema objects from registries. Listener method called to indicate an agent finished loading the schema objects for a schema into the Registries.

    Specified by:
    schemaUnloaded in interface SchemaLoaderListener
    Parameters:
    schema - the Schema that was unloaded

    getLoadedSchemas

    public java.util.Map<java.lang.String,Schema> getLoadedSchemas()
    Gets an unmodifiable Map of schema names to loaded Schema objects.

    Returns:
    the map of loaded Schema objects

    getObjectBySchemaName

    public java.util.Map<java.lang.String,java.util.Set<SchemaObjectWrapper>> getObjectBySchemaName()
    Returns:
    Gets a reference to the Map associating a schemaName to its contained SchemaObjects

    contains

    public boolean contains(SchemaObject schemaObject)
    Tells if the given SchemaObject is present in one schema. The schema may be disabled.

    Parameters:
    schemaObject - The schemaObject we are looking for
    Returns:
    true if the schemaObject is present in a schema

    addSchema

    public java.util.Set<SchemaObjectWrapper> addSchema(java.lang.String schemaName)
    Create a new schema association with its content

    Parameters:
    schemaName - The schema name

    associateWithSchema

    public void associateWithSchema(java.util.List<java.lang.Throwable> errors,
                                    SchemaObject schemaObject)
    Store the given SchemaObject in the Map associating SchemaObjetcs to their related Schema.

    Parameters:
    schemaObject - The schemaObject to register
    Throws:
    LdapException - If there is a problem

    dissociateFromSchema

    public void dissociateFromSchema(java.util.List<java.lang.Throwable> errors,
                                     SchemaObject schemaObject)
                              throws LdapException
    Store the given SchemaObject in the Map associating SchemaObjetcs to their related Schema.

    Parameters:
    schemaObject - The schemaObject to register
    Throws:
    LdapException - If there is a problem

    dissociateFromSchema

    public void dissociateFromSchema(SchemaObject schemaObject)
                              throws LdapException
    Remove the given SchemaObject from the Map associating SchemaObjetcs to their related Schema.

    Parameters:
    schemaObject - The schemaObject to remove
    Throws:
    LdapException - If there is a problem

    isReferenced

    public boolean isReferenced(SchemaObject schemaObject)
    Checks if a specific SchemaObject is referenced by any other SchemaObject.

    Parameters:
    schemaObject - The SchemaObject we are looking for
    Returns:
    true if there is at least one SchemaObjetc referencing the given one

    getUsedBy

    public java.util.Set<SchemaObjectWrapper> getUsedBy(SchemaObject schemaObject)
    Gets the Set of SchemaObjects referencing the given SchemaObject

    Parameters:
    schemaObject - The SchemaObject we are looking for
    Returns:
    The Set of referencing SchemaObject, or null

    dumpUsedBy

    public java.lang.String dumpUsedBy()
    Dump the UsedBy data structure as a String


    dumpUsing

    public java.lang.String dumpUsing()
    Dump the Using data structure as a String


    getUsing

    public java.util.Set<SchemaObjectWrapper> getUsing(SchemaObject schemaObject)
    Gets the Set of SchemaObjects referenced by the given SchemaObject

    Parameters:
    schemaObject - The SchemaObject we are looking for
    Returns:
    The Set of referenced SchemaObject, or null

    addReference

    public void addReference(SchemaObject base,
                             SchemaObject referenced)
    Add an association between a SchemaObject an the SchemaObject it refers

    Parameters:
    base - The base SchemaObject
    referenced - The referenced SchemaObject

    delReference

    public void delReference(SchemaObject base,
                             SchemaObject referenced)
    Delete an association between a SchemaObject an the SchemaObject it refers

    Parameters:
    base - The base SchemaObject
    referenced - The referenced SchemaObject

    check

    public boolean check()
    Check the registries for invalid relations. This check stops at the first error.

    Returns:
    true if the Registries is consistent, false otherwise

    clone

    public Registries clone()
                     throws java.lang.CloneNotSupportedException
    Clone the Registries. This is done in two steps : - first clone the SchemaObjetc registries - second restore the relation between them

    Overrides:
    clone in class java.lang.Object
    Throws:
    java.lang.CloneNotSupportedException

    isRelaxed

    public boolean isRelaxed()
    Tells if the Registries is permissive or if it must be checked against inconsistencies.

    Returns:
    True if SchemaObjects can be added even if they break the consistency

    isStrict

    public boolean isStrict()
    Tells if the Registries is strict.

    Returns:
    True if SchemaObjects cannot be added if they break the consistency

    setRelaxed

    public void setRelaxed()
    Change the Registries to a relaxed mode, where invalid SchemaObjects can be registered.


    setStrict

    public void setStrict()
    Change the Registries to a strict mode, where invalid SchemaObjects cannot be registered.


    isDisabledAccepted

    public boolean isDisabledAccepted()
    Tells if the Registries accept disabled elements.

    Returns:
    True if disabled SchemaObjects can be added

    getReferencing

    public java.util.Set<SchemaObjectWrapper> getReferencing(SchemaObject schemaObject)
    Check that we can remove a given SchemaObject without breaking some of its references. We will return the list of refereing objects.

    Parameters:
    schemaObject - The SchemaObject to remove
    Returns:
    The list of SchemaObjects referencing the SchemaObjetc we want to remove

    setDisabledAccepted

    public void setDisabledAccepted(boolean disabledAccepted)
    Change the Registries behavior regarding disabled SchemaObject element.

    Parameters:
    acceptDisabled - If false, then the Registries won't accept disabled SchemaObject or enabled SchemaObject from disabled schema

    clear

    public void clear()
               throws LdapException
    Clear the registries from all its elements

    Throws:
    LdapException - If something goes wrong

    toString

    public java.lang.String toString()
    Overrides:
    toString in class java.lang.Object
    See Also:
    Object.toString()


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