Interface SchemaManager

  • All Known Implementing Classes:
    DefaultSchemaManager

    public interface SchemaManager
    A class used to manage access to the Schemas and Registries. It's associated with a SchemaLoader, in charge of loading the schemas from the disk.
    Author:
    Apache Directory Project
    • Field Detail

      • STRICT

        static final boolean STRICT
        Two flags for RELAXED and STRICT, this is STRICT
        See Also:
        Constant Field Values
      • RELAXED

        static final boolean RELAXED
        Two flags for RELAXED and STRICT, this is RELAXED
        See Also:
        Constant Field Values
    • Method Detail

      • load

        boolean load​(Schema... schemas)
              throws LdapException
        Load some Schemas into the registries. The Registries is checked after the schemas have been loaded, and if there is an error, the method returns false and the registries is kept intact.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas to load
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • load

        boolean load​(String... schemas)
              throws LdapException
        Load some Schemas into the registries. The Registries is checked after the schemas have been loaded, and if there is an error, the method returns false and the registries is kept intact.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas' name to load
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • loadWithDeps

        boolean loadWithDeps​(Schema... schemas)
                      throws LdapException
        Load some Schemas into the registries, and loads all of the schemas they depend on. The Registries is checked after the schemas have been loaded, and if there is an error, the method returns false and the registries is kept intact.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas to load
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • loadWithDeps

        boolean loadWithDeps​(String... schemas)
                      throws LdapException
        Load some Schemas into the registries, and loads all of the schemas they depend on. The Registries is checked after the schemas have been loaded, and if there is an error, the method returns false and the registries is kept intact.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas' name to load
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • loadRelaxed

        boolean loadRelaxed​(Schema... schemas)
                     throws LdapException
        Load Schemas into the registries, even if there are some errors in the schemas. The Registries is checked after the schemas have been loaded. Even if we have errors, the registries will be updated.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas to load, if enabled
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadRelaxed

        boolean loadRelaxed​(String... schemas)
                     throws LdapException
        Load Schemas into the registries, even if there are some errors in the schemas. The Registries is checked after the schemas have been loaded. Even if we have errors, the registries will be updated.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas' name to load, if enabled
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • loadWithDepsRelaxed

        boolean loadWithDepsRelaxed​(Schema... schemas)
                             throws LdapException
        Load some Schemas into the registries, and loads all of the schemas they depend on. The Registries is checked after the schemas have been loaded. Even if we have errors, the registries will be updated.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadWithDepsRelaxed

        boolean loadWithDepsRelaxed​(String... schemas)
                             throws LdapException
        Load some Schemas into the registries, and loads all of the schemas they depend on. The Registries is checked after the schemas have been loaded. Even if we have errors, the registries will be updated.
        The Schemas must be enabled, and only enabled SchemaObject will be loaded.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - the Schemas' name to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadDisabled

        boolean loadDisabled​(Schema... schemas)
                      throws LdapException
        Load Schemas into the Registries, even if they are disabled. The disabled SchemaObject from an enabled schema will also be loaded. The Registries will be checked after the schemas have been loaded. Even if we have errors, the Registries will be updated.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - The Schemas to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadDisabled

        boolean loadDisabled​(String... schemas)
                      throws LdapException
        Load Schemas into the Registries, even if they are disabled. The disabled SchemaObject from an enabled schema will also be loaded. The Registries will be checked after the schemas have been loaded. Even if we have errors, the Registries will be updated.
        If any error was met, the getErrors() method will contain them
        Parameters:
        schemas - The Schemas' name to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadAllEnabled

        boolean loadAllEnabled()
                        throws LdapException
        Load all the enabled schema into the Registries. The Registries is strict, any inconsistent schema will be rejected.
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadAllEnabledRelaxed

        boolean loadAllEnabledRelaxed()
                               throws LdapException
        Load all the enabled schema into the Registries. The Registries is relaxed, even inconsistent schema will be loaded.
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • unload

        boolean unload​(Schema... schemas)
                throws LdapException
        Unload the given set of Schemas
        Parameters:
        schemas - The list of Schema to unload
        Returns:
        True if all the schemas have been unloaded
        Throws:
        LdapException - If something went wrong
      • unload

        boolean unload​(String... schemas)
                throws LdapException
        Unload the given set of Schemas
        Parameters:
        schemas - The list of Schema to unload
        Returns:
        True if all the schemas have been unloaded
        Throws:
        LdapException - If something went wrong
      • enable

        boolean enable​(Schema... schemas)
                throws LdapException
        Enables a set of Schemas, and returns true if all the schema have been enabled, with all the dependent schemas, and if the registries is still consistent. If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schemas to enable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • enable

        boolean enable​(String... schemas)
                throws LdapException
        Enables a set of Schemas, and returns true if all the schema have been enabled, with all the dependent schemas, and if the registries is still consistent. If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schema name to enable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • enableRelaxed

        boolean enableRelaxed​(Schema... schemas)
        Enables a set of Schemas, and returns true if all the schema have been enabled, with all the dependent schemas. No check is done, the Registries might become inconsistent after this operation.
        Parameters:
        schemas - The list of schemas to enable
        Returns:
        true if all the schemas have been enabled
      • enableRelaxed

        boolean enableRelaxed​(String... schemas)
        Enables a set of Schemas, and returns true if all the schema have been enabled, with all the dependent schemas. No check is done, the Registries might become inconsistent after this operation.
        Parameters:
        schemas - The list of schema names to enable
        Returns:
        true if all the schemas have been enabled
      • getEnabled

        Collection<Schema> getEnabled()
        Returns:
        the list of all the enabled schema
      • getAllSchemas

        Collection<Schema> getAllSchemas()
        Returns:
        the list of all schemas
      • isEnabled

        boolean isEnabled​(String schemaName)
        Tells if the given Schema is enabled
        Parameters:
        schemaName - The schema name
        Returns:
        true if the schema is enabled
      • isEnabled

        boolean isEnabled​(Schema schema)
        Tells if the given Schema is enabled
        Parameters:
        schema - The schema
        Returns:
        true if the schema is enabled
      • disable

        boolean disable​(Schema... schemas)
                 throws LdapException
        Disables a set of Schemas, and returns true if all the schema have been disabled, with all the dependent schemas, and if the registries is still consistent. If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schemas to disable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • disable

        boolean disable​(String... schemas)
                 throws LdapException
        Disables a set of Schemas, and returns true if all the schema have been disabled, with all the dependent schemas, and if the registries is still consistent. If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schema names to disable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • disabledRelaxed

        boolean disabledRelaxed​(Schema... schemas)
        Disables a set of Schemas, and returns true if all the schema have been disabled, with all the dependent schemas. The Registries is not checked and can be inconsistent after this operation If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schemas to disable
        Returns:
        true if all the schemas have been disabled
      • disabledRelaxed

        boolean disabledRelaxed​(String... schemas)
        Disables a set of Schemas, and returns true if all the schema have been disabled, with all the dependent schemas. The Registries is not checked and can be inconsistent after this operation If the modification is ok, the Registries will be updated.
        Parameters:
        schemas - The list of schema names to disable
        Returns:
        true if all the schemas have been disabled
      • getDisabled

        List<Schema> getDisabled()
        Returns:
        the list of all the disabled schema
      • isDisabled

        boolean isDisabled​(String schemaName)
        Tells if the given Schema is disabled
        Parameters:
        schemaName - The schema name
        Returns:
        true if the schema is disabled
      • isDisabled

        boolean isDisabled​(Schema schema)
        Tells if the given Schema is disabled
        Parameters:
        schema - The schema
        Returns:
        true if the schema is disabled
      • isRelaxed

        boolean isRelaxed()
        Tells if the SchemaManager is permissive or if it must be checked against inconsistencies.
        Returns:
        True if SchemaObjects can be added even if they break the consistency
      • setRelaxed

        void setRelaxed()
        Set the SchemaManager to a RELAXED mode
      • isStrict

        boolean isStrict()
        Tells if the SchemaManager is strict.
        Returns:
        True if SchemaObjects cannot be added if they break the consistency
      • setStrict

        void setStrict()
        Set the SchemaManager to a STRICT mode
      • verify

        boolean verify​(Schema... schemas)
                throws LdapException
        Check that the Schemas are consistent regarding the current Registries.
        Parameters:
        schemas - The schemas to check
        Returns:
        true if the schemas can be loaded in the registries
        Throws:
        LdapException - if something went wrong
      • verify

        boolean verify​(String... schemas)
                throws LdapException
        Check that the Schemas are consistent regarding the current Registries.
        Parameters:
        schemas - The schema names to check
        Returns:
        true if the schemas can be loaded in the registries
        Throws:
        LdapException - if something went wrong
      • getRegistries

        Registries getRegistries()
        Returns:
        The Registries
      • lookupAttributeTypeRegistry

        AttributeType lookupAttributeTypeRegistry​(String oid)
                                           throws LdapException
        Lookup for an AttributeType in the AttributeType registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found AttributeType
        Throws:
        LdapException - if the OID is not found in the AttributeType registry
      • getAttributeType

        AttributeType getAttributeType​(String oid)
        Get an AttributeType in the AttributeType registry. This method won't throw an exception if the AttributeTyp is not found, it will just return null.
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found AttributeType, or null if not found
      • lookupComparatorRegistry

        LdapComparator<?> lookupComparatorRegistry​(String oid)
                                            throws LdapException
        Lookup for a Comparator in the Comparator registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found Comparator
        Throws:
        LdapException - if the OID is not found in the Comparator registry
      • lookupMatchingRuleRegistry

        MatchingRule lookupMatchingRuleRegistry​(String oid)
                                         throws LdapException
        Lookup for a MatchingRule in the MatchingRule registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found MatchingRule
        Throws:
        LdapException - if the OID is not found in the MatchingRule registry
      • lookupNormalizerRegistry

        Normalizer lookupNormalizerRegistry​(String oid)
                                     throws LdapException
        Lookup for a Normalizer in the Normalizer registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found Normalizer
        Throws:
        LdapException - if the OID is not found in the Normalizer registry
      • lookupObjectClassRegistry

        ObjectClass lookupObjectClassRegistry​(String oid)
                                       throws LdapException
        Lookup for a ObjectClass in the ObjectClass registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found ObjectClass
        Throws:
        LdapException - if the OID is not found in the ObjectClass registry
      • lookupLdapSyntaxRegistry

        LdapSyntax lookupLdapSyntaxRegistry​(String oid)
                                     throws LdapException
        Lookup for an LdapSyntax in the LdapSyntax registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found LdapSyntax
        Throws:
        LdapException - if the OID is not found in the LdapSyntax registry
      • lookupSyntaxCheckerRegistry

        SyntaxChecker lookupSyntaxCheckerRegistry​(String oid)
                                           throws LdapException
        Lookup for a SyntaxChecker in the SyntaxChecker registry
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found SyntaxChecker
        Throws:
        LdapException - if the OID is not found in the SyntaxChecker registry
      • getAttributeTypeRegistry

        AttributeTypeRegistry getAttributeTypeRegistry()
        Get an immutable reference on the AttributeType registry
        Returns:
        A reference to the AttributeType registry.
      • getComparatorRegistry

        ComparatorRegistry getComparatorRegistry()
        Get an immutable reference on the Comparator registry
        Returns:
        A reference to the Comparator registry.
      • getDITContentRuleRegistry

        DitContentRuleRegistry getDITContentRuleRegistry()
        Get an immutable reference on the DitContentRule registry
        Returns:
        A reference to the DitContentRule registry.
      • getDITStructureRuleRegistry

        DitStructureRuleRegistry getDITStructureRuleRegistry()
        Get an immutable reference on the DitStructureRule registry
        Returns:
        A reference to the DitStructureRule registry.
      • getMatchingRuleRegistry

        MatchingRuleRegistry getMatchingRuleRegistry()
        Get an immutable reference on the MatchingRule registry
        Returns:
        A reference to the MatchingRule registry.
      • getMatchingRuleUseRegistry

        MatchingRuleUseRegistry getMatchingRuleUseRegistry()
        Get an immutable reference on the MatchingRuleUse registry
        Returns:
        A reference to the MatchingRuleUse registry.
      • getNormalizerRegistry

        NormalizerRegistry getNormalizerRegistry()
        Get an immutable reference on the Normalizer registry
        Returns:
        A reference to the Normalizer registry.
      • getNameFormRegistry

        NameFormRegistry getNameFormRegistry()
        Get an immutable reference on the NameForm registry
        Returns:
        A reference to the NameForm registry.
      • getObjectClassRegistry

        ObjectClassRegistry getObjectClassRegistry()
        Get an immutable reference on the ObjectClass registry
        Returns:
        A reference to the ObjectClass registry.
      • getLdapSyntaxRegistry

        LdapSyntaxRegistry getLdapSyntaxRegistry()
        Get an immutable reference on the LdapSyntax registry
        Returns:
        A reference to the LdapSyntax registry.
      • getSyntaxCheckerRegistry

        SyntaxCheckerRegistry getSyntaxCheckerRegistry()
        Get an immutable reference on the SyntaxChecker registry
        Returns:
        A reference to the SyntaxChecker registry.
      • getNormalizerMapping

        Map<String,​OidNormalizer> getNormalizerMapping()
        Get an immutable reference on the Normalizer mapping
        Returns:
        A reference to the Normalizer mapping
      • setRegistries

        void setRegistries​(Registries registries)
        Associate a new Registries to the SchemaManager
        Parameters:
        registries - The new Registries
      • getErrors

        List<Throwable> getErrors()
        Returns:
        The errors obtained when checking the registries
      • getNamingContext

        Dn getNamingContext()
        Returns:
        the namingContext
      • initialize

        void initialize()
                 throws LdapException
        Initializes the SchemaService
        Throws:
        LdapException - If the initialization fails
      • add

        boolean add​(SchemaObject schemaObject)
             throws LdapException
        Registers a new SchemaObject. The registries will be updated only if it's consistent after this addition, if the SchemaManager is in Strict mode. If something went wrong during this operation, the SchemaManager.getErrors() will give the list of generated errors.
        Parameters:
        schemaObject - the SchemaObject to register
        Returns:
        true if the addition has been made, false if there were some errors
        Throws:
        LdapException - if the SchemaObject is already registered or the registration operation is not supported
      • delete

        boolean delete​(SchemaObject schemaObject)
                throws LdapException
        Unregisters a new SchemaObject. The registries will be updated only if it's consistent after this deletion, if the SchemaManager is in Strict mode. If something went wrong during this operation, the SchemaManager.getErrors() will give the list of generated errors.
        Parameters:
        schemaObject - the SchemaObject to unregister
        Returns:
        true if the deletion has been made, false if there were some errors
        Throws:
        LdapException - if the SchemaObject is not registered or the deletion operation is not supported
      • unregisterAttributeType

        SchemaObject unregisterAttributeType​(String attributeTypeOid)
                                      throws LdapException
        Removes the registered attributeType from the attributeTypeRegistry
        Parameters:
        attributeTypeOid - the attributeType OID to unregister
        Returns:
        the unregistred AtttributeType
        Throws:
        LdapException - if the attributeType is invalid
      • unregisterComparator

        SchemaObject unregisterComparator​(String comparatorOid)
                                   throws LdapException
        Removes the registered Comparator from the ComparatorRegistry
        Parameters:
        comparatorOid - the Comparator OID to unregister
        Returns:
        the unregistred Comparator
        Throws:
        LdapException - if the Comparator is invalid
      • unregisterDitControlRule

        SchemaObject unregisterDitControlRule​(String ditControlRuleOid)
                                       throws LdapException
        Removes the registered DitControlRule from the DitControlRuleRegistry
        Parameters:
        ditControlRuleOid - the DitControlRule OID to unregister
        Returns:
        the unregistred DitControlRule
        Throws:
        LdapException - if the DitControlRule is invalid
      • unregisterDitStructureRule

        SchemaObject unregisterDitStructureRule​(String ditStructureRuleOid)
                                         throws LdapException
        Removes the registered DitStructureRule from the DitStructureRuleRegistry
        Parameters:
        ditStructureRuleOid - the DitStructureRule OID to unregister
        Returns:
        the unregistred DitStructureRule
        Throws:
        LdapException - if the DitStructureRule is invalid
      • unregisterMatchingRule

        SchemaObject unregisterMatchingRule​(String matchingRuleOid)
                                     throws LdapException
        Removes the registered MatchingRule from the MatchingRuleRegistry
        Parameters:
        matchingRuleOid - the MatchingRuleRule OID to unregister
        Returns:
        the unregistred MatchingRule
        Throws:
        LdapException - if the MatchingRule is invalid
      • unregisterMatchingRuleUse

        SchemaObject unregisterMatchingRuleUse​(String matchingRuleUseOid)
                                        throws LdapException
        Removes the registered MatchingRuleUse from the MatchingRuleUseRegistry
        Parameters:
        matchingRuleUseOid - the MatchingRuleUse OID to unregister
        Returns:
        the unregistred MatchingRuleUse
        Throws:
        LdapException - if the MatchingRuleUse is invalid
      • unregisterNameForm

        SchemaObject unregisterNameForm​(String nameFormOid)
                                 throws LdapException
        Removes the registered NameForm from the NameFormRegistry
        Parameters:
        nameFormOid - the NameForm OID to unregister
        Returns:
        the unregistred NameForm
        Throws:
        LdapException - if the NameForm is invalid
      • unregisterNormalizer

        SchemaObject unregisterNormalizer​(String normalizerOid)
                                   throws LdapException
        Removes the registered Normalizer from the NormalizerRegistry
        Parameters:
        normalizerOid - the Normalizer OID to unregister
        Returns:
        the unregistred Normalizer
        Throws:
        LdapException - if the Normalizer is invalid
      • unregisterObjectClass

        SchemaObject unregisterObjectClass​(String objectClassOid)
                                    throws LdapException
        Removes the registered ObjectClass from the ObjectClassRegistry
        Parameters:
        objectClassOid - the ObjectClass OID to unregister
        Returns:
        the unregistred ObjectClass
        Throws:
        LdapException - if the ObjectClass is invalid
      • unregisterLdapSyntax

        SchemaObject unregisterLdapSyntax​(String ldapSyntaxOid)
                                   throws LdapException
        Removes the registered LdapSyntax from the LdapSyntaxRegistry
        Parameters:
        ldapSyntaxOid - the LdapSyntax OID to unregister
        Returns:
        the unregistred Syntax
        Throws:
        LdapException - if the LdapSyntax is invalid
      • unregisterSyntaxChecker

        SchemaObject unregisterSyntaxChecker​(String syntaxCheckerOid)
                                      throws LdapException
        Removes the registered SyntaxChecker from the SyntaxCheckerRegistry
        Parameters:
        syntaxCheckerOid - the SyntaxChecker OID to unregister
        Returns:
        the unregistred SyntaxChecker
        Throws:
        LdapException - if the SyntaxChecker is invalid
      • getGlobalOidRegistry

        OidRegistry getGlobalOidRegistry()
        Returns a reference to the global OidRegistry
        Returns:
        The the global OidRegistry
      • getLoadedSchema

        Schema getLoadedSchema​(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

        boolean isSchemaLoaded​(String schemaName)
        Tells if the specific schema is loaded
        Parameters:
        schemaName - The schema we want to check
        Returns:
        true if the schema is laoded
      • listDependentSchemaNames

        Set<String> listDependentSchemaNames​(String schemaName)
        Get the list of Schema names which has the given schema name as a dependence
        Parameters:
        schemaName - The Schema name for which we want to get the list of dependent schemas
        Returns:
        The list of dependent schemas