org.alfresco.repo.lock
Class LockServiceImpl

java.lang.Object
  extended by org.alfresco.repo.lock.LockServiceImpl
All Implemented Interfaces:
CopyServicePolicies.OnCopyNodePolicy, NodeServicePolicies.BeforeCreateChildAssociationPolicy, NodeServicePolicies.BeforeDeleteNodePolicy, NodeServicePolicies.BeforeUpdateNodePolicy, AssociationPolicy, ClassPolicy, Policy, VersionServicePolicies.BeforeCreateVersionPolicy, VersionServicePolicies.OnCreateVersionPolicy, LockService

public class LockServiceImpl
extends java.lang.Object
implements LockService, NodeServicePolicies.BeforeCreateChildAssociationPolicy, NodeServicePolicies.BeforeUpdateNodePolicy, NodeServicePolicies.BeforeDeleteNodePolicy, CopyServicePolicies.OnCopyNodePolicy, VersionServicePolicies.BeforeCreateVersionPolicy, VersionServicePolicies.OnCreateVersionPolicy

Simple Lock service implementation


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.alfresco.repo.policy.Policy
Policy.Arg
 
Field Summary
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeCreateChildAssociationPolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeUpdateNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy
QNAME
 
Fields inherited from interface org.alfresco.repo.copy.CopyServicePolicies.OnCopyNodePolicy
ARG_0, ARG_1, QNAME
 
Fields inherited from interface org.alfresco.repo.policy.Policy
NAMESPACE
 
Constructor Summary
LockServiceImpl()
           
 
Method Summary
 void beforeCreateChildAssociation(org.alfresco.service.cmr.repository.NodeRef parentNodeRef, org.alfresco.service.cmr.repository.NodeRef childNodeRef, org.alfresco.service.namespace.QName assocTypeQName, org.alfresco.service.namespace.QName assocQName, boolean isNewNode)
          Ensures that the parent is not locked.
 void beforeCreateVersion(org.alfresco.service.cmr.repository.NodeRef versionableNode)
          Ensures that node is not locked.
 void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Ensures that node is not locked.
 void beforeUpdateNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Ensures that node is not locked.
 void checkForLock(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Checks to see if the node is locked or not.
 CopyBehaviourCallback getCopyCallback(org.alfresco.service.namespace.QName classRef, CopyDetails copyDetails)
          Called for all types and aspects before copying a node.
 java.util.List getLocks(org.alfresco.service.cmr.repository.StoreRef storeRef)
          Get all the node references that the current user has locked.
 java.util.List getLocks(org.alfresco.service.cmr.repository.StoreRef storeRef, LockType lockType)
          Get all the node references that the current user has locked filtered by the provided lock type.
 LockStatus getLockStatus(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Gets the lock status for the node reference relative to the current user.
 LockStatus getLockStatus(org.alfresco.service.cmr.repository.NodeRef nodeRef, java.lang.String userName)
          Gets the lock status for a node and a user name
 LockType getLockType(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Gets the lock type for the node indicated.
 void init()
          Initialise methods called by Spring framework
 void lock(java.util.Collection nodeRefs, LockType lockType, int timeToExpire)
          Places a lock on all the nodes referenced in the passed list.
 void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef, LockType lockType)
          Places a lock on a node.
 void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef, LockType lockType, int timeToExpire)
          Places a lock on a node.
 void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef, LockType lockType, int timeToExpire, boolean lockChildren)
          Places a lock on a node and optionally on all its children.
 void onCreateVersion(org.alfresco.service.namespace.QName classRef, org.alfresco.service.cmr.repository.NodeRef versionableNode, java.util.Map versionProperties, PolicyScope nodeDetails)
          OnCreateVersion behaviour for the lock aspect
 void setAuthenticationService(AuthenticationService authenticationService)
          Sets the authentication service
 void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
          Set the node service
 void setOwnableService(OwnableService ownableService)
          Sets the ownable service
 void setPolicyComponent(PolicyComponent policyComponent)
          Sets the policy component
 void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
          Set the search service
 void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
          Set the tenant service
 void unlock(java.util.Collection nodeRefs)
          Removes a lock on the nodes provided.
 void unlock(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Removes the lock on a node.
 void unlock(org.alfresco.service.cmr.repository.NodeRef nodeRef, boolean unlockChildren)
          Removes the lock on a node and optional on its children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockServiceImpl

public LockServiceImpl()
Method Detail

setNodeService

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

Parameters:
nodeService - the node service

setTenantService

public void setTenantService(org.alfresco.repo.tenant.TenantService tenantService)
Set the tenant service

Parameters:
tenantService - the tenant service

setPolicyComponent

public void setPolicyComponent(PolicyComponent policyComponent)
Sets the policy component

Parameters:
policyComponent - the policy componentO

setAuthenticationService

public void setAuthenticationService(AuthenticationService authenticationService)
Sets the authentication service

Parameters:
authenticationService - the authentication service

setOwnableService

public void setOwnableService(OwnableService ownableService)
Sets the ownable service

Parameters:
ownableService - the ownable service

setSearchService

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

Parameters:
searchService - the search service

init

public void init()
Initialise methods called by Spring framework


lock

public void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                 LockType lockType)
Description copied from interface: LockService
Places a lock on a node.

