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
_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 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
-
_scheduler
protected Scheduler _scheduler
The scheduler
-
-
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
-
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.
-
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
-
-