Class AbstractMaintenanceTask
- java.lang.Object
-
- org.ametys.workspaces.repository.maintenance.AbstractMaintenanceTask
-
- All Implemented Interfaces:
LogEnabled
- Direct Known Subclasses:
ConsistencyCheckTask,DataStoreGarbageCollectorTask,ReindexingTask
public abstract class AbstractMaintenanceTask extends Object implements LogEnabled
Jackrabbit maintenance tasks implementations should extends this class.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean_isFinishedprotected org.slf4j.Logger_loggerLogger for tracesprotected TaskProgress_progressTaskProgressprotected RepositoryConfig_repositoryConfigThe repository configprotected RepositoryProvider_repositoryProviderThe 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 voidapply()Apply the tasks (within the execute method()).protected voidclose()Close the tasksvoidexecute(RepositoryConfig repositoryConfig)Execute the taskMap<String,Object>getProgressInfo()Get progress information.protected voidinitialize()Initialize the tasks.booleanisFinished()Is the execution of the task finished?private voidsetFinished()private voidsetInErrorState(Exception e)protected abstract voidsetLogger()Set the tasks logger.voidsetLogger(org.slf4j.Logger logger)Called at creation time to provide aLogger.private voidsetRunning()
-
-
-
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
-
_isFinished
private boolean _isFinished
-
-
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 theTaskProgressobject 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:LogEnabledCalled at creation time to provide aLogger.- Specified by:
setLoggerin interfaceLogEnabled- Parameters:
logger- aLoggerfor 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
-
setRunning
private void setRunning()
-
setFinished
private void setFinished()
-
setInErrorState
private void setInErrorState(Exception e)
-
_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.
-
-