Class DeleteSubTree

java.lang.Object
com.isode.dsapi.bulk.DeleteSubTree

public class DeleteSubTree extends Object
Recursive delete of a directory subtree, optionally including the start DN.

This retries its searches if a size limit error is encountered until all the entries are deleted. Errors are stored up and returned one by one as exceptions from the getException() method, which may be called whilst the delete is in progress from the foreground thread. status(), isFinished(), getEntryCount() and getErrorCount() may be called to monitor the progress of the recursive delete. abort() may be called to abort the operation.

Note that the run() method should be called only within a background thread (e.g. using BackgroundTask), as the code executes directory operations directly and will block waiting for directory operations to complete.

Author:
jp
  • Constructor Summary

    Constructors
    Constructor
    Description
    DeleteSubTree(DirectorySession ds, DN start, boolean include_start)
    Initialise the DeleteSubTree to use the given directory session, start point and 'first' flag.
    DeleteSubTree(DirectorySession ds, DN start, boolean include_start, boolean useManageDsaIt, DN userDN)
    Initialise the DeleteSubTree to use the given directory session, start point and 'first' flag.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Abort the operation.
    int
    Return the number of entries deleted
    int
    Return the number of errors noted to date.
    Returns the next outstanding Exception, or null if there are no more exceptions outstanding.
    boolean
    Test to see if the dump has finished.
    void
    run()
    Run the sub-tree delete operation.
    Get the current status of the operation as a string.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DeleteSubTree

      public DeleteSubTree(DirectorySession ds, DN start, boolean include_start)
      Initialise the DeleteSubTree to use the given directory session, start point and 'first' flag. This may be done from a GUI thread.
      Parameters:
      ds - DirectorySession to use
      start - DN to start at
      include_start - Include the starting DN in the deletion?
    • DeleteSubTree

      public DeleteSubTree(DirectorySession ds, DN start, boolean include_start, boolean useManageDsaIt, DN userDN)
      Initialise the DeleteSubTree to use the given directory session, start point and 'first' flag. This may be done from a GUI thread.
      Parameters:
      ds - DirectorySession to use
      start - DN to start at
      include_start - Include the starting DN in the deletion?
      useManageDsaIt - TRUE if manageDsaIt should be set to TRUE in common arguments used in DS operations
      userDN - DN of user who has permissions to delete an admin point; if it is null then admin point deletion would fail
      Since:
      15.0
  • Method Details

    • run

      public void run()
      Run the sub-tree delete operation. Non-fatal Exceptions are queued rather than rethrown, so it is important to check for errors after running this method by calling getException().

      This method must be run from a background (non-GUI) thread as it does directory operations directly and will block whilst waiting for directory data.

    • abort

      public void abort()
      Abort the operation. This may be called from the GUI thread. This will stop the operation at the next available opportunity. Note that if the operation is blocked waiting for a directory result, this cannot be interrupted and the abort will not be processed until the directory operation actually returns.
    • status

      public String status()
      Get the current status of the operation as a string. This may be called from the GUI thread.
      Returns:
      Status of the operation as a string
    • isFinished

      public boolean isFinished()
      Test to see if the dump has finished. This may be called from the GUI thread.
      Returns:
      Finished?
    • getException

      public Exception getException()
      Returns the next outstanding Exception, or null if there are no more exceptions outstanding. This may be called from the GUI thread (assuming that the delete is running in the background).

      The Exceptions are plain Exceptions, with an explanation and the problem DN in the message text. If the exception was caused by a DSAPIException, this is available using the getCause() method.

    • getEntryCount

      public int getEntryCount()
      Return the number of entries deleted
    • getErrorCount

      public int getErrorCount()
      Return the number of errors noted to date.