The lock prevents any other user or process from comitting updates to the node until the lock is released.

The lock will be owned by the current user.

A lock made with this call will never expire.

Specified by:
lock in interface LockService
Parameters:
nodeRef - a reference to a node
lockType - the lock type
See Also:
org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.cmr.lock.LockType)

lock

public void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                 LockType lockType,
                 int timeToExpire)
Description copied from interface: LockService
Places a lock on a node.

The lock prevents any other user or process from comitting updates to the node until the lock is released.

The lock will be owned by the current user.

If the time to expire is 0 then the lock will never expire. Otherwise the timeToExpire indicates the number of seconds before the lock expires. When a lock expires the lock is considered to have been released.

If the node is already locked and the user is the lock owner then the lock will be renewed with the passed timeToExpire.

Specified by:
lock in interface LockService
Parameters:
nodeRef - a reference to a node
lockType - the lock type
timeToExpire - the number of seconds before the locks expires.
See Also:
org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.cmr.lock.LockType, int)

lock

public void lock(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                 LockType lockType,
                 int timeToExpire,
                 boolean lockChildren)
          throws UnableToAquireLockException
Description copied from interface: LockService
Places a lock on a node and optionally on all its children.

The lock prevents any other user or process from comitting updates to the node until the lock is released.

The lock will be owned by the current user.

If any one of the child locks can not be taken then an exception will be raised and all locks canceled.

If the time to expire is 0 then the lock will never expire. Otherwise the timeToExpire indicates the number of seconds before the lock expires. When a lock expires the lock is considered to have been released.

If the node is already locked and the user is the lock owner then the lock will be renewed with the passed timeToExpire.

Specified by:
lock in interface LockService
Parameters:
nodeRef - a reference to a node
lockType - the lock type
timeToExpire - the number of seconds before the locks expires.
lockChildren - if true indicates that all the children (and grandchildren, etc) of the node will also be locked, false otherwise
Throws:
UnableToAquireLockException - thrown if the lock could not be obtained
See Also:
org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, org.alfresco.service.cmr.lock.LockType, int, boolean)

lock

public void lock(java.util.Collection nodeRefs,
                 LockType lockType,
                 int timeToExpire)
          throws UnableToAquireLockException
Description copied from interface: LockService
Places a lock on all the nodes referenced in the passed list.

The lock prevents any other user or process from comitting updates to the node until the lock is released.

The lock will be owned by the current user.

If the time to expire is 0 then the lock will never expire. Otherwise the timeToExpire indicates the number of seconds before the lock expires. When a lock expires the lock is considered to have been released.

