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 Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
_logger
Logger for tracesprotected TaskProgress
_progress
TaskProgressprotected RepositoryConfig
_repositoryConfig
The repository configprotected RepositoryProvider
_repositoryProvider
The repository provider.
-
Constructor Summary
Constructors Constructor Description AbstractMaintenanceTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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 taskMap<String,Object>
getProgressInfo()
Get progress information.protected void
initialize()
Initialize the tasks.boolean
isFinished()
Is the execution of the task finished?protected abstract void
setLogger()
Set the tasks logger.void
setLogger(org.slf4j.Logger logger)
Called at creation time to provide aLogger
.
-
-
-
Field Detail
-
_progress
protected TaskProgress _progress
TaskProgress
-
_repositoryConfig
protected RepositoryConfig _repositoryConfig
The repository config
-
_repositoryProvider
protected RepositoryProvider _repositoryProvider
The repository provider.
-
_logger
protected org.slf4j.Logger _logger
Logger for traces
-
-
Constructor Detail
-
AbstractMaintenanceTask
public AbstractMaintenanceTask()
-
-
Method Detail
-
execute
public void execute(RepositoryConfig repositoryConfig) throws RepositoryException
Execute the task- Parameters:
repositoryConfig
- The RepositoryConfig object, used to create new Repository instance.- Throws:
RepositoryException
- If an error with the repository occurs while the task is executed.
-
initialize
protected void initialize() throws RepositoryException
Initialize the tasks. This method can also create theTaskProgress
object bounded to the task.- Throws:
RepositoryException
- If a repository exception
-
setLogger
protected abstract void setLogger()
Set the tasks logger.
-
setLogger
public void setLogger(org.slf4j.Logger logger)
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
apply
protected abstract void apply() throws RepositoryException
Apply the tasks (within the execute method()).- Throws:
RepositoryException
- If a repository exception
-
close
protected void close() throws RepositoryException
Close the tasks- Throws:
RepositoryException
- If a repository exception
-
getProgressInfo
public Map<String,Object> 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.
-
-