Class LocalBackend<C extends Configuration>

    • Constructor Detail

      • LocalBackend

        public LocalBackend()
    • Method Detail

      • finalizeBackend

        public final void finalizeBackend()
        Description copied from class: Backend
        Performs any necessary work to finalize this backend. The backend must be an opened backend, so do not use this method on backends where only configureBackend() has been called. This may be called during the Directory Server shutdown process or if a backend is disabled with the server online. It must not return until the backend is closed.

        This method may not throw any exceptions. If any problems are encountered, then they may be logged but the closure should progress as completely as possible.

        Specified by:
        finalizeBackend in class Backend<C extends Configuration>
      • closeBackend

        public void closeBackend()
        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.

      • isIndexed

        public abstract boolean isIndexed​(AttributeType attributeType,
                                          IndexType indexType)
        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.
        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.
      • isIndexed

        public boolean isIndexed​(SearchFilter filter)
        Indicates whether a subtree search using the provided filter would be indexed in this backend. This default implementation uses a rough set of logic that makes a best-effort determination. Subclasses that provide a more complete indexing mechanism may wish to override this method and provide a more accurate result.
        Parameters:
        filter - The search filter for which to make the determination.
        Returns:
        true if it is believed that the provided filter would be indexed in this backend, or false if not.
      • hasSubordinates

        public abstract ConditionResult hasSubordinates​(DN entryDN)
                                                 throws DirectoryException
        Indicates whether the requested entry has any subordinates.
        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.
      • getNumberOfChildren

        public abstract long getNumberOfChildren​(DN parentDN)
                                          throws DirectoryException
        Retrieves the number of subordinates immediately below the requested entry.
        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.
        NullPointerException - if baseDN is null.
      • getNumberOfEntriesInBaseDN

        public abstract long getNumberOfEntriesInBaseDN​(DN baseDN)
                                                 throws DirectoryException
        Retrieves the number of entries for the specified base DN including all entries from the requested entry to the lowest level in the tree.
        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.
        NullPointerException - if baseDN is null.
      • entryExists

        public boolean entryExists​(DN entryDN)
                            throws DirectoryException
        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.
        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.
      • getEntry

        public abstract Entry getEntry​(DN entryDN)
                                throws DirectoryException
        Retrieves the requested entry from this backend. The caller is not required to hold any locks on the specified DN.
        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.
      • addEntry

        public abstract void addEntry​(Entry entry,
                                      AddOperation addOperation)
                               throws DirectoryException,
                                      CanceledOperationException
        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.
        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.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the add operation.
      • deleteEntry

        public abstract void deleteEntry​(DN entryDN,
                                         DeleteOperation deleteOperation)
                                  throws DirectoryException,
                                         CanceledOperationException
        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.
        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.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the delete operation.
      • replaceEntry

        public abstract void replaceEntry​(Entry oldEntry,
                                          Entry newEntry,
                                          ModifyOperation modifyOperation)
                                   throws DirectoryException,
                                          CanceledOperationException
        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.
        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.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the modify operation.
      • renameEntry

        public abstract void renameEntry​(DN currentDN,
                                         Entry entry,
                                         ModifyDNOperation modifyDNOperation)
                                  throws DirectoryException,
                                         CanceledOperationException
        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.
        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.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the modify DN operation.
      • search

        public abstract void search​(SearchOperation searchOperation)
                             throws DirectoryException,
                                    CanceledOperationException
        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.
        Parameters:
        searchOperation - The search operation to be processed.
        Throws:
        DirectoryException - If a problem occurs while processing the search.
        CanceledOperationException - If this backend noticed and reacted to a request to cancel or abandon the search operation.
      • supports

        public abstract boolean supports​(LocalBackend.BackendOperation backendOperation)
        Indicates whether this backend supports the provided backend operation.
        Parameters:
        backendOperation - the backend operation
        Returns:
        true if this backend supports the provided backend operation, false otherwise.
      • createBackup

        public abstract void createBackup​(BackupConfig backupConfig)
                                   throws DirectoryException
        Creates a backup of the contents of this backend in a form that may be restored at a later date if necessary. This method should only be called if supports(BackendOperation) with LocalBackend.BackendOperation.BACKUP returns true.

        Note that the server will not explicitly initialize this backend before calling this method.

        Parameters:
        backupConfig - The configuration to use when performing the backup.
        Throws:
        DirectoryException - If a problem occurs while performing the backup.
      • removeBackup

        public abstract void removeBackup​(BackupDirectory backupDirectory,
                                          String backupID)
                                   throws DirectoryException
        Removes the specified backup if it is possible to do so.
        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).
      • getWritabilityMode

        public final WritabilityMode getWritabilityMode()
        Retrieves the writability mode for this backend.
        Returns:
        The writability mode for this backend.
      • setWritabilityMode

        public final void setWritabilityMode​(WritabilityMode writabilityMode)
        Specifies the writability mode for this backend.
        Parameters:
        writabilityMode - The writability mode for this backend.
      • isPrivateBackend

        public final boolean isPrivateBackend()
        Description copied from class: Backend
        Indicates whether this backend holds private data or user data.
        Specified by:
        isPrivateBackend in class Backend<C extends Configuration>
        Returns:
        true if this backend holds private data, or false if it holds user data.
      • setPrivateBackend

        public final void setPrivateBackend​(boolean isPrivateBackend)
        Specifies whether this backend holds private data or user data.
        Parameters:
        isPrivateBackend - Specifies whether this backend holds private data or user data.
      • isDefaultRoute

        public final boolean isDefaultRoute()
        Description copied from class: Backend
        Indicates whether this backend should be considered a default (wild-card) route.
        Specified by:
        isDefaultRoute in class Backend<C extends Configuration>
        Returns:
        true if the backend should be considered as the default route, false otherwise
      • registerPersistentSearch

        public void registerPersistentSearch​(PersistentSearch persistentSearch)
                                      throws DirectoryException
        Registers the provided persistent search operation with this backend so that it will be notified of any add, delete, modify, or modify DN operations that are performed.
        Parameters:
        persistentSearch - The persistent search operation to register with this backend
        Throws:
        DirectoryException - If a problem occurs while registering the persistent search
      • getPersistentSearches

        public Queue<PersistentSearch> getPersistentSearches()
        Returns the persistent searches currently active against this local backend.
        Returns:
        the list of persistent searches currently active against this local backend
      • getEntryCount

        public abstract long getEntryCount()
        Retrieves the total number of entries contained in this backend, if that information is available.
        Returns:
        The total number of entries contained in this backend, or -1 if that information is not available.
      • handlesEntry

        public final boolean handlesEntry​(DN entryDN)
        Indicates whether this backend should be used to handle operations for the provided entry.
        Parameters:
        entryDN - The DN of the entry for which to make the determination.
        Returns:
        true if this backend handles operations for the provided entry, or false if it does not.
      • getBackendMonitor

        public final LocalBackendMonitor getBackendMonitor()
        Retrieves the backend monitor that is associated with this backend.
        Returns:
        The backend monitor that is associated with this backend, or null if none has been assigned.
      • setBackendMonitor

        public final void setBackendMonitor​(LocalBackendMonitor backendMonitor)
        Sets the backend monitor for this backend.
        Parameters:
        backendMonitor - The backend monitor for this backend.
      • supportsControl

        public final boolean supportsControl​(String controlOID)
        Indicates whether this backend supports the specified control.
        Parameters:
        controlOID - The OID of the control for which to make the determination.
        Returns:
        true if this backends supports the control with the specified OID, or false if it does not.
      • handlesEntry

        public static boolean handlesEntry​(DN entryDN,
                                           Collection<DN> baseDNs,
                                           Collection<DN> excludeDNs)
        Indicates whether a backend should be used to handle operations for the provided entry given the set of base DNs and exclude DNs.
        Parameters:
        entryDN - The DN of the entry for which to make the determination.
        baseDNs - The set of base DNs for the backend.
        excludeDNs - The set of DNs that should be excluded from the backend.
        Returns:
        true if the backend should handle operations for the provided entry, or false if it does not.