Class AbstractMaintenanceTask

java.lang.Object
org.ametys.workspaces.repository.maintenance.AbstractMaintenanceTask
All Implemented Interfaces:
LogEnabled
Direct Known Subclasses:
ConsistencyCheckTask, DataStoreGarbageCollectorTask, ReindexingTask, RemoveUnusedHistoryTask

public abstract class AbstractMaintenanceTask extends Object implements LogEnabled
Jackrabbit maintenance tasks implementations should extends this class.
  • Field Details

  • Constructor Details

  • Method Details

    • execute

      public void execute(RepositoryConfig repositoryConfig) throws javax.jcr.RepositoryException
      Execute the task
      Parameters:
      repositoryConfig - The RepositoryConfig object, used to create new Repository instance.
      Throws:
      javax.jcr.RepositoryException - If an error with the repository occurs while the task is executed.
    • initialize

      protected void initialize() throws javax.jcr.RepositoryException
      Initialize the tasks. This method can also create the TaskProgress object bounded to the task.
      Throws:
      javax.jcr.RepositoryException - If a repository exception
    • setLogger

      protected abstract void setLogger()
      Set the tasks logger.
    • setLogger

      public void setLogger(Logger logger)
      Description copied from interface: LogEnabled
      Called at creation time to provide a Logger.
      Specified by:
      setLogger in interface LogEnabled
      Parameters:
      logger - a Logger for messages.
    • apply

      protected abstract void apply() throws javax.jcr.RepositoryException
      Apply the tasks (within the execute method()).
      Throws:
      javax.jcr.RepositoryException - If a repository exception
    • close

      protected void close() throws javax.jcr.RepositoryException
      Close the tasks
      Throws:
      javax.jcr.RepositoryException - If a repository exception
    • getProgressInfo

      Get progress information.
      Returns:
      a map containing information on the progress status.
    • isFinished

      public boolean isFinished()
      Is the execution of the task finished?
      Returns:
      true if finished
    • _getFormattedDuration

      protected String _getFormattedDuration(long elapsedTime)
      Transforms millisecond to a formatted string representing a duration.
      Parameters:
      elapsedTime - milleseconds corresponding to the duration.
      Returns:
      Pretty formatted string.