Package com.jalios.jcms
Class StrongLockManager
- java.lang.Object
-
- com.jalios.jcms.db.BasicDBListener
-
- com.jalios.jcms.StrongLockManager
-
- All Implemented Interfaces:
DBConstants
,DBListener
,PluginComponent
public class StrongLockManager extends BasicDBListener
This class manages StrongLock.- Since:
- jcms-6.2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
StrongLockManager.CacheEntry
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CACHE_ENABLED_PROP
static java.lang.String
CACHE_MAX_ENTRIES_PROP
static java.lang.String
DATA_ID_FIELD
-
Fields inherited from interface com.jalios.jcms.db.DBConstants
ALL_CATEGORIES_SET_FIELD, ATTACH_WS_SET_FIELD, AUTH_GRP_SET_FIELD, AUTH_MBR_SET_FIELD, AUTHOR_ID_FIELD, CATEGORIES_SET_FIELD, CDATE_FIELD, CHANNEL_JCMSDB_PROP, CLASSIFICATION_LEVEL_FIELD, DBDATA_URID, EXTENDED_READ_RIGHTS, HAS_ATTACH_WS_FIELD, HAS_NO_READ_RIGHTS, HIBERNATE_MAPPING_ADATE, HIBERNATE_MAPPING_AUTHOR, HIBERNATE_MAPPING_CDATE, HIBERNATE_MAPPING_EDATE, HIBERNATE_MAPPING_HAS_ATTACH_WS, HIBERNATE_MAPPING_HASNOREADRIGHTS, HIBERNATE_MAPPING_MAININSTANCE_ID, HIBERNATE_MAPPING_MAJORVERSION, HIBERNATE_MAPPING_MDATE, HIBERNATE_MAPPING_MERGE_DATE, HIBERNATE_MAPPING_MERGE_ID, HIBERNATE_MAPPING_MINORVERSION, HIBERNATE_MAPPING_OPAUTHOR, HIBERNATE_MAPPING_PDATE, HIBERNATE_MAPPING_PSTATUS, HIBERNATE_MAPPING_READ_ACK, HIBERNATE_MAPPING_READERCOUNT, HIBERNATE_MAPPING_RESTRICTIVE_UPDATE_RIGHTS, HIBERNATE_MAPPING_TITLE, HIBERNATE_MAPPING_TRACKED, HIBERNATE_MAPPING_UDATE, HIBERNATE_MAPPING_VOTECOUNT, HIBERNATE_MAPPING_VOTESCORE, HIBERNATE_MAPPING_WORKFLOW_ID, HIBERNATE_MAPPING_WORKSPACE_ID, MAX_HIBERNATE_MAPPING_PUBLICATION, MDATE_FIELD, OPAUTHOR_ID_FIELD, PSTATUS_FIELD, ROW_ID_FIELD, SCROLL_FETCH_SIZE, WORKFLOW_ID_FIELD, WORKSPACE_ID_FIELD
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canRequestUnlock(Data data, Member mbr)
Returns true if the given member can request the unlock (by mail).boolean
canUnlock(Data data, Member mbr)
Returns true if the member can unlock the given databoolean
canUnlock(StrongLock lock, Member mbr)
Returns true if the member can unlock the given lockboolean
checkLockMember(Data data, Member mbr)
Returns true if the given member has locked the given data or if the data is not locked.boolean
checkLockMember(Data data, Member mbr, boolean useCache)
Returns true if the given member has locked the given data or if the data is not locked.static StrongLockManager
getInstance()
<T extends Data>
java.util.Set<T>getLockedDataSet(java.lang.Class<T> clazz)
Returns all the locked data for the given class.<T extends Data>
java.util.Set<T>getLockedDataSet(java.lang.Class<T> clazz, boolean useCache)
Returns all the locked data for the given class.<T extends Data>
java.util.Set<T>getLockedDataSet(java.lang.Class<T> clazz, Member mbr)
Returns all the locked data for the given class and locked by the given member.java.lang.String
getLockInfo(Data data, java.util.Locale locale)
Returns a string which explains who has the lock on the given data (return "" if the data is not locked)java.lang.String
getLockInfo(Data data, java.util.Locale locale, boolean useCache)
Returns a string which explains who has the lock on the given data (return "" if the data is not locked)StrongLock
getStrongLock(Data data)
Returns the StrongLock bound to given data.StrongLock
getStrongLock(Data data, boolean useCache)
Returns the StrongLock bound to given data.boolean
isLocked(Data data)
Returns true if the given data is locked.void
lock(Data data, Member mbr)
Lock the given data for the given member.void
lock(Data data, Member mbr, java.lang.String context, java.lang.String contextData)
Lock the given data for the given member.void
onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
This method is called after a DBData has been deleted.void
onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)
This method is called after a DBData has been created.void
onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
This method is called after a DBData has been updated.void
refreshCacheEntry(Data data)
Invalidate the cache entries for the given publicationvoid
requestUnlock(Data data, Member mbr, java.lang.String message)
Request to unlock the given data for the given membervoid
resetCache()
Reset the cache.void
unlock(Data data)
Unlock the given data, without checking the member.void
unlock(Data data, Member mbr)
Unlock the given datavoid
unlock(Data data, Member mbr, boolean force)
Unlock the given data-
Methods inherited from class com.jalios.jcms.db.BasicDBListener
getAdateFromState, getAuthorIdFromState, getCdateFromState, getDateFromState, getEdateFromState, getMdateFromState, getPdateFromState, getPrePstatus, getPrePstatus, getPstatusFromState, hasNoChange, hasNoChange, init, onPreUpdate
-
-
-
-
Field Detail
-
CACHE_ENABLED_PROP
public static final java.lang.String CACHE_ENABLED_PROP
- See Also:
- Constant Field Values
-
CACHE_MAX_ENTRIES_PROP
public static final java.lang.String CACHE_MAX_ENTRIES_PROP
- See Also:
- Constant Field Values
-
DATA_ID_FIELD
public static final java.lang.String DATA_ID_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static StrongLockManager getInstance()
-
getStrongLock
public StrongLock getStrongLock(Data data)
Returns the StrongLock bound to given data.- Parameters:
data
- the data- Returns:
- the StrongLock bound to given data.
- Since:
- jcms-6.2.0
-
getStrongLock
public StrongLock getStrongLock(Data data, boolean useCache)
Returns the StrongLock bound to given data.- Parameters:
data
- the datauseCache
- indicate if the cache can be used.- Returns:
- the StrongLock bound to given data.
- Since:
- jcms-6.2.0
-
isLocked
public boolean isLocked(Data data)
Returns true if the given data is locked.- Parameters:
data
- the data- Returns:
- true if the given data is locked.
- Since:
- jcms-6.2.0
-
getLockedDataSet
public <T extends Data> java.util.Set<T> getLockedDataSet(java.lang.Class<T> clazz)
Returns all the locked data for the given class.- Type Parameters:
T
- Any Data type- Parameters:
clazz
- the class- Returns:
- all the locked data for the given class.
- Since:
- jcms-6.2.0
-
getLockedDataSet
public <T extends Data> java.util.Set<T> getLockedDataSet(java.lang.Class<T> clazz, boolean useCache)
Returns all the locked data for the given class.- Type Parameters:
T
- Any Data type- Parameters:
clazz
- the classuseCache
- use the cache if true- Returns:
- all the locked data for the given class.
- Since:
- jcms-6.2.0
-
getLockedDataSet
public <T extends Data> java.util.Set<T> getLockedDataSet(java.lang.Class<T> clazz, Member mbr)
Returns all the locked data for the given class and locked by the given member.- Type Parameters:
T
- Any Data type- Parameters:
clazz
- the classmbr
- the member- Returns:
- all the locked data for the given class and locked by the given member.
- Since:
- jcms-9.0.1
-
lock
public void lock(Data data, Member mbr)
Lock the given data for the given member.- Parameters:
data
- the datambr
- the member who puts the lock.- Since:
- jcms-6.2.0
-
lock
public void lock(Data data, Member mbr, java.lang.String context, java.lang.String contextData)
Lock the given data for the given member.- Parameters:
data
- the datambr
- the member who puts the lock.context
- the context of the lockcontextData
- the context data (custom data put by context manager)- Since:
- jcms-10.0.2
-
unlock
public void unlock(Data data, Member mbr)
Unlock the given data- Parameters:
data
- the datambr
- the member who releases the lock (only the member who has locked and the admin can release the lock).- Since:
- jcms-6.2.0
-
unlock
public void unlock(Data data)
Unlock the given data, without checking the member.- Parameters:
data
- the data- Since:
- jcms-6.2.0
-
unlock
public void unlock(Data data, Member mbr, boolean force)
Unlock the given data- Parameters:
data
- the datambr
- the member who releases the lockforce
- if false only the member who has locked and the admin can release the lock.- Since:
- jcms-6.2.0
-
canUnlock
public boolean canUnlock(Data data, Member mbr)
Returns true if the member can unlock the given data- Parameters:
data
- the datambr
- the member- Returns:
- true if the member can unlock the given data
- Since:
- jcms-9.0.0
-
canUnlock
public boolean canUnlock(StrongLock lock, Member mbr)
Returns true if the member can unlock the given lock- Parameters:
lock
- the lockmbr
- the member- Returns:
- true if the member can unlock the given lock
- Since:
- jcms-9.0.0
-
checkLockMember
public boolean checkLockMember(Data data, Member mbr)
Returns true if the given member has locked the given data or if the data is not locked.- Parameters:
data
- the datambr
- the member- Returns:
- true if the given member has locked the given data or if the data is not locked.
- Since:
- jcms-6.2.0
-
checkLockMember
public boolean checkLockMember(Data data, Member mbr, boolean useCache)
Returns true if the given member has locked the given data or if the data is not locked.- Parameters:
data
- the datambr
- the memberuseCache
- indicate if the cache can be used.- Returns:
- true if the given member has locked the given data or if the data is not locked.
- Since:
- jcms-10.0.1
-
getLockInfo
public java.lang.String getLockInfo(Data data, java.util.Locale locale)
Returns a string which explains who has the lock on the given data (return "" if the data is not locked)- Parameters:
data
- the datalocale
- the locale- Returns:
- a string which explains who has the lock.
- Since:
- jcms-6.2.0
-
getLockInfo
public java.lang.String getLockInfo(Data data, java.util.Locale locale, boolean useCache)
Returns a string which explains who has the lock on the given data (return "" if the data is not locked)- Parameters:
data
- the datalocale
- the localeuseCache
- indicate if the cache can be used.- Returns:
- a string which explains who has the lock.
- Since:
- jcms-6.2.0
-
canRequestUnlock
public boolean canRequestUnlock(Data data, Member mbr)
Returns true if the given member can request the unlock (by mail).- Parameters:
data
- the datambr
- the member who request the unlock- Returns:
- true if the given member can request the unlock.
- Since:
- jcms-8.0.0
-
requestUnlock
public void requestUnlock(Data data, Member mbr, java.lang.String message)
Request to unlock the given data for the given member- Parameters:
data
- the locked datambr
- the member who request the unlockmessage
- a free message from the member who request the unlock- Since:
- jcms-8.0.0
-
resetCache
public void resetCache()
Reset the cache. A new cache is initialized.- Since:
- jcms-6.2.0
-
refreshCacheEntry
public void refreshCacheEntry(Data data)
Invalidate the cache entries for the given publication- Parameters:
data
- the publication id- Since:
- jcms-6.2.0
-
onPostInsert
public void onPostInsert(DBData data, org.hibernate.event.PostInsertEvent event, boolean firstTime)
Description copied from interface:DBListener
This method is called after a DBData has been created.- Specified by:
onPostInsert
in interfaceDBListener
- Overrides:
onPostInsert
in classBasicDBListener
- Parameters:
data
- the data.event
- the event.firstTime
- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostInsert(DBData, PostInsertEvent, boolean)
-
onPostUpdate
public void onPostUpdate(DBData data, org.hibernate.event.PostUpdateEvent event, boolean firstTime)
Description copied from interface:DBListener
This method is called after a DBData has been updated.- Specified by:
onPostUpdate
in interfaceDBListener
- Overrides:
onPostUpdate
in classBasicDBListener
- Parameters:
data
- the data.event
- the event.firstTime
- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostUpdate(DBData, PostUpdateEvent, boolean)
-
onPostDelete
public void onPostDelete(DBData data, org.hibernate.event.PostDeleteEvent event, boolean firstTime)
Description copied from interface:DBListener
This method is called after a DBData has been deleted.- Specified by:
onPostDelete
in interfaceDBListener
- Overrides:
onPostDelete
in classBasicDBListener
- Parameters:
data
- the deleted DBData. WARNING! In a JSync Cluster, when firstTime is false, this data will be null. In this case, to get information about this deleted data, you must use the event and in particular event.getId(), which returns the JPlatform ID of the data, and event.getDeletedState() which returns the attributes of the data.event
- the eventfirstTime
- true on the JSync replica on which the operation took place and false on the other replicas.- See Also:
DBListener.onPostDelete(DBData, PostDeleteEvent, boolean)
-
-