Class DefaultSchemaManager

    • Constructor Detail

      • DefaultSchemaManager

        public DefaultSchemaManager()
        Creates a new instance of DefaultSchemaManager with LDIF based SchemaLoader, Strict schema validation
      • DefaultSchemaManager

        public DefaultSchemaManager​(Collection<Schema> schemas)
        Creates a new instance of DefaultSchemaManager with the default schema schemaLoader Strict schema validation
        Parameters:
        schemas - The list of schema to load
      • DefaultSchemaManager

        public DefaultSchemaManager​(SchemaLoader schemaLoader)
        Creates a new instance of DefaultSchemaManager with the given schemaLoader Schema validation strictness (i.e. relaxed/strict) controlled by the given schemaLoader
        Parameters:
        schemaLoader - The schemaLoader containing the schemas to load
      • DefaultSchemaManager

        public DefaultSchemaManager​(boolean relaxed,
                                    Collection<Schema> schemas)
        Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
        Parameters:
        relaxed - If the schema manager should be relaxed or not
        schemas - The list of schema to load
    • Method Detail

      • disable

        public 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.
        Specified by:
        disable in interface SchemaManager
        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

        public boolean disable​(String... schemaNames)
                        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.
        Specified by:
        disable in interface SchemaManager
        Parameters:
        schemaNames - The list of schema names to disable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • disabledRelaxed

        public 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.
        Specified by:
        disabledRelaxed in interface SchemaManager
        Parameters:
        schemas - The list of schemas to disable
        Returns:
        true if all the schemas have been disabled
      • disabledRelaxed

        public 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.
        Specified by:
        disabledRelaxed in interface SchemaManager
        Parameters:
        schemas - The list of schema names to disable
        Returns:
        true if all the schemas have been disabled
      • enable

        public 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.
        Specified by:
        enable in interface SchemaManager
        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

        public boolean enable​(String... schemaNames)
                       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.
        Specified by:
        enable in interface SchemaManager
        Parameters:
        schemaNames - The list of schema name to enable
        Returns:
        true if the Registries is still consistent, false otherwise.
        Throws:
        LdapException - If something went wrong
      • enableRelaxed

        public 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.
        Specified by:
        enableRelaxed in interface SchemaManager
        Parameters:
        schemas - The list of schemas to enable
        Returns:
        true if all the schemas have been enabled
      • enableRelaxed

        public 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.
        Specified by:
        enableRelaxed in interface SchemaManager
        Parameters:
        schemas - The list of schema names to enable
        Returns:
        true if all the schemas have been enabled
      • isDisabledAccepted

        public boolean isDisabledAccepted()
        Currently not implemented.
        Returns:
        Always FALSE
      • load

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        load in interface SchemaManager
        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

        public boolean load​(String... schemaNames)
                     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 SchemaManager.getErrors() method will contain them
        Specified by:
        load in interface SchemaManager
        Parameters:
        schemaNames - the Schemas' name to load
        Returns:
        true if the schemas have been loaded and the registries is consistent
        Throws:
        LdapException - If something went wrong
      • addSchemaObject

        protected SchemaObject addSchemaObject​(Registries registries,
                                               SchemaObject schemaObject,
                                               Schema schema)
                                        throws LdapException
        Add the schemaObject into the registries.
        Parameters:
        registries - The Registries
        schemaObject - The SchemaObject containing the SchemaObject description
        schema - The associated schema
        Returns:
        the created schemaObject instance
        Throws:
        LdapException - If the registering failed
      • loadAllEnabled

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

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

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadDisabled in interface SchemaManager
        Parameters:
        schemas - The Schemas to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadDisabled

        public boolean loadDisabled​(String... schemaNames)
                             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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadDisabled in interface SchemaManager
        Parameters:
        schemaNames - The Schemas' name to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadRelaxed

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadRelaxed in interface SchemaManager
        Parameters:
        schemas - the Schemas to load, if enabled
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadRelaxed

        public boolean loadRelaxed​(String... schemaNames)
                            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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadRelaxed in interface SchemaManager
        Parameters:
        schemaNames - 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
      • loadWithDeps

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadWithDeps in interface SchemaManager
        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

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadWithDeps in interface SchemaManager
        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
      • loadWithDepsRelaxed

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadWithDepsRelaxed in interface SchemaManager
        Parameters:
        schemas - the Schemas to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • loadWithDepsRelaxed

        public 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 SchemaManager.getErrors() method will contain them
        Specified by:
        loadWithDepsRelaxed in interface SchemaManager
        Parameters:
        schemas - the Schemas' name to load
        Returns:
        true if the schemas have been loaded
        Throws:
        LdapException - If something went wrong
      • setRegistries

        public void setRegistries​(Registries registries)
        Associate a new Registries to the SchemaManager
        Specified by:
        setRegistries in interface SchemaManager
        Parameters:
        registries - The new Registries
      • unload

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

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

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

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

        public 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.
        Specified by:
        getAttributeType in interface SchemaManager
        Parameters:
        oid - the OID we are looking for
        Returns:
        The found AttributeType, or null if not found
      • add

        public 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.
        Specified by:
        add in interface SchemaManager
        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

        public 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.
        Specified by:
        delete in interface SchemaManager
        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
      • getLoadedSchema

        public Schema getLoadedSchema​(String schemaName)
        Gets a schema that has been loaded into these Registries.
        Specified by:
        getLoadedSchema in interface SchemaManager
        Parameters:
        schemaName - the name of the schema to lookup
        Returns:
        the loaded Schema if one corresponding to the name exists
      • isSchemaLoaded

        public boolean isSchemaLoaded​(String schemaName)
        Tells if the specific schema is loaded
        Specified by:
        isSchemaLoaded in interface SchemaManager
        Parameters:
        schemaName - The schema we want to check
        Returns:
        true if the schema is laoded
      • unregisterAttributeType

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

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

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

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

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

        public SchemaObject unregisterMatchingRuleUse​(String matchingRuleUseOid)
                                               throws LdapException
        Removes the registered MatchingRuleUse from the MatchingRuleUseRegistry
        Specified by:
        unregisterMatchingRuleUse in interface SchemaManager
        Parameters:
        matchingRuleUseOid - the MatchingRuleUse OID to unregister
        Returns:
        the unregistred MatchingRuleUse
        Throws:
        LdapException - if the MatchingRuleUse is invalid
      • unregisterNormalizer

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

        public SchemaObject unregisterObjectClass​(String objectClassOid)
                                           throws LdapException
        Removes the registered ObjectClass from the ObjectClassRegistry
        Specified by:
        unregisterObjectClass in interface SchemaManager
        Parameters:
        objectClassOid - the ObjectClass OID to unregister
        Returns:
        the unregistred ObjectClass
        Throws:
        LdapException - if the ObjectClass is invalid
      • unregisterSyntaxChecker

        public SchemaObject unregisterSyntaxChecker​(String syntaxCheckerOid)
                                             throws LdapException
        Removes the registered SyntaxChecker from the SyntaxCheckerRegistry
        Specified by:
        unregisterSyntaxChecker in interface SchemaManager
        Parameters:
        syntaxCheckerOid - the SyntaxChecker OID to unregister
        Returns:
        the unregistred SyntaxChecker
        Throws:
        LdapException - if the SyntaxChecker is invalid
      • isRelaxed

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

        public boolean isStrict()
        Tells if the SchemaManager is strict.
        Specified by:
        isStrict in interface SchemaManager
        Returns:
        True if SchemaObjects cannot be added if they break the consistency
      • listDependentSchemaNames

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

        public void setRelaxed()
        Change the SchemaManager to a relaxed mode, where invalid SchemaObjects can be registered.
        Specified by:
        setRelaxed in interface SchemaManager
      • setStrict

        public void setStrict()
        Change the SchemaManager to a strict mode, where invalid SchemaObjects cannot be registered.
        Specified by:
        setStrict in interface SchemaManager
      • isDisabled

        public boolean isDisabled​(String schemaName)
        Tells if the given Schema is disabled
        Specified by:
        isDisabled in interface SchemaManager
        Parameters:
        schemaName - The schema name
        Returns:
        true if the schema is disabled
      • isDisabled

        public boolean isDisabled​(Schema schema)
        Tells if the given Schema is disabled
        Specified by:
        isDisabled in interface SchemaManager
        Parameters:
        schema - The schema
        Returns:
        true if the schema is disabled
      • isEnabled

        public boolean isEnabled​(String schemaName)
        Tells if the given Schema is enabled
        Specified by:
        isEnabled in interface SchemaManager
        Parameters:
        schemaName - The schema name
        Returns:
        true if the schema is enabled
      • isEnabled

        public boolean isEnabled​(Schema schema)
        Tells if the given Schema is enabled
        Specified by:
        isEnabled in interface SchemaManager
        Parameters:
        schema - The schema
        Returns:
        true if the schema is enabled