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 protected Scheduler_schedulerThe schedulerstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description UnlockHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
_scheduler
protected Scheduler _scheduler
The scheduler
-
-
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
-
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.
-
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
-
-