Package org.kuali.rice.krad.service.impl
Class PessimisticLockServiceImpl
java.lang.Object
org.kuali.rice.krad.service.impl.PessimisticLockServiceImpl
- All Implemented Interfaces:
PessimisticLockService
@Transactional
public class PessimisticLockServiceImpl
extends Object
implements PessimisticLockService
Service implementation for pessimistic locking
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataDictionaryServiceprotected org.kuali.rice.krad.data.DataObjectServiceprotected org.kuali.rice.kim.api.permission.PermissionServiceprotected org.kuali.rice.kim.api.identity.PersonService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckExistingPessimisticLocks(Document document, List<String> userOwnedLockDescriptors, Map<String, Set<String>> otherOwnedLockDescriptors) Check to make sure that the current user doesn't erroneously share the same lock with another user.protected PessimisticLockcreateNewPessimisticLock(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.protected PessimisticLockcreateNewPessimisticLock(Document document, org.kuali.rice.kim.api.identity.Person user) voidestablishLocks(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.booleanestablishPessimisticLocks(Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit) voidestablishWorkflowPessimisticLocking(Document document) This method creates a newPessimisticLockwhen Workflow processing requires onegenerateNewLock(String documentNumber) generateNewLock(String documentNumber, String lockDescriptor) generateNewLock(String documentNumber, String lockDescriptor, org.kuali.rice.kim.api.identity.Person user) generateNewLock(String documentNumber, org.kuali.rice.kim.api.identity.Person user) getDocumentActions(Document document, org.kuali.rice.kim.api.identity.Person user, Set<String> documentActions) Deprecated.protected MapgetEditModeWithEditableModesRemoved(Map currentEditMode) Deprecated.protected MapThis method is used to return values needed to replace the given 'entry type' edit modeMap.Entrywith one that will not allow the user to enter data on the documentorg.kuali.rice.kim.api.permission.PermissionServiceorg.kuali.rice.kim.api.identity.PersonServicegetPessimisticLocksForDocument(String documentNumber) getPessimisticLocksForSession(String sessionId) protected org.kuali.rice.kim.api.identity.PersonThis method identifies the user that should be used to create and clearPessimisticLockobjects required by Workflow.
The default is the Kuali system user defined byRiceConstants#SYSTEM_USER.protected booleanhasPreRouteEditAuthorization(Document document, org.kuali.rice.kim.api.identity.Person user) Deprecated.Different mechanism of obtaining authorization in KRADprotected booleanisEntryEditMode(Map.Entry entry) Deprecated.protected booleanisLockRequiredByUser(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.booleanisPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person user) protected booleanisPessimisticLockNeeded(Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit) Determines whether to add a pessimistic lock on thedocumentforuserbased on the current pessimistic locks and edit modes.voidreleaseAllLocksForUser(List<PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user) voidreleaseAllLocksForUser(List<PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user, String lockDescriptor) voidreleaseWorkflowPessimisticLocking(Document document) This method releases locks created via theestablishWorkflowPessimisticLocking(Document)method for the given documentsave(PessimisticLock lock) voidsetDataDictionaryService(DataDictionaryService dataDictionaryService) voidsetDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService) protected booleanusesPessimisticLocking(Document document) Deprecated.
-
Field Details
-
dataObjectService
protected org.kuali.rice.krad.data.DataObjectService dataObjectService -
dataDictionaryService
-
permissionService
protected org.kuali.rice.kim.api.permission.PermissionService permissionService -
personService
protected org.kuali.rice.kim.api.identity.PersonService personService
-
-
Constructor Details
-
PessimisticLockServiceImpl
public PessimisticLockServiceImpl()
-
-
Method Details
-
delete
- Specified by:
deletein interfacePessimisticLockService- See Also:
-
generateNewLock
- Specified by:
generateNewLockin interfacePessimisticLockService- See Also:
-
generateNewLock
- Specified by:
generateNewLockin interfacePessimisticLockService- See Also:
-
generateNewLock
public PessimisticLock generateNewLock(String documentNumber, org.kuali.rice.kim.api.identity.Person user) - Specified by:
generateNewLockin interfacePessimisticLockService- See Also:
-
generateNewLock
public PessimisticLock generateNewLock(String documentNumber, String lockDescriptor, org.kuali.rice.kim.api.identity.Person user) - Specified by:
generateNewLockin interfacePessimisticLockService- See Also:
-
getPessimisticLocksForDocument
- Specified by:
getPessimisticLocksForDocumentin interfacePessimisticLockService- See Also:
-
getPessimisticLocksForSession
- Specified by:
getPessimisticLocksForSessionin interfacePessimisticLockService- See Also:
-
isPessimisticLockAdminUser
public boolean isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person user) - Specified by:
isPessimisticLockAdminUserin interfacePessimisticLockService- See Also:
-
releaseAllLocksForUser
public void releaseAllLocksForUser(List<PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user) - Specified by:
releaseAllLocksForUserin interfacePessimisticLockService- See Also:
-
releaseAllLocksForUser
public void releaseAllLocksForUser(List<PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user, String lockDescriptor) -
save
- Specified by:
savein interfacePessimisticLockService- See Also:
-
establishPessimisticLocks
public boolean establishPessimisticLocks(Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit) - Specified by:
establishPessimisticLocksin interfacePessimisticLockService
-
isPessimisticLockNeeded
protected boolean isPessimisticLockNeeded(Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit) Determines whether to add a pessimistic lock on thedocumentforuserbased on the current pessimistic locks and edit modes.- Parameters:
document- the document on which the locks will be establisheduser- the user for which the locks are being establishedcanEdit- whether the user currently can edit the document- Returns:
- true if a pessimistic lock should be added, false otherwise
-
checkExistingPessimisticLocks
protected void checkExistingPessimisticLocks(Document document, List<String> userOwnedLockDescriptors, Map<String, Set<String>> otherOwnedLockDescriptors) Check to make sure that the current user doesn't erroneously share the same lock with another user.- Parameters:
document- the document to check for erroneous locksuserOwnedLockDescriptors- the list of lock descriptors for the current userotherOwnedLockDescriptors- the map of other lock descriptors to all of the other users that own them
-
createNewPessimisticLock
protected PessimisticLock createNewPessimisticLock(Document document, org.kuali.rice.kim.api.identity.Person user) Creates a newPessimisticLockon adocumentfor auser.If the
documentuses custom lock descriptors, then the new lock is generated with a custom lock descriptor for a portion of the document. Otherwise, it will create a lock over the entire document.- Parameters:
document- the document on which the locks will be establisheduser- the user for which the locks are being established- Returns:
- the newly created lock object
-
getDocumentActions
@Deprecated public Set getDocumentActions(Document document, org.kuali.rice.kim.api.identity.Person user, Set<String> documentActions) Deprecated.- Specified by:
getDocumentActionsin interfacePessimisticLockService
-
hasPreRouteEditAuthorization
@Deprecated protected boolean hasPreRouteEditAuthorization(Document document, org.kuali.rice.kim.api.identity.Person user) Deprecated.Different mechanism of obtaining authorization in KRADThis method checks to see that the given user has a lock on the document and return true if one is found.- Parameters:
document- - document to checkuser- - current user- Returns:
- true if the document is using Pessimistic Locking, the user has initiate authorization (see
#hasInitiateAuthorization(Document, Person)), and the document has a lock owned by the given user. If the document is not using Pessimistic Locking the value returned will be that returned by#hasInitiateAuthorization(Document, Person).
-
usesPessimisticLocking
Deprecated. -
establishWorkflowPessimisticLocking
This method creates a newPessimisticLockwhen Workflow processing requires one- Specified by:
establishWorkflowPessimisticLockingin interfacePessimisticLockService- Parameters:
document- - the document to create the lock against and add the lock to- See Also:
-
org.kuali.rice.kns.document.authorization.DocumentAuthorizer#establishWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document)
-
releaseWorkflowPessimisticLocking
This method releases locks created via theestablishWorkflowPessimisticLocking(Document)method for the given document- Specified by:
releaseWorkflowPessimisticLockingin interfacePessimisticLockService- Parameters:
document- - document to release locks from- See Also:
-
org.kuali.rice.kns.document.authorization.DocumentAuthorizer#releaseWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document)
-
getWorkflowPessimisticLockOwnerUser
protected org.kuali.rice.kim.api.identity.Person getWorkflowPessimisticLockOwnerUser()This method identifies the user that should be used to create and clearPessimisticLockobjects required by Workflow.
The default is the Kuali system user defined byRiceConstants#SYSTEM_USER. This method can be overridden by implementing documents if another user is needed.- Returns:
- a valid
Personobject
-
establishLocks
@Deprecated public Map establishLocks(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.This implementation will check the given document, editMode map, and user object to verify Pessimistic Locking. If the given edit mode map contains an 'entry type' edit mode then the system will check the locks already in existence on the document. If a valid lock for the given user is found the system will return the given edit mode map. If a valid lock is found but is owned by another user the edit mode map returned will have any 'entry type' edit modes removed. If the given document has no locks and the edit mode map passed in has at least one 'entry type' mode then a newPessimisticLockobject will be created and set on the document for the given user.
NOTE: This method is only called if the document uses pessimistic locking as described in the data dictionary file.- Specified by:
establishLocksin interfacePessimisticLockService- See Also:
-
org.kuali.rice.kns.document.authorization.DocumentAuthorizer#establishLocks(org.kuali.rice.krad.document.Document, java.util.Map, org.kuali.rice.kim.api.identity.Person)
-
isLockRequiredByUser
@Deprecated protected boolean isLockRequiredByUser(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.This method is used to check if the given parameters warrant a new lock to be created for the given user. This method utilizes theisEntryEditMode(java.util.Map.Entry)method.- Parameters:
document- - document to verify lock creation againsteditMode- - edit modes list to check for 'entry type' edit modesuser- - user the lock will be 'owned' by- Returns:
- true if the given edit mode map has at least one 'entry type' edit mode... false otherwise
-
getEditModeWithEditableModesRemoved
Deprecated.This method is used to remove edit modes from the given map that allow the user to edit data on the document. This method utilizes theisEntryEditMode(java.util.Map.Entry)method to identify if an edit mode is defined as an 'entry type' edit mode. It also uses thegetEntryEditModeReplacementMode(java.util.Map.Entry)method to replace any 'entry type' edit modes it finds.- Parameters:
currentEditMode- - current set of edit modes the user has assigned to them- Returns:
- an adjusted edit mode map where 'entry type' edit modes have been removed or replaced using the
getEntryEditModeReplacementMode(java.util.Map.Entry)method
-
isEntryEditMode
Deprecated.This method is used to check if the givenMap.Entryis an 'entry type' edit mode and that the value is set to signify that this user has that edit mode available to them- Parameters:
entry- - theMap.Entryobject that contains an edit mode such as the ones returned but#getEditMode(Document, Person)- Returns:
- true if the given entry has a key signifying an 'entry type' edit mode and the value is equal to
#EDIT_MODE_DEFAULT_TRUE_VALUE... false if not
-
getEntryEditModeReplacementMode
This method is used to return values needed to replace the given 'entry type' edit modeMap.Entrywith one that will not allow the user to enter data on the document- Parameters:
entry- - the current 'entry type' edit mode to replace- Returns:
- a Map of edit modes that will be used to replace this edit mode (represented by the given entry parameter)
-
createNewPessimisticLock
@Deprecated protected PessimisticLock createNewPessimisticLock(Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user) Deprecated.This method creates a newPessimisticLockobject using the given document and user. If the document's useCustomLockDescriptors() method returns true then the new lock will also have a custom lock descriptor value set to the return value of the document's getCustomLockDescriptor(Person) method.- Parameters:
document- - document to place the lock oneditMode- - current edit modes for given useruser- - user who will 'own' the new lock object- Returns:
- the newly created lock object
-
getPersonService
public org.kuali.rice.kim.api.identity.PersonService getPersonService() -
getDataDictionaryService
-
setDataDictionaryService
-
getPermissionService
public org.kuali.rice.kim.api.permission.PermissionService getPermissionService() -
setDataObjectService
public void setDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService)
-