If the node is already locked and the current user is the lock owner then the lock will be renewed with the passed timeToExpire.

Specified by:
lock in interface LockService
Parameters:
nodeRefs - a list of node references
lockType - the type of lock being created
timeToExpire - the number of seconds before the locks expires.
Throws:
UnableToAquireLockException - thrown if the lock could not be obtained
See Also:
org.alfresco.service.cmr.lock.LockService#lock(java.util.Collection, java.lang.String, org.alfresco.service.cmr.lock.LockType, int)

unlock

public void unlock(org.alfresco.service.cmr.repository.NodeRef nodeRef)
            throws UnableToReleaseLockException
Description copied from interface: LockService
Removes the lock on a node.

The user must have sufficient permissions to remove the lock (ie: be the owner of the lock or have admin rights) otherwise an exception will be raised.

Specified by:
unlock in interface LockService
Parameters:
nodeRef - a reference to a node
Throws:
UnableToReleaseLockException - thrown if the lock could not be released
See Also:
org.alfresco.service.cmr.lock.LockService#unlock(NodeRef, String)

unlock

public void unlock(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                   boolean unlockChildren)
            throws UnableToReleaseLockException
Description copied from interface: LockService
Removes the lock on a node and optional on its children.

The user must have sufficient permissions to remove the lock(s) (ie: be the owner of the lock(s) or have admin rights) otherwise an exception will be raised.

If one of the child nodes is not locked then it will be ignored and the process continue without error.

If the lock on any one of the child nodes cannot be released then an exception will be raised.

Specified by:
unlock in interface LockService
Parameters:
nodeRef - a node reference
unlockChildren - if true then all the children (and grandchildren, etc) of the node will also be unlocked, false otherwise
Throws:
UnableToReleaseLockException - thrown if the lock could not be released
See Also:
org.alfresco.service.cmr.lock.LockService#unlock(NodeRef, String, boolean)

unlock

public void unlock(java.util.Collection nodeRefs)
            throws UnableToReleaseLockException
Description copied from interface: LockService
Removes a lock on the nodes provided.

The user must have sufficient permissions to remove the locks (ie: be the owner of the locks or have admin rights) otherwise an exception will be raised.

If one of the nodes is not locked then it will be ignored and the process will continue without an error.

If the lock on any one of the nodes cannot be released than an exception will be raised and the process rolled back.

Specified by:
unlock in interface LockService
Parameters:
nodeRefs - the node references
Throws:
UnableToReleaseLockException - thrown if the lock could not be released
See Also:
org.alfresco.repo.lock.LockService#unlock(Collection, String)

getLockStatus

public LockStatus getLockStatus(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: LockService
Gets the lock status for the node reference relative to the current user.

Specified by:
getLockStatus in interface LockService
Parameters:
nodeRef - the node reference
Returns:
the lock status
See Also:
LockService.getLockStatus(NodeRef)

getLockStatus

public LockStatus getLockStatus(org.alfresco.service.cmr.repository.NodeRef nodeRef,
                                java.lang.String userName)
Gets the lock status for a node and a user name

Specified by:
getLockStatus in interface LockService
Parameters:
nodeRef - the node reference
userName - the user name
Returns:
the lock status
See Also:
LockService#getLockStatus(NodeRef, NodeRef)

getLockType

public LockType getLockType(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: LockService
Gets the lock type for the node indicated.

Returns null if the node is not locked.

Throws an exception if the node does not have the lock aspect.

Specified by:
getLockType in interface LockService
Parameters:
nodeRef - the node reference
Returns:
the lock type, null is returned if the object in question has no lock
See Also:
LockService.getLockType(NodeRef)

checkForLock

public void checkForLock(org.alfresco.service.cmr.repository.NodeRef nodeRef)
                  throws NodeLockedException
Checks to see if the node is locked or not. Gets the user reference from the current session.

Specified by:
checkForLock in interface LockService
Parameters:
nodeRef - the node reference
Throws:
NodeLockedException - thrown if the node is locked. This is based on the lock status of the lock, the user ref and the lock type.

beforeCreateChildAssociation

public void beforeCreateChildAssociation(org.alfresco.service.cmr.repository.NodeRef parentNodeRef,
                                         org.alfresco.service.cmr.repository.NodeRef childNodeRef,
                                         org.alfresco.service.namespace.QName assocTypeQName,
                                         org.alfresco.service.namespace.QName assocQName,
                                         boolean isNewNode)
Ensures that the parent is not locked.

Specified by:
beforeCreateChildAssociation in interface NodeServicePolicies.BeforeCreateChildAssociationPolicy
Parameters:
parentNodeRef - the parent node reference
childNodeRef - the child node reference
assocTypeQName - the type of the association
assocQName - the name of the association
isNewNode - true if the node is new or false if the node is being linked in
See Also:
LockServiceImpl.checkForLock(NodeRef)

beforeUpdateNode

public void beforeUpdateNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Ensures that node is not locked.

Specified by:
beforeUpdateNode in interface NodeServicePolicies.BeforeUpdateNodePolicy
Parameters:
nodeRef - reference to the node being updated
See Also:
LockServiceImpl.checkForLock(NodeRef)

beforeDeleteNode

public void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Ensures that node is not locked.

Specified by:
beforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicy
Parameters:
nodeRef - the node reference
See Also:
LockServiceImpl.checkForLock(NodeRef)

getCopyCallback

public CopyBehaviourCallback getCopyCallback(org.alfresco.service.namespace.QName classRef,
                                             CopyDetails copyDetails)
Description copied from interface: CopyServicePolicies.OnCopyNodePolicy
Called for all types and aspects before copying a node.

Specified by:
getCopyCallback in interface CopyServicePolicies.OnCopyNodePolicy
Parameters:
classRef - the type or aspect qualified name
copyDetails - the details of the impending copy
Returns:
Returns LockableAspectCopyBehaviourCallback
See Also:
CopyServicePolicies

beforeCreateVersion

public void beforeCreateVersion(org.alfresco.service.cmr.repository.NodeRef versionableNode)
Ensures that node is not locked.

Specified by:
beforeCreateVersion in interface VersionServicePolicies.BeforeCreateVersionPolicy
Parameters:
versionableNode - reference to the node about to be versioned
See Also:
LockServiceImpl.checkForLock(NodeRef)

onCreateVersion

public void onCreateVersion(org.alfresco.service.namespace.QName classRef,
                            org.alfresco.service.cmr.repository.NodeRef versionableNode,
                            java.util.Map versionProperties,
                            PolicyScope nodeDetails)
OnCreateVersion behaviour for the lock aspect

Ensures that the property values of the lock aspect are not 'frozen' in the version store.

Specified by:
onCreateVersion in interface VersionServicePolicies.OnCreateVersionPolicy
Parameters:
classRef - the class reference
versionableNode - the versionable node reference
versionProperties - the version properties
nodeDetails - the details of the node to be versioned

getLocks

public java.util.List getLocks(org.alfresco.service.cmr.repository.StoreRef storeRef)
Description copied from interface: LockService
Get all the node references that the current user has locked.

Specified by:
getLocks in interface LockService
Parameters:
storeRef - the store reference
Returns:
a list of nodes that the current user has locked.
See Also:
org.alfresco.service.cmr.lock.LockService#getLocks()

getLocks

public java.util.List getLocks(org.alfresco.service.cmr.repository.StoreRef storeRef,
                               LockType lockType)
Description copied from interface: LockService
Get all the node references that the current user has locked filtered by the provided lock type.

Specified by:
getLocks in interface LockService
Parameters:
storeRef - the store reference
lockType - the lock type to filter the results by
Returns:
a list of nodes that the current user has locked filtered by the lock type provided
See Also:
org.alfresco.service.cmr.lock.LockService#getLocks(org.alfresco.service.cmr.lock.LockType)


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