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
ConstructorsConstructorDescriptionCmsLock(String resourceName, CmsUUID userId, CmsProject project, CmsLockType type) Constructor for a new Cms lock. -
Method Summary
Modifier and TypeMethodDescriptionprotected Objectclone()intbooleanCompares this lock to the specified object.Returns the edition lock.static CmsLockReturns 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 CmsLockReturns 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.inthashCode()booleanReturnstrueif this is an directly inherited lock.booleanisDirectlyOwnedBy(CmsUser user) Returnstrueif this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock.booleanReturnstrueif 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.booleanisDirectlyOwnedInProjectBy(CmsUser user, CmsProject project) Returnstrueif 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.booleanReturnstrueif this is an exclusive (or temporary exclusive) lock.booleanisExclusiveOwnedBy(CmsUser user) Returnstrueif this is an exclusive (or temporary exclusive) lock, and the given user is the owner of this lock.booleanisExclusiveOwnedInProjectBy(CmsUser user, CmsProject project) Returnstrueif 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.booleanReturnstrueif this is an inherited lock, which may either be directly or shared inherited.booleanisInProject(CmsProject project) Returnstrueif the given project is the project of this lock.booleanisLockableBy(CmsUser user) Checks if a resource can be locked by a user.booleanbooleanReturnstrueif the given user is the owner of this lock.booleanisOwnedInProjectBy(CmsUser user, CmsProject project) Returnstrueif the given user is the owner of this lock, and this lock belongs to the given project.booleanReturnstrueif this is a persistent lock that should be saved when the systems shuts down.booleanReturnstrueif this is a publish lock.booleanisShared()Returnstrueif this is a shared lock.booleanReturnstrueif this is a system (2nd level) lock.booleanReturnstrueif this is a temporary lock.booleanReturnstrueif this lock is in fact unlocked.protected voidsetRelatedLock(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:
compareToin 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
Returnstrueif this is an directly inherited lock.- Returns:
trueif this is an directly inherited lock
-
isDirectlyOwnedBy
Returnstrueif 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:
trueif this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock
-
isDirectlyOwnedInProjectBy
Returnstrueif 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:
trueif this is an exclusive, temporary exclusive, or directly inherited lock, and the current user is the owner of this lock
-
isDirectlyOwnedInProjectBy
Returnstrueif 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:
trueif this is an exclusive, temporary exclusive, or directly inherited lock, and the given user is the owner of this lock
-
isExclusive
Returnstrueif this is an exclusive (or temporary exclusive) lock.- Returns:
trueif this is an exclusive (or temporary exclusive) lock
-
isExclusiveOwnedBy
Returnstrueif 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:
trueif this is an exclusive (or temporary exclusive) lock, and the given user is the owner of this lock
-
isExclusiveOwnedInProjectBy
Returnstrueif 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:
trueif 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
Returnstrueif this is an inherited lock, which may either be directly or shared inherited.- Returns:
trueif this is an inherited lock, which may either be directly or shared inherited
-
isInProject
Returnstrueif the given project is the project of this lock.- Parameters:
project- the project to compare to the project of this lock- Returns:
trueif 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:
trueif this lock blocks any operation on the locked resource until it is unlocked
-
isNullLock
Returnstrueif this lock is theNULLlock which can be obtained bygetNullLock().Only for the
NULLlock,isUnlocked()istrue.- Returns:
trueif this lock is theNULLlock
-
isOwnedBy
Returnstrueif the given user is the owner of this lock.- Parameters:
user- the user to compare to the owner of this lock- Returns:
trueif the given user is the owner of this lock
-
isOwnedInProjectBy
Returnstrueif 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:
trueif the given user is the owner of this lock, and this lock belongs to the given project
-
isPersistent
Returnstrueif this is a persistent lock that should be saved when the systems shuts down.- Returns:
trueif this is a persistent lock that should be saved when the systems shuts down
-
isPublish
Returnstrueif this is a publish lock.- Returns:
trueif this is a publish lock
-
isSystemLock
Returnstrueif this is a system (2nd level) lock.- Returns:
trueif this is a system (2nd level) lock
-
isTemporary
Returnstrueif this is a temporary lock.- Returns:
trueif this is a temporary lock
-
isUnlocked
Returnstrueif this lock is in fact unlocked.Only if this is
true, the result lock is equal to theNULLlock, which can be obtained bygetNullLock().- Returns:
trueif 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
-