org.opencms.lock
Class CmsLock

java.lang.Object
  extended byorg.opencms.lock.CmsLock
All Implemented Interfaces:
java.lang.Cloneable

public class CmsLock
extends java.lang.Object
implements java.lang.Cloneable

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.

Using old-style methods on CmsResource objects to prove the lock state of a resource may result to incorrect lock states. Use CmsObject.getLock(String) to obtain a CmsLock object that represents the current lock state of a resource.

Since:
6.0.0
Version:
$Revision: 1.28 $
Author:
Thomas Weckert, Andreas Zahner
See Also:
CmsObject.getLock(org.opencms.file.CmsResource), CmsLockManager

Field Summary
static int COMMON
          Indicates that the lock is a common lock and doesn't expire.
static int TEMPORARY
          Indicates that the lock is a temporary lock that expires is the user was logged out.
static int TYPE_EXCLUSIVE
          A lock that allows the user to edit the resource’s structure record, it’s resource record, and its content record.
static int TYPE_INHERITED
          A lock that is inherited from a locked parent folder.
static int TYPE_SHARED_EXCLUSIVE
          A lock that allows the user to edit the resource’s structure record only, but not it’s resource record nor content record.
static int TYPE_SHARED_INHERITED
          A lock that allows the user to edit the resource’s structure record only, but not it’s resource record nor content record.
static int TYPE_UNLOCKED
          Reserved for the Null CmsLock.
 
Constructor Summary
CmsLock(java.lang.String resourceName, CmsUUID userId, int projectId, int type)
          Constructor for a new Cms lock.
CmsLock(java.lang.String resourceName, CmsUUID userId, int projectId, int type, int mode)
          Constructor for a new Cms lock.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares this lock to the specified object.
 int getMode()
          Returns the mode of the lock to indicate if the lock is a temporary lock.
static CmsLock getNullLock()
          Returns the shared Null CmsLock.
 int getProjectId()
          Returns the ID of the project where the resource is currently locked.
 java.lang.String getResourceName()
          Returns the name of the locked resource.
 int 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 isNullLock()
          Proves if this CmsLock is the Null CmsLock.
 java.lang.String toString()
          Builds a string representation of the current state.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMON

public static final int COMMON
Indicates that the lock is a common lock and doesn't expire.

See Also:
Constant Field Values

TEMPORARY

public static final int TEMPORARY
Indicates that the lock is a temporary lock that expires is the user was logged out.

See Also:
Constant Field Values

TYPE_EXCLUSIVE

public static final int TYPE_EXCLUSIVE
A lock that allows the user to edit the resource’s structure record, it’s resource record, and its content record.

This lock is assigned to files that are locked via the context menu.

See Also:
Constant Field Values

TYPE_INHERITED

public static final int TYPE_INHERITED
A lock that is inherited from a locked parent folder.

See Also:
Constant Field Values

TYPE_SHARED_EXCLUSIVE

public static final int TYPE_SHARED_EXCLUSIVE
A lock that allows the user to edit the resource’s structure record only, but not it’s resource record nor content record.

This lock is assigned to files if a sibling of the resource record has already an exclusive lock.

See Also:
Constant Field Values

TYPE_SHARED_INHERITED

public static final int TYPE_SHARED_INHERITED
A lock that allows the user to edit the resource’s structure record only, but not it’s resource record nor content record.

This lock is assigned to resources that already have a shared exclusive lock, and then inherit a lock because one if it's parent folders gets locked.

See Also:
Constant Field Values

TYPE_UNLOCKED

public static final int TYPE_UNLOCKED
Reserved for the Null CmsLock.

See Also:
Constant Field Values
Constructor Detail

CmsLock

public CmsLock(java.lang.String resourceName,
               CmsUUID userId,
               int projectId,
               int type)
Constructor for a new Cms lock.

Parameters:
resourceName - the full resource name including the site root
userId - the ID of the user who locked the resource
projectId - the ID of the project where the resource is locked
type - flag indicating how the resource is locked

CmsLock

public CmsLock(java.lang.String resourceName,
               CmsUUID userId,
               int projectId,
               int type,
               int mode)
Constructor for a new Cms lock.

Parameters:
resourceName - the full resource name including the site root
userId - the ID of the user who locked the resource
projectId - the ID of the project where the resource is locked
type - flag indicating how the resource is locked
mode - flag indicating the mode (temporary or common) of a lock
Method Detail

getNullLock

public static CmsLock getNullLock()
Returns the shared Null CmsLock.

Returns:
the shared Null CmsLock

equals

public boolean equals(java.lang.Object obj)
Compares this lock to the specified object.

Parameters:
obj - the object to compare to
Returns:
true if and only if member values of this CmsLock are the same with the compared CmsLock

getMode

public int getMode()
Returns the mode of the lock to indicate if the lock is a temporary lock.

Returns:
the temporary mode of the lock

getProjectId

public int getProjectId()
Returns the ID of the project where the resource is currently locked.

Returns:
the ID of the project

getResourceName

public java.lang.String getResourceName()
Returns the name of the locked resource.

Returns:
the name of the locked resource

getType

public int getType()
Returns the type about how the resource is locked.

Returns:
the type of the lock

getUserId

public CmsUUID getUserId()
Returns the ID of the user who currently locked the resource.

Returns:
the ID of the user

hashCode

public int hashCode()
See Also:
Object.hashCode()

isNullLock

public boolean isNullLock()
Proves if this CmsLock is the Null CmsLock.

Returns:
true if and only if this CmsLock is the Null CmsLock

toString

public java.lang.String toString()
Builds a string representation of the current state.

See Also:
Object.toString()