Package org.opencms.lock
Class CmsLock
java.lang.Object
org.opencms.lock.CmsLock
- All Implemented Interfaces:
Comparable<CmsLock>
Represents the lock state of a VFS resource.
The lock state is combination of how, by whom and in which project a resource is currently locked.
- Since:
- 6.0.0
- See Also:
-
Constructor Summary
ConstructorDescriptionCmsLock
(String resourceName, CmsUUID userId, CmsProject project, CmsLockType type) Constructor for a new Cms lock. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
clone()
int
boolean
Compares this lock to the specified object.Returns the edition lock.static CmsLock
Returns the shared Null CmsLock.Returns the project where the resource is currently locked.Returns the ID of the project where the resource is currently locked.protected CmsLock
Returns the related Lock.Returns the name of the locked resource.Returns the system lock.getType()
Returns the type about how the resource is locked.Returns the ID of the user who currently locked the resource.int
hashCode()
boolean
Returnstrue
if this is an directly inherited lock.boolean
isDirectlyOwnedBy
(CmsUser user) Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock.boolean
Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the current user is the owner of this lock, checking also the project of the lock.boolean
isDirectlyOwnedInProjectBy
(CmsUser user, CmsProject project) Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock, checking also the project of the lock.boolean
Returnstrue
if this is an exclusive (or temporary exclusive) lock.boolean
isExclusiveOwnedBy
(CmsUser user) Returnstrue
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner of this lock.boolean
isExclusiveOwnedInProjectBy
(CmsUser user, CmsProject project) Returnstrue
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner and the given project is the project of this lock.boolean
Returnstrue
if this is an inherited lock, which may either be directly or shared inherited.boolean
isInProject
(CmsProject project) Returnstrue
if the given project is the project of this lock.boolean
isLockableBy
(CmsUser user) Checks if a resource can be locked by a user.boolean
boolean
Returnstrue
if the given user is the owner of this lock.boolean
isOwnedInProjectBy
(CmsUser user, CmsProject project) Returnstrue
if the given user is the owner of this lock, and this lock belongs to the given project.boolean
Returnstrue
if this is a persistent lock that should be saved when the systems shuts down.boolean
Returnstrue
if this is a publish lock.boolean
isShared()
Returnstrue
if this is a shared lock.boolean
Returnstrue
if this is a system (2nd level) lock.boolean
Returnstrue
if this is a temporary lock.boolean
Returnstrue
if this lock is in fact unlocked.protected void
setRelatedLock
(CmsLock relatedLock) Sets the related Lock.toString()
Builds a string representation of the current state.
-
Constructor Details
-
CmsLock
Constructor for a new Cms lock.- Parameters:
resourceName
- the full resource name including the site rootuserId
- the ID of the user who locked the resourceproject
- the project where the resource is lockedtype
- flag indicating how the resource is locked
-
-
Method Details
-
getNullLock
Returns the shared Null CmsLock.- Returns:
- the shared Null CmsLock
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CmsLock>
- See Also:
-
equals
Compares this lock to the specified object. -
getEditionLock
Returns the edition lock.- Returns:
- the edition lock
-
getProject
Returns the project where the resource is currently locked.- Returns:
- the project where the resource is currently locked
-
getProjectId
Returns the ID of the project where the resource is currently locked.- Returns:
- the ID of the project
-
getResourceName
Returns the name of the locked resource.- Returns:
- the name of the locked resource
-
getSystemLock
Returns the system lock.- Returns:
- the system lock
-
getType
Returns the type about how the resource is locked.- Returns:
- the type of the lock
-
getUserId
Returns the ID of the user who currently locked the resource.- Returns:
- the ID of the user
-
hashCode
-
isDirectlyInherited
Returnstrue
if this is an directly inherited lock.- Returns:
true
if this is an directly inherited lock
-
isDirectlyOwnedBy
Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock.- Parameters:
user
- the user to compare to the owner of this lock- Returns:
true
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock
-
isDirectlyOwnedInProjectBy
Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the current user is the owner of this lock, checking also the project of the lock.- Parameters:
cms
- the CMS context to check- Returns:
true
if this is an exclusive, temporary exclusive, or directly inherited lock, and the current user is the owner of this lock
-
isDirectlyOwnedInProjectBy
Returnstrue
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock, checking also the project of the lock.- Parameters:
user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this lock- Returns:
true
if this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock
-
isExclusive
Returnstrue
if this is an exclusive (or temporary exclusive) lock.- Returns:
true
if this is an exclusive (or temporary exclusive) lock
-
isExclusiveOwnedBy
Returnstrue
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner of this lock.- Parameters:
user
- the user to compare to the owner of this lock- Returns:
true
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner of this lock
-
isExclusiveOwnedInProjectBy
Returnstrue
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner and the given project is the project of this lock.- Parameters:
user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this lock- Returns:
true
if this is an exclusive (or temporary exclusive) lock, and the given user is the owner and the given project is the project of this lock
-
isInherited
Returnstrue
if this is an inherited lock, which may either be directly or shared inherited.- Returns:
true
if this is an inherited lock, which may either be directly or shared inherited
-
isInProject
Returnstrue
if the given project is the project of this lock.- Parameters:
project
- the project to compare to the project of this lock- Returns:
true
if the given project is the project of this lock
-
isLockableBy
Checks if a resource can be locked by a user.The resource is not lockable if it already has a lock of type
CmsLockType.PUBLISH
.The resource is lockable either - if it is currently unlocked - if it has a lock of another type set and the user is the lock owner
- Parameters:
user
- the user to test lockeability for- Returns:
true
if this lock blocks any operation on the locked resource until it is unlocked
-
isNullLock
Returnstrue
if this lock is theNULL
lock which can be obtained bygetNullLock()
.Only for the
NULL
lock,isUnlocked()
istrue
.- Returns:
true
if this lock is theNULL
lock
-
isOwnedBy
Returnstrue
if the given user is the owner of this lock.- Parameters:
user
- the user to compare to the owner of this lock- Returns:
true
if the given user is the owner of this lock
-
isOwnedInProjectBy
Returnstrue
if the given user is the owner of this lock, and this lock belongs to the given project.- Parameters:
user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this lock- Returns:
true
if the given user is the owner of this lock, and this lock belongs to the given project
-
isPersistent
Returnstrue
if this is a persistent lock that should be saved when the systems shuts down.- Returns:
true
if this is a persistent lock that should be saved when the systems shuts down
-
isPublish
Returnstrue
if this is a publish lock.- Returns:
true
if this is a publish lock
-
isSystemLock
Returnstrue
if this is a system (2nd level) lock.- Returns:
true
if this is a system (2nd level) lock
-
isTemporary
Returnstrue
if this is a temporary lock.- Returns:
true
if this is a temporary lock
-
isUnlocked
Returnstrue
if this lock is in fact unlocked.Only if this is
true
, the result lock is equal to theNULL
lock, which can be obtained bygetNullLock()
.- Returns:
true
if this lock is in fact unlocked
-
toString
Builds a string representation of the current state. -
clone
-
getRelatedLock
Returns the related Lock.- Returns:
- the related Lock
-
setRelatedLock
Sets the related Lock.- Parameters:
relatedLock
- the related Lock to set
-