Class AbstractMaintenanceTask
java.lang.Object
org.ametys.workspaces.repository.maintenance.AbstractMaintenanceTask
- All Implemented Interfaces:
LogEnabled
- Direct Known Subclasses:
CleanReferenceTask,ConsistencyCheckTask,DataStoreGarbageCollectorTask,ReclaimUnusedSpaceTask,ReindexingTask,RemoveUnusedHistoryTask
Jackrabbit maintenance tasks implementations should extends this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.slf4j.LoggerLogger for tracesprotected ContainerProgressionTrackerContainerProgressionTracker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 tasksprotected RepositoryImplCreate a repository.protected RepositoryContextCreate a repository context.voidexecute(Pair<RepositoryConfig, RepositoryContext> repositoryInfo) Execute the taskprotected static List<IterablePersistenceManager>Get the persistence manager from all workspace and the version manager from the repository context If any of those persistence manager is not anIterablePersistenceManagernull will be returnedprotected RepositoryImplGet the repository from a provided context.protected RepositoryContextGet the current repository context if one was provided or already created.Get progress information.protected RepositoryImplGet the repository.protected RepositoryConfigGet the repository configprotected voidInitialize the tasks.booleanIs the execution of the task finished?booleanIndicate if the task need to be executed with an offline repositoryprotected abstract voidSet the tasks logger.voidsetLogger(org.slf4j.Logger logger) Called at creation time to provide aLogger.
-
Field Details
-
_progress
ContainerProgressionTracker -
_logger
Logger for traces
-
-
Constructor Details
-
AbstractMaintenanceTask
public AbstractMaintenanceTask()
-
-
Method Details
-
requiresOffline
Indicate if the task need to be executed with an offline repository- Returns:
- true if the repository need to be offline
-
execute
public void execute(Pair<RepositoryConfig, RepositoryContext> repositoryInfo) throws javax.jcr.RepositoryExceptionExecute the task- Parameters:
repositoryInfo- a pair providing either the repository config (left) or the repository context (right). Only one will be valued. The other one is null.- 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 theProgressionTrackerobject bounded to the task.- Throws:
javax.jcr.RepositoryException- If a repository exception
-
apply
Apply the tasks (within the execute method()).- Throws:
javax.jcr.RepositoryException- If a repository exception
-
close
Close the tasks -
setLogger
Set the tasks logger. -
setLogger
Description copied from interface:LogEnabledCalled at creation time to provide aLogger.- Specified by:
setLoggerin interfaceLogEnabled- Parameters:
logger- aLoggerfor messages.
-
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.
-
getRepositoryConfig
Get the repository config- Returns:
- the repository config
-
createRepositoryContext
Create a repository context. If a repository context was provided, or a repository was already created, then an error will be thrown- Returns:
- the repository context
- Throws:
javax.jcr.RepositoryException- if an error occurred
-
getOrCreateRepositoryContext
Get the current repository context if one was provided or already created. Or instantiate a new one from the provided config.- Returns:
- a repository context
- Throws:
javax.jcr.RepositoryException- when an error occurred
-
getRepository
Get the repository. The repository can either be retrieved from a providedRepositoryContextor from a context created bycreateRepositoryContext(),createRepository()orgetOrCreateRepository().- Returns:
- the repository
-
createRepository
Create a repository. If there is already an existing repository or repository context, a error will be thrown- Returns:
- a repository
- Throws:
javax.jcr.RepositoryException- when an error occurred
-
getOrCreateRepository
Get the repository from a provided context. Or instantiate a new repository from the provided config- Returns:
- a repository
- Throws:
javax.jcr.RepositoryException- when an error occurred
-
getAllPersistenceManager
protected static List<IterablePersistenceManager> getAllPersistenceManager(RepositoryContext context) throws javax.jcr.RepositoryException Get the persistence manager from all workspace and the version manager from the repository context If any of those persistence manager is not anIterablePersistenceManagernull will be returned- Parameters:
context- the repository context- Returns:
- the persistence managers
- Throws:
javax.jcr.RepositoryException- if an error occurred
-