Class AbstractMaintenanceTask
java.lang.Object
org.ametys.workspaces.repository.maintenance.AbstractMaintenanceTask
- All Implemented Interfaces:
LogEnabled
- Direct Known Subclasses:
ConsistencyCheckTask
,DataStoreGarbageCollectorTask
,ReindexingTask
,RemoveUnusedHistoryTask
Jackrabbit maintenance tasks implementations should extends this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Logger
Logger for tracesprotected TaskProgress
TaskProgressprotected RepositoryConfig
The repository configprotected RepositoryProvider
The repository provider. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected String
_getFormattedDuration
(long elapsedTime) Transforms millisecond to a formatted string representing a duration.protected abstract void
apply()
Apply the tasks (within the execute method()).protected void
close()
Close the tasksvoid
execute
(RepositoryConfig repositoryConfig) Execute the taskGet progress information.protected void
Initialize the tasks.boolean
Is the execution of the task finished?protected abstract void
Set the tasks logger.void
Called at creation time to provide aLogger
.
-
Field Details
-
_progress
TaskProgress -
_repositoryConfig
The repository config -
_repositoryProvider
The repository provider. -
_logger
Logger for traces
-
-
Constructor Details
-
AbstractMaintenanceTask
public AbstractMaintenanceTask()
-
-
Method Details
-
execute
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
Initialize the tasks. This method can also create theTaskProgress
object bounded to the task.- Throws:
javax.jcr.RepositoryException
- If a repository exception
-
setLogger
Set the tasks logger. -
setLogger
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
apply
Apply the tasks (within the execute method()).- Throws:
javax.jcr.RepositoryException
- If a repository exception
-
close
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
Is the execution of the task finished?- Returns:
- true if finished
-
_getFormattedDuration
Transforms millisecond to a formatted string representing a duration.- Parameters:
elapsedTime
- milleseconds corresponding to the duration.- Returns:
- Pretty formatted string.
-