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_PARAMETERprivate static String__PERIOD_PARAMETERprivate boolean_activatedprivate Map<String,LocalDateTime>_lockedObjectsThe map of locked contents id (String) and their locked time (value)private long_periodprivate AmetysObjectResolver_resolverprotected Scheduler_schedulerThe schedulerstatic StringROLEAvalon 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 lockedAmetysObjects in the repository.
Should not be called by clients.booleancancelUnlocking(AmetysObject object)Cancel the unlocking of anAmetysObject.voiddispose()<A extends LockableAmetysObject>
Map<A,LocalDateTime>getLockedObjects()Get all current lockedLockableAmetysObject.longgetTimeBeforeUnlock()Get the period before unlocking a content.voidinitialize()booleanisUnlockingActivated()Check if the unlocking is enabled.voidscheduleUnlocking(AmetysObject object)Schedule a task to unlock an object.voidservice(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:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
_initializeLockedObjects
private void _initializeLockedObjects()
Search and stores references to all lockedAmetysObjects 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- TheAmetysObjectto 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:
disposein interfaceDisposable
-
-