|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.lock.CmsLockManager
public final class CmsLockManager
The CmsLockManager is used by the Cms application to detect the lock state of a resource.
The lock state depends on the path of the resource, and probably locked parent folders. The result of a query to the lock manager are instances of CmsLock objects.
CmsObject.getLock(CmsResource)
,
CmsLock
Constructor Summary | |
---|---|
CmsLockManager(CmsDriverManager driverManager)
Default constructor, creates a new lock manager. |
Method Summary | |
---|---|
void |
addResource(CmsDbContext dbc,
CmsResource resource,
CmsUser user,
CmsProject project,
CmsLockType type)
Adds a resource to the lock manager. |
int |
countExclusiveLocksInProject(CmsProject project)
Counts the exclusive locked resources in a project. |
CmsLock |
getLock(CmsDbContext dbc,
CmsResource resource)
Returns the lock state of the given resource. |
CmsLock |
getLock(CmsDbContext dbc,
CmsResource resource,
boolean includeSiblings)
Returns the lock state of the given resource. |
java.util.List |
getLocks(CmsDbContext dbc,
java.lang.String resourceName,
CmsLockFilter filter)
Returns all exclusive locked resources matching the given resource name and filter. |
boolean |
hasSystemLocks(CmsDbContext dbc,
CmsResource resource)
Returns true if the given resource contains a resource that has a system lock. |
void |
moveResource(java.lang.String source,
java.lang.String destination)
Moves a lock during the move resource operation. |
void |
readLocks(CmsDbContext dbc)
Reads the latest saved locks from the database and installs them to this lock manager. |
void |
removeDeletedResource(CmsDbContext dbc,
java.lang.String resourceName)
Removes a resource after it has been deleted by the driver manager. |
void |
removeLocks(CmsUUID userId)
Removes all locks of a user. |
CmsLock |
removeResource(CmsDbContext dbc,
CmsResource resource,
boolean forceUnlock,
boolean removeSystemLock)
Removes a resource from the lock manager. |
void |
removeResourcesInProject(CmsUUID projectId,
boolean removeSystemLocks)
Removes all resources locked in a project. |
void |
removeTempLocks(CmsUUID userId)
Removes all exclusive temporary locks of a user. |
java.lang.String |
toString()
|
void |
writeLocks(CmsDbContext dbc)
Writes the locks that are currently stored in-memory to the database to allow restoring them in later startups. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CmsLockManager(CmsDriverManager driverManager)
driverManager
- the driver manager instanceMethod Detail |
---|
public void addResource(CmsDbContext dbc, CmsResource resource, CmsUser user, CmsProject project, CmsLockType type) throws CmsLockException, CmsException
dbc
- the current database contextresource
- the resourceuser
- the user who locked the resourceproject
- the project where the resource is lockedtype
- the lock type
CmsLockException
- if the resource is locked
CmsException
- if something goes wrongpublic int countExclusiveLocksInProject(CmsProject project)
project
- the project
public CmsLock getLock(CmsDbContext dbc, CmsResource resource) throws CmsException
In case no lock is set, the null lock
which can be obtained
by CmsLock.getNullLock()
is returned.
dbc
- the current database contextresource
- the resource
CmsException
- if something goes wrongpublic CmsLock getLock(CmsDbContext dbc, CmsResource resource, boolean includeSiblings) throws CmsException
In case no lock is set, the null lock
which can be obtained
by CmsLock.getNullLock()
is returned.
dbc
- the current database contextresource
- the resourceincludeSiblings
- if siblings (shared locks) should be included in the search
CmsException
- if something goes wrongpublic java.util.List getLocks(CmsDbContext dbc, java.lang.String resourceName, CmsLockFilter filter) throws CmsException
dbc
- the database contextresourceName
- the resource namefilter
- the lock filter
CmsException
- if something goes wrongpublic boolean hasSystemLocks(CmsDbContext dbc, CmsResource resource) throws CmsException
true
if the given resource contains a resource that has a system lock.This check is required for certain operations on folders.
dbc
- the database contextresource
- the resource to check the system locks for
true
if the given resource contains a resource that has a system lock
CmsException
- if something goes wrongpublic void moveResource(java.lang.String source, java.lang.String destination)
source
- the source root pathdestination
- the destination root pathpublic void readLocks(CmsDbContext dbc) throws CmsException
dbc
- the current database context
CmsException
- if something goes wrongpublic void removeDeletedResource(CmsDbContext dbc, java.lang.String resourceName) throws CmsException
dbc
- the current database contextresourceName
- the root path of the deleted resource
CmsException
- if something goes wrongpublic void removeLocks(CmsUUID userId)
Edition and system locks are removed.
userId
- the id of the user whose locks should be removedpublic CmsLock removeResource(CmsDbContext dbc, CmsResource resource, boolean forceUnlock, boolean removeSystemLock) throws CmsException
The forceUnlock option should be used with caution.
forceUnlock will remove the lock by ignoring any rules which may cause wrong lock states.
dbc
- the current database contextresource
- the resourceforceUnlock
- true
, if a resource is forced to get unlocked (only edition locks),
no matter by which user and in which project the resource is currently lockedremoveSystemLock
- true
, if you also want to remove system locks
CmsLock
object of the resource,
or CmsLock.getNullLock()
if the resource was unlocked
CmsException
- if something goes wrongpublic void removeResourcesInProject(CmsUUID projectId, boolean removeSystemLocks)
projectId
- the ID of the project where the resources have been lockedremoveSystemLocks
- if true
, also system locks are removedpublic void removeTempLocks(CmsUUID userId)
Only edition lock can be temporary, so no system locks are removed.
userId
- the id of the user whose locks has to be removedpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public void writeLocks(CmsDbContext dbc) throws CmsException
This overwrites the locks previously stored in the underlying database table.
dbc
- the current database context
CmsException
- if something goes wrong
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |