Class UnlockHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.repository.lock.UnlockHelper
-
- All Implemented Interfaces:
LogEnabled
,Disposable
,Initializable
,Component
,Serviceable
,ThreadSafe
public class UnlockHelper extends AbstractLogEnabled implements Initializable, ThreadSafe, Component, Serviceable, Disposable
The helper for scheduling the unlocking of the contents.
At initialization all contents are scanned and locked ones will be automatically unlocked.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
__ACTIVATE_PARAMETER
private static String
__PERIOD_PARAMETER
private boolean
_activated
private Map<String,LocalDateTime>
_lockedObjects
The map of locked contents id (String) and their locked time (value)private long
_period
private AmetysObjectResolver
_resolver
protected Scheduler
_scheduler
The schedulerstatic String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description UnlockHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
_cancelUnlocking(AmetysObject object)
private void
_initializeLockedObjects()
Search and stores references to all lockedAmetysObject
s in the repository.
Should not be called by clients.boolean
cancelUnlocking(AmetysObject object)
Cancel the unlocking of anAmetysObject
.void
dispose()
<A extends LockableAmetysObject>
Map<A,LocalDateTime>getLockedObjects()
Get all current lockedLockableAmetysObject
.long
getTimeBeforeUnlock()
Get the period before unlocking a content.void
initialize()
boolean
isUnlockingActivated()
Check if the unlocking is enabled.void
scheduleUnlocking(AmetysObject object)
Schedule a task to unlock an object.void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__ACTIVATE_PARAMETER
private static final String __ACTIVATE_PARAMETER
- See Also:
- Constant Field Values
-
__PERIOD_PARAMETER
private static final String __PERIOD_PARAMETER
- See Also:
- Constant Field Values
-
_scheduler
protected Scheduler _scheduler
The scheduler
-
_activated
private boolean _activated
-
_period
private long _period
-
_lockedObjects
private Map<String,LocalDateTime> _lockedObjects
The map of locked contents id (String) and their locked time (value)
-
_resolver
private AmetysObjectResolver _resolver
-
-
Constructor Detail
-
UnlockHelper
public UnlockHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
_initializeLockedObjects
private void _initializeLockedObjects()
Search and stores references to all lockedAmetysObject
s in the repository.
Should not be called by clients.
-
isUnlockingActivated
public boolean isUnlockingActivated()
Check if the unlocking is enabled.- Returns:
- true if the unlocking is activated, false otherwise.
-
getTimeBeforeUnlock
public long getTimeBeforeUnlock()
Get the period before unlocking a content.- Returns:
- The period in hours.
-
scheduleUnlocking
public void scheduleUnlocking(AmetysObject object)
Schedule a task to unlock an object.- Parameters:
object
- TheAmetysObject
to be unlocked.
-
cancelUnlocking
public boolean cancelUnlocking(AmetysObject object)
Cancel the unlocking of anAmetysObject
.- Parameters:
object
- The object to cancel the unlock scheduling.- Returns:
- true if the unlocking was cancelled, false otherwise.
-
_cancelUnlocking
private boolean _cancelUnlocking(AmetysObject object)
-
getLockedObjects
public <A extends LockableAmetysObject> Map<A,LocalDateTime> getLockedObjects()
Get all current lockedLockableAmetysObject
.- Type Parameters:
A
- the generic type extendingLockableAmetysObject
.- Returns:
- The contents as a Map of Content to LocalDateTime (the date time when they were locked).
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceDisposable
-
-