public class CmsLock extends java.lang.Object implements java.lang.Comparable<CmsLock>
The lock state is combination of how, by whom and in which project a resource is currently locked.
CmsObject.getLock(org.opencms.file.CmsResource)
,
CmsLockManager
Constructor and Description |
---|
CmsLock(java.lang.String resourceName,
CmsUUID userId,
CmsProject project,
CmsLockType type)
Constructor for a new Cms lock.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
clone() |
int |
compareTo(CmsLock other) |
boolean |
equals(java.lang.Object obj)
Compares this lock to the specified object.
|
CmsLock |
getEditionLock()
Returns the edition lock.
|
static CmsLock |
getNullLock()
Returns the shared Null CmsLock.
|
CmsProject |
getProject()
Returns the project where the resource is currently locked.
|
CmsUUID |
getProjectId()
Returns the ID of the project where the resource is currently locked.
|
protected CmsLock |
getRelatedLock()
Returns the related Lock.
|
java.lang.String |
getResourceName()
Returns the name of the locked resource.
|
CmsLock |
getSystemLock()
Returns the system lock.
|
CmsLockType |
getType()
Returns the type about how the resource is locked.
|
CmsUUID |
getUserId()
Returns the ID of the user who currently locked the resource.
|
int |
hashCode() |
boolean |
isDirectlyInherited()
Returns
true if this is an directly inherited lock. |
boolean |
isDirectlyOwnedBy(CmsUser user)
Returns
true if this is an exclusive, temporary exclusive, or
directly inherited lock, and the given user is the owner of this lock. |
boolean |
isDirectlyOwnedInProjectBy(CmsObject cms)
Returns
true 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)
Returns
true 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 |
isExclusive()
Returns
true if this is an exclusive (or temporary exclusive) lock. |
boolean |
isExclusiveOwnedBy(CmsUser user)
Returns
true 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)
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. |
boolean |
isInherited()
Returns
true if this is an inherited lock, which may either be directly or shared inherited. |
boolean |
isInProject(CmsProject project)
Returns
true 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 |
isNullLock()
|
boolean |
isOwnedBy(CmsUser user)
Returns
true if the given user is the owner of this lock. |
boolean |
isOwnedInProjectBy(CmsUser user,
CmsProject project)
Returns
true if the given user is the owner of this lock,
and this lock belongs to the given project. |
boolean |
isPersistent()
Returns
true if this is a persistent lock that should be saved when the systems shuts down. |
boolean |
isPublish()
Returns
true if this is a publish lock. |
boolean |
isShared()
Returns
true if this is a shared lock. |
boolean |
isSystemLock()
Returns
true if this is a system (2nd level) lock. |
boolean |
isTemporary()
Returns
true if this is a temporary lock. |
boolean |
isUnlocked()
Returns
true if this lock is in fact unlocked. |
protected void |
setRelatedLock(CmsLock relatedLock)
Sets the related Lock.
|
java.lang.String |
toString()
Builds a string representation of the current state.
|
public CmsLock(java.lang.String resourceName, CmsUUID userId, CmsProject project, CmsLockType type)
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 lockedpublic static CmsLock getNullLock()
public int compareTo(CmsLock other)
compareTo
in interface java.lang.Comparable<CmsLock>
Comparable.compareTo(java.lang.Object)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare topublic CmsLock getEditionLock()
public CmsProject getProject()
public CmsUUID getProjectId()
public java.lang.String getResourceName()
public CmsLock getSystemLock()
public CmsLockType getType()
public CmsUUID getUserId()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean isDirectlyInherited()
true
if this is an directly inherited lock.true
if this is an directly inherited lockpublic boolean isDirectlyOwnedBy(CmsUser user)
true
if this is an exclusive, temporary exclusive, or
directly inherited lock, and the given user is the owner of this lock.user
- the user to compare to the owner of this locktrue
if this is an exclusive, temporary exclusive, or
directly inherited lock, and the given user is the owner of this lockpublic boolean isDirectlyOwnedInProjectBy(CmsObject cms)
true
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.cms
- the CMS context to checktrue
if this is an exclusive, temporary exclusive, or
directly inherited lock, and the current user is the owner of this lockpublic boolean isDirectlyOwnedInProjectBy(CmsUser user, CmsProject project)
true
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.user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this locktrue
if this is an exclusive, temporary exclusive, or
directly inherited lock, and the given user is the owner of this lockpublic boolean isExclusive()
true
if this is an exclusive (or temporary exclusive) lock.true
if this is an exclusive (or temporary exclusive) lockpublic boolean isExclusiveOwnedBy(CmsUser user)
true
if this is an exclusive (or temporary exclusive) lock,
and the given user is the owner of this lock.user
- the user to compare to the owner of this locktrue
if this is an exclusive (or temporary exclusive) lock,
and the given user is the owner of this lockpublic boolean isExclusiveOwnedInProjectBy(CmsUser user, CmsProject project)
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.user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this locktrue
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 lockpublic boolean isInherited()
true
if this is an inherited lock, which may either be directly or shared inherited.true
if this is an inherited lock, which may either be directly or shared inheritedpublic boolean isInProject(CmsProject project)
true
if the given project is the project of this lock.project
- the project to compare to the project of this locktrue
if the given project is the project of this lockpublic boolean isLockableBy(CmsUser 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
user
- the user to test lockeability fortrue
if this lock blocks any operation on the locked resource until it is unlockedpublic boolean isNullLock()
true
if this lock is the NULL
lock which can
be obtained by getNullLock()
.
Only for the NULL
lock, isUnlocked()
is true
.
true
if this lock is the NULL
lockpublic boolean isOwnedBy(CmsUser user)
true
if the given user is the owner of this lock.user
- the user to compare to the owner of this locktrue
if the given user is the owner of this lockpublic boolean isOwnedInProjectBy(CmsUser user, CmsProject project)
true
if the given user is the owner of this lock,
and this lock belongs to the given project.user
- the user to compare to the owner of this lockproject
- the project to compare to the project of this locktrue
if the given user is the owner of this lock,
and this lock belongs to the given projectpublic boolean isPersistent()
true
if this is a persistent lock that should be saved when the systems shuts down.true
if this is a persistent lock that should be saved when the systems shuts downpublic boolean isPublish()
true
if this is a publish lock.true
if this is a publish lockpublic boolean isShared()
true
if this is a shared lock.true
if this is a shared lockpublic boolean isSystemLock()
true
if this is a system (2nd level) lock.true
if this is a system (2nd level) lockpublic boolean isTemporary()
true
if this is a temporary lock.true
if this is a temporary lockpublic boolean isUnlocked()
true
if this lock is in fact unlocked.
Only if this is true
, the result lock is equal to the NULL
lock,
which can be obtained by getNullLock()
.
true
if this lock is in fact unlockedpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
protected java.lang.Object clone()
clone
in class java.lang.Object
Object.clone()
protected CmsLock getRelatedLock()
protected void setRelatedLock(CmsLock relatedLock)
relatedLock
- the related Lock to set