Class SchemaBackend

    • Constructor Detail

      • SchemaBackend

        public SchemaBackend()
        Creates a new backend with the provided information. All backend implementations must implement a default constructor that use super() to invoke this constructor.
    • Method Detail

      • configureBackend

        public void configureBackend​(SchemaBackendCfg cfg,
                                     ServerContext serverContext)
                              throws ConfigException
        Description copied from class: Backend
        Configure this backend based on the information in the provided configuration. When the method returns, the backend will have been configured (ready to be opened) but still unable to process operations.
        Specified by:
        configureBackend in class Backend<SchemaBackendCfg>
        Parameters:
        cfg - The configuration of this backend.
        serverContext - The server context for this instance
        Throws:
        ConfigException - If there is an error in the configuration.
      • closeBackend

        public void closeBackend()
        Description copied from class: LocalBackend
        Performs any necessary work to finally close this backend, particularly closing any underlying databases or connections and deregistering any suffixes that it manages with the Directory Server.

        It will be called as final step of finalizeBackend(), so subclasses might override it.

        Overrides:
        closeBackend in class LocalBackend<SchemaBackendCfg>
      • getBaseDNs

        public Set<DN> getBaseDNs()
        Description copied from class: Backend
        Retrieves the set of base-level DNs that may be used within this backend.
        Specified by:
        getBaseDNs in class Backend<SchemaBackendCfg>
        Returns:
        The set of base-level DNs that may be used within this backend.
      • getEntryCount

        public long getEntryCount()
        Description copied from class: LocalBackend
        Retrieves the total number of entries contained in this backend, if that information is available.
        Specified by:
        getEntryCount in class LocalBackend<SchemaBackendCfg>
        Returns:
        The total number of entries contained in this backend, or -1 if that information is not available.
      • isIndexed

        public boolean isIndexed​(AttributeType attributeType,
                                 IndexType indexType)
        Description copied from class: LocalBackend
        Indicates whether search operations which target the specified attribute in the indicated manner would be considered indexed in this backend. The operation should be considered indexed only if the specified operation can be completed efficiently within the backend.

        Note that this method should return a general result that covers all values of the specified attribute. If a the specified attribute is indexed in the indicated manner but some particular values may still be treated as unindexed (e.g., if the number of entries with that attribute value exceeds some threshold), then this method should still return true for the specified attribute and index type.
        Specified by:
        isIndexed in class LocalBackend<SchemaBackendCfg>
        Parameters:
        attributeType - The attribute type for which to make the determination.
        indexType - The index type for which to make the determination.
        Returns:
        true if search operations targeting the specified attribute in the indicated manner should be considered indexed, or false if not.
      • hasSubordinates

        public ConditionResult hasSubordinates​(DN entryDN)
                                        throws DirectoryException
        Description copied from class: LocalBackend
        Indicates whether the requested entry has any subordinates.
        Specified by:
        hasSubordinates in class LocalBackend<SchemaBackendCfg>
        Parameters:
        entryDN - The distinguished name of the entry.
        Returns:
        ConditionResult.TRUE if the entry has one or more subordinates or ConditionResult.FALSE otherwise or ConditionResult.UNDEFINED if it can not be determined.
        Throws:
        DirectoryException - If a problem occurs while trying to retrieve the entry.
      • getNumberOfEntriesInBaseDN

        public long getNumberOfEntriesInBaseDN​(DN baseDN)
                                        throws DirectoryException
        Description copied from class: LocalBackend
        Retrieves the number of entries for the specified base DN including all entries from the requested entry to the lowest level in the tree.
        Specified by:
        getNumberOfEntriesInBaseDN in class LocalBackend<SchemaBackendCfg>
        Parameters:
        baseDN - The base distinguished name.
        Returns:
        The number of subordinate entries including the base dn.
        Throws:
        DirectoryException - If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the entry.
      • getNumberOfChildren

        public long getNumberOfChildren​(DN parentDN)
                                 throws DirectoryException
        Description copied from class: LocalBackend
        Retrieves the number of subordinates immediately below the requested entry.
        Specified by:
        getNumberOfChildren in class LocalBackend<SchemaBackendCfg>
        Parameters:
        parentDN - The distinguished name of the parent.
        Returns:
        The number of subordinate entries for the requested entry.
        Throws:
        DirectoryException - If baseDN isn't a base dn managed by this backend or if a problem occurs while trying to retrieve the entry.
      • getEntry

        public Entry getEntry​(DN entryDN)
                       throws DirectoryException
        Description copied from class: LocalBackend
        Retrieves the requested entry from this backend. The caller is not required to hold any locks on the specified DN.
        Specified by:
        getEntry in class LocalBackend<SchemaBackendCfg>
        Parameters:
        entryDN - The distinguished name of the entry to retrieve.
        Returns:
        The requested entry, or null if the entry does not exist.
        Throws:
        DirectoryException - If a problem occurs while trying to retrieve the entry.
      • getSchemaEntry

        public Entry getSchemaEntry​(DN entryDN)
        Generates and returns a schema entry for the Directory Server.
        Parameters:
        entryDN - The DN to use for the generated entry.
        Returns:
        The schema entry that was generated.
      • entryExists

        public boolean entryExists​(DN entryDN)
                            throws DirectoryException
        Description copied from class: LocalBackend
        Indicates whether an entry with the specified DN exists in the backend. The default implementation calls getEntry, but backend implementations may override this with a more efficient version. The caller is not required to hold any locks on the specified DN.
        Overrides:
        entryExists in class LocalBackend<SchemaBackendCfg>
        Parameters:
        entryDN - The DN of the entry for which to determine existence.
        Returns:
        true if the specified entry exists in this backend, or false if it does not.
        Throws:
        DirectoryException - If a problem occurs while trying to make the determination.
      • addEntry

        public void addEntry​(Entry entry,
                             AddOperation addOperation)
                      throws DirectoryException
        Description copied from class: LocalBackend
        Adds the provided entry to this backend. This method must ensure that the entry is appropriate for the backend and that no entry already exists with the same DN. The caller must hold a write lock on the DN of the provided entry.
        Specified by:
        addEntry in class LocalBackend<SchemaBackendCfg>
        Parameters:
        entry - The entry to add to this backend.
        addOperation - The add operation with which the new entry is associated. This may be null for adds performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to add the entry.
      • deleteEntry

        public void deleteEntry​(DN entryDN,
                                DeleteOperation deleteOperation)
                         throws DirectoryException
        Description copied from class: LocalBackend
        Removes the specified entry from this backend. This method must ensure that the entry exists and that it does not have any subordinate entries (unless the backend supports a subtree delete operation and the client included the appropriate information in the request). The caller must hold a write lock on the provided entry DN.
        Specified by:
        deleteEntry in class LocalBackend<SchemaBackendCfg>
        Parameters:
        entryDN - The DN of the entry to remove from this backend.
        deleteOperation - The delete operation with which this action is associated. This may be null for deletes performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to remove the entry.
      • replaceEntry

        public void replaceEntry​(Entry oldEntry,
                                 Entry newEntry,
                                 ModifyOperation modifyOperation)
                          throws DirectoryException
        Description copied from class: LocalBackend
        Replaces the specified entry with the provided entry in this backend. The backend must ensure that an entry already exists with the same DN as the provided entry. The caller must hold a write lock on the DN of the provided entry.
        Specified by:
        replaceEntry in class LocalBackend<SchemaBackendCfg>
        Parameters:
        oldEntry - The original entry that is being replaced.
        newEntry - The new entry to use in place of the existing entry with the same DN.
        modifyOperation - The modify operation with which this action is associated. This may be null for modifications performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to replace the entry.
      • renameEntry

        public void renameEntry​(DN currentDN,
                                Entry entry,
                                ModifyDNOperation modifyDNOperation)
                         throws DirectoryException
        Description copied from class: LocalBackend
        Moves and/or renames the provided entry in this backend, altering any subordinate entries as necessary. This must ensure that an entry already exists with the provided current DN, and that no entry exists with the target DN of the provided entry. The caller must hold write locks on both the current DN and the new DN for the entry.
        Specified by:
        renameEntry in class LocalBackend<SchemaBackendCfg>
        Parameters:
        currentDN - The current DN of the entry to be moved/renamed.
        entry - The new content to use for the entry.
        modifyDNOperation - The modify DN operation with which this action is associated. This may be null for modify DN operations performed internally.
        Throws:
        DirectoryException - If a problem occurs while trying to perform the rename.
      • search

        public void search​(SearchOperation searchOperation)
                    throws DirectoryException
        Description copied from class: LocalBackend
        Processes the specified search in this backend. Matching entries should be provided back to the core server using the SearchOperation.returnEntry method. The caller is not required to have any locks when calling this operation.
        Specified by:
        search in class LocalBackend<SchemaBackendCfg>
        Parameters:
        searchOperation - The search operation to be processed.
        Throws:
        DirectoryException - If a problem occurs while processing the search.
      • getSupportedControls

        public Set<String> getSupportedControls()
        Description copied from class: Backend
        Retrieves the OIDs of the controls that may be supported by this backend.
        Specified by:
        getSupportedControls in class Backend<SchemaBackendCfg>
        Returns:
        The OIDs of the controls that may be supported by this backend.
      • getSupportedFeatures

        public Set<String> getSupportedFeatures()
        Description copied from class: Backend
        Retrieves the OIDs of the features that may be supported by this backend.
        Specified by:
        getSupportedFeatures in class Backend<SchemaBackendCfg>
        Returns:
        The OIDs of the features that may be supported by this backend.
      • supports

        public boolean supports​(LocalBackend.BackendOperation backendOperation)
        Description copied from class: LocalBackend
        Indicates whether this backend supports the provided backend operation.
        Specified by:
        supports in class LocalBackend<SchemaBackendCfg>
        Parameters:
        backendOperation - the backend operation
        Returns:
        true if this backend supports the provided backend operation, false otherwise.
      • removeBackup

        public void removeBackup​(BackupDirectory backupDirectory,
                                 String backupID)
                          throws DirectoryException
        Description copied from class: LocalBackend
        Removes the specified backup if it is possible to do so.
        Specified by:
        removeBackup in class LocalBackend<SchemaBackendCfg>
        Parameters:
        backupDirectory - The backup directory structure with which the specified backup is associated.
        backupID - The backup ID for the backup to be removed.
        Throws:
        DirectoryException - If it is not possible to remove the specified backup for some reason (e.g., no such backup exists or there are other backups that are dependent upon it).
      • isConfigurationChangeAcceptable

        public boolean isConfigurationChangeAcceptable​(SchemaBackendCfg configEntry,
                                                       List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
        Description copied from interface: ConfigurationChangeListener
        Indicates whether the proposed change to the configuration is acceptable to this change listener.
        Specified by:
        isConfigurationChangeAcceptable in interface ConfigurationChangeListener<SchemaBackendCfg>
        Parameters:
        configEntry - The new configuration containing the changes.
        unacceptableReasons - A list that can be used to hold messages about why the provided configuration is not acceptable.
        Returns:
        Returns true if the proposed change is acceptable, or false if it is not.
      • getComponentEntryDN

        public DN getComponentEntryDN()
        Description copied from interface: AlertGenerator
        Retrieves the DN of the configuration entry with which this alert generator is associated.
        Specified by:
        getComponentEntryDN in interface AlertGenerator
        Returns:
        The DN of the configuration entry with which this alert generator is associated.
      • getClassName

        public String getClassName()
        Description copied from interface: AlertGenerator
        Retrieves the fully-qualified name of the Java class for this alert generator implementation.
        Specified by:
        getClassName in interface AlertGenerator
        Returns:
        The fully-qualified name of the Java class for this alert generator implementation.
      • getAlerts

        public Map<String,​String> getAlerts()
        Description copied from interface: AlertGenerator
        Retrieves information about the set of alerts that this generator may produce. The map returned should be between the notification type for a particular notification and the human-readable description for that notification. This alert generator must not generate any alerts with types that are not contained in this list.
        Specified by:
        getAlerts in interface AlertGenerator
        Returns:
        Information about the set of alerts that this generator may produce.
      • getDirectory

        public File getDirectory()
        Description copied from interface: Backupable
        Returns the directory which acts as the root of all files to backup and restore.
        Specified by:
        getDirectory in interface Backupable
        Returns:
        the root directory
      • isDirectRestore

        public boolean isDirectRestore()
        Description copied from interface: Backupable
        Indicates if restore is done directly in the restore directory.
        Specified by:
        isDirectRestore in interface Backupable
        Returns:
        true if restore is done directly in the restore directory provided by getDirectory() method, or false if restore is done in a temporary directory.
      • beforeRestore

        public Path beforeRestore()
                           throws DirectoryException
        Description copied from interface: Backupable
        Called before the restore operation begins.

        In case of direct restore, the backupable entity should take any action to save a copy of existing data before restore operation. Saving includes removing the existing data and copying it in a save directory.

        Specified by:
        beforeRestore in interface Backupable
        Returns:
        the directory where current files are saved. It may be null if not applicable.
        Throws:
        DirectoryException - If an error occurs.
      • afterRestore

        public void afterRestore​(Path restoreDirectory,
                                 Path saveDirectory)
                          throws DirectoryException
        Description copied from interface: Backupable
        Called after the restore operation has finished successfully.

        For direct restore, the backupable entity can safely discard the saved copy. For indirect restore, the backupable entity should switch the restored directory to the final restore directory.

        Specified by:
        afterRestore in interface Backupable
        Parameters:
        restoreDirectory - The directory in which files have actually been restored. It is never null.
        saveDirectory - The directory in which current files have been saved. It may be null if beforeRestore() returned null.
        Throws:
        DirectoryException - If an error occurs.