org.alfresco.repo.avm.locking
Class AVMLockingServiceImpl

java.lang.Object
  extended by org.alfresco.repo.avm.locking.AVMLockingServiceImpl
All Implemented Interfaces:
AVMLockingService

public class AVMLockingServiceImpl
extends java.lang.Object
implements AVMLockingService

Implementation of the lock service.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.service.cmr.avm.locking.AVMLockingService
AVMLockingService.LockState
 
Field Summary
static java.lang.String KEY_AVM_LOCKS
           
static java.lang.String KEY_LOCK_OWNER
           
 
Constructor Summary
AVMLockingServiceImpl()
           
 
Method Summary
 java.util.Map getLockData(java.lang.String avmStore, java.lang.String path)
          Get the data associated with a lock
 java.lang.String getLockOwner(java.lang.String avmStore, java.lang.String path)
          Get the current holder of a lock on AVM store path
 AVMLockingService.LockState getLockState(java.lang.String avmStore, java.lang.String path, java.lang.String lockOwner)
          Get the state of a lock with respect to a given AVM store, path and user
 boolean hasAccess(org.alfresco.service.cmr.repository.NodeRef webProjectRef, java.lang.String avmPath, java.lang.String lockOwner)
          Is the user allowed to do anything to the given asset, other than read?
 boolean hasAccess(java.lang.String webProject, java.lang.String avmPath, java.lang.String lockOwner)
          Is the user allowed to do anything to the given asset, other than read?
 void lock(java.lang.String avmStore, java.lang.String path, java.lang.String lockOwner, java.util.Map lockData)
          Creates a lock of the given type on a path within an AVM store.
 boolean modifyLock(java.lang.String avmStore, java.lang.String path, java.lang.String lockOwner, java.lang.String newAvmStore, java.lang.String newPath, java.util.Map lockData)
          Modify a lock if it exists or do nothing if it doesn't.
static java.lang.String normalizePath(java.lang.String path)
          Utility to get relative paths into canonical lock form - remove first forward slash - multiple forward slashes collapsed into single foward slash
 void removeLock(java.lang.String avmStore, java.lang.String path)
          Remove a lock.
 void removeLocks(java.lang.String avmStore)
          Remove all locks for a specific AVM store
 void removeLocks(java.lang.String avmStore, java.util.Map lockDataToMatch)
          Remove all locks for a specific AVM store that also optionally match a map of lock data entries.
 void removeLocks(java.lang.String avmStore, java.lang.String dirPath, java.util.Map lockDataToMatch)
          Remove all locks for a specific AVM store that start with a given directory path that also optionally match a map of lock data entries.
 void setAttributeService(AttributeService attributeService)
           
 void setAuthorityService(AuthorityService authorityService)
           
 void setAvmLockDAO(AVMLockDAO avmLockDAO)
           
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
           
 void setPersonService(PersonService personService)
           
 void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
           
 void setWebProjectStore(java.lang.String webProjectStore)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_AVM_LOCKS

public static final java.lang.String KEY_AVM_LOCKS
See Also:
Constant Field Values

KEY_LOCK_OWNER

public static final java.lang.String KEY_LOCK_OWNER
See Also:
Constant Field Values
Constructor Detail

AVMLockingServiceImpl

public AVMLockingServiceImpl()
Method Detail

setWebProjectStore

public void setWebProjectStore(java.lang.String webProjectStore)
Parameters:
webProjectStore - The webProjectStore to set

setAttributeService

public void setAttributeService(AttributeService attributeService)
Parameters:
attributeService - the service to persist attributes

setAuthorityService

public void setAuthorityService(AuthorityService authorityService)
Parameters:
authorityService - the service to check validity of usernames

setPersonService

public void setPersonService(PersonService personService)
Parameters:
personService - checks validity of person names

setSearchService

public void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)

setNodeService

public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)

setAvmLockDAO

public void setAvmLockDAO(AVMLockDAO avmLockDAO)

lock

public void lock(java.lang.String avmStore,
                 java.lang.String path,
                 java.lang.String lockOwner,
                 java.util.Map lockData)
Creates a lock of the given type on a path within an AVM store.

Specified by:
lock in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
path - the relative path of the lock
lockOwner - the user taking the lock
lockData - additional data to append to the lock

modifyLock

public boolean modifyLock(java.lang.String avmStore,
                          java.lang.String path,
                          java.lang.String lockOwner,
                          java.lang.String newAvmStore,
                          java.lang.String newPath,
                          java.util.Map lockData)
Modify a lock if it exists or do nothing if it doesn't. The user supplied must already hold the lock if it exists.

Specified by:
modifyLock in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
path - the relative path of the lock
lockOwner - the user taking the lock and who must also own the existing lock
newAvmStore - the name of the new AVM store
newPath - the new relative path of the lock
lockData - the new additional data to append to the lock
Returns:
true if the lock was modified or false if no lock existed

getLockOwner

public java.lang.String getLockOwner(java.lang.String avmStore,
                                     java.lang.String path)
Get the current holder of a lock on AVM store path

Specified by:
getLockOwner in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
path - the relative path of the lock
Returns:
Returns the user holding the lock or null

getLockData

public java.util.Map getLockData(java.lang.String avmStore,
                                 java.lang.String path)
Get the data associated with a lock

Specified by:
getLockData in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
path - the relative path of the lock
Returns:
the state of the lock with respect to the given user

getLockState

public AVMLockingService.LockState getLockState(java.lang.String avmStore,
                                                java.lang.String path,
                                                java.lang.String lockOwner)
Get the state of a lock with respect to a given AVM store, path and user

Specified by:
getLockState in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
path - the relative path of the lock
lockOwner - the user who might own the lock
Returns:
the state of the lock with respect to the given user

removeLock

public void removeLock(java.lang.String avmStore,
                       java.lang.String path)
Remove a lock.

Specified by:
removeLock in interface AVMLockingService
path - the relative path of the lock

removeLocks

public void removeLocks(java.lang.String avmStore)
Remove all locks for a specific AVM store

Specified by:
removeLocks in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store

removeLocks

public void removeLocks(java.lang.String avmStore,
                        java.lang.String dirPath,
                        java.util.Map lockDataToMatch)
Remove all locks for a specific AVM store that start with a given directory path that also optionally match a map of lock data entries.

Specified by:
removeLocks in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
dirPath - optional - start with given directory path or null to match all
lockDataToMatch - optional - lock data to match (note: all entries must match) or null/empty to match all

removeLocks

public void removeLocks(java.lang.String avmStore,
                        java.util.Map lockDataToMatch)
Remove all locks for a specific AVM store that also optionally match a map of lock data entries.

Specified by:
removeLocks in interface AVMLockingService
Parameters:
avmStore - the name of the AVM store
lockDataToMatch - optional - lock data to match (note: all entries must match) or null/empty to match all

hasAccess

public boolean hasAccess(java.lang.String webProject,
                         java.lang.String avmPath,
                         java.lang.String lockOwner)
Is the user allowed to do anything to the given asset, other than read?

Specified by:
hasAccess in interface AVMLockingService
Parameters:
webProject - the name of the WCM project
lockOwner - the user to check
Returns:
true if the user has access (either holds the lock or there is no lock, etc)

hasAccess

public boolean hasAccess(org.alfresco.service.cmr.repository.NodeRef webProjectRef,
                         java.lang.String avmPath,
                         java.lang.String lockOwner)
Is the user allowed to do anything to the given asset, other than read?

Specified by:
hasAccess in interface AVMLockingService
Parameters:
webProjectRef - the name of the WCM project
lockOwner - the user to check
Returns:
true if the user has access (either holds the lock or there is no lock, etc)

normalizePath

public static java.lang.String normalizePath(java.lang.String path)
Utility to get relative paths into canonical lock form - remove first forward slash - multiple forward slashes collapsed into single foward slash

Parameters:
path - The incoming path.
Returns:
The normalized path.


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.