Class PessimisticLockServiceImpl

java.lang.Object
org.kuali.rice.krad.service.impl.PessimisticLockServiceImpl
All Implemented Interfaces:
org.kuali.rice.krad.service.PessimisticLockService

@Transactional public class PessimisticLockServiceImpl extends Object implements org.kuali.rice.krad.service.PessimisticLockService
Service implementation for pessimistic locking
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.kuali.rice.krad.service.DataDictionaryService
     
    protected org.kuali.rice.krad.data.DataObjectService
     
    protected org.kuali.rice.kim.api.permission.PermissionService
     
    protected org.kuali.rice.kim.api.identity.PersonService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    checkExistingPessimisticLocks(org.kuali.rice.krad.document.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 org.kuali.rice.krad.document.authorization.PessimisticLock
    createNewPessimisticLock(org.kuali.rice.krad.document.Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user)
    Deprecated.
    protected org.kuali.rice.krad.document.authorization.PessimisticLock
    createNewPessimisticLock(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user)
    Creates a new PessimisticLock on a document for a user.
    void
     
    establishLocks(org.kuali.rice.krad.document.Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user)
    Deprecated.
    boolean
    establishPessimisticLocks(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit)
    void
    establishWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document document)
    This method creates a new PessimisticLock when Workflow processing requires one
    org.kuali.rice.krad.document.authorization.PessimisticLock
    generateNewLock(String documentNumber)
     
    org.kuali.rice.krad.document.authorization.PessimisticLock
    generateNewLock(String documentNumber, String lockDescriptor)
     
    org.kuali.rice.krad.document.authorization.PessimisticLock
    generateNewLock(String documentNumber, String lockDescriptor, org.kuali.rice.kim.api.identity.Person user)
     
    org.kuali.rice.krad.document.authorization.PessimisticLock
    generateNewLock(String documentNumber, org.kuali.rice.kim.api.identity.Person user)
     
    org.kuali.rice.krad.service.DataDictionaryService
     
    getDocumentActions(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, Set<String> documentActions)
    Deprecated.
    protected Map
    Deprecated.
    protected Map
    This method is used to return values needed to replace the given 'entry type' edit mode Map.Entry with one that will not allow the user to enter data on the document
    org.kuali.rice.kim.api.permission.PermissionService
     
    org.kuali.rice.kim.api.identity.PersonService
     
    List<org.kuali.rice.krad.document.authorization.PessimisticLock>
     
    List<org.kuali.rice.krad.document.authorization.PessimisticLock>
     
    protected org.kuali.rice.kim.api.identity.Person
    This method identifies the user that should be used to create and clear PessimisticLock objects required by Workflow.

    The default is the Kuali system user defined by
    invalid reference
    RiceConstants#SYSTEM_USER
    .
    protected boolean
    hasPreRouteEditAuthorization(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user)
    Deprecated.
    Different mechanism of obtaining authorization in KRAD
    protected boolean
    Deprecated.
    protected boolean
    isLockRequiredByUser(org.kuali.rice.krad.document.Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user)
    Deprecated.
    boolean
    isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person user)
     
    protected boolean
    isPessimisticLockNeeded(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit)
    Determines whether to add a pessimistic lock on the document for user based on the current pessimistic locks and edit modes.
    void
    releaseAllLocksForUser(List<org.kuali.rice.krad.document.authorization.PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user)
     
    void
    releaseAllLocksForUser(List<org.kuali.rice.krad.document.authorization.PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user, String lockDescriptor)
     
    void
    releaseWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document document)
    This method releases locks created via the establishWorkflowPessimisticLocking(Document) method for the given document
    org.kuali.rice.krad.document.authorization.PessimisticLock
    save(org.kuali.rice.krad.document.authorization.PessimisticLock lock)
     
    void
    setDataDictionaryService(org.kuali.rice.krad.service.DataDictionaryService dataDictionaryService)
     
    void
    setDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService)
     
    protected boolean
    usesPessimisticLocking(org.kuali.rice.krad.document.Document document)
    Deprecated.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • dataObjectService

      protected org.kuali.rice.krad.data.DataObjectService dataObjectService
    • dataDictionaryService

      protected org.kuali.rice.krad.service.DataDictionaryService 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

      public void delete(String id)
      Specified by:
      delete in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.delete(java.lang.String)
    • generateNewLock

      public org.kuali.rice.krad.document.authorization.PessimisticLock generateNewLock(String documentNumber)
      Specified by:
      generateNewLock in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.generateNewLock(String)
    • generateNewLock

      public org.kuali.rice.krad.document.authorization.PessimisticLock generateNewLock(String documentNumber, String lockDescriptor)
      Specified by:
      generateNewLock in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.generateNewLock(java.lang.String)
    • generateNewLock

      public org.kuali.rice.krad.document.authorization.PessimisticLock generateNewLock(String documentNumber, org.kuali.rice.kim.api.identity.Person user)
      Specified by:
      generateNewLock in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.generateNewLock(java.lang.String, org.kuali.rice.kim.api.identity.Person)
    • generateNewLock

      public org.kuali.rice.krad.document.authorization.PessimisticLock generateNewLock(String documentNumber, String lockDescriptor, org.kuali.rice.kim.api.identity.Person user)
      Specified by:
      generateNewLock in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.generateNewLock(java.lang.String, java.lang.String, org.kuali.rice.kim.api.identity.Person)
    • getPessimisticLocksForDocument

      public List<org.kuali.rice.krad.document.authorization.PessimisticLock> getPessimisticLocksForDocument(String documentNumber)
      Specified by:
      getPessimisticLocksForDocument in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.getPessimisticLocksForDocument(java.lang.String)
    • getPessimisticLocksForSession

      public List<org.kuali.rice.krad.document.authorization.PessimisticLock> getPessimisticLocksForSession(String sessionId)
      Specified by:
      getPessimisticLocksForSession in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.getPessimisticLocksForSession(java.lang.String)
    • isPessimisticLockAdminUser

      public boolean isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person user)
      Specified by:
      isPessimisticLockAdminUser in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.isPessimisticLockAdminUser(org.kuali.rice.kim.api.identity.Person)
    • releaseAllLocksForUser

      public void releaseAllLocksForUser(List<org.kuali.rice.krad.document.authorization.PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user)
      Specified by:
      releaseAllLocksForUser in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.releaseAllLocksForUser(java.util.List, org.kuali.rice.kim.api.identity.Person)
    • releaseAllLocksForUser

      public void releaseAllLocksForUser(List<org.kuali.rice.krad.document.authorization.PessimisticLock> locks, org.kuali.rice.kim.api.identity.Person user, String lockDescriptor)
      Specified by:
      releaseAllLocksForUser in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.releaseAllLocksForUser(java.util.List, org.kuali.rice.kim.api.identity.Person, java.lang.String)
    • save

      public org.kuali.rice.krad.document.authorization.PessimisticLock save(org.kuali.rice.krad.document.authorization.PessimisticLock lock)
      Specified by:
      save in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • PessimisticLockService.save(org.kuali.rice.krad.document.authorization.PessimisticLock)
    • establishPessimisticLocks

      public boolean establishPessimisticLocks(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit)
      Specified by:
      establishPessimisticLocks in interface org.kuali.rice.krad.service.PessimisticLockService
    • isPessimisticLockNeeded

      protected boolean isPessimisticLockNeeded(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, boolean canEdit)
      Determines whether to add a pessimistic lock on the document for user based on the current pessimistic locks and edit modes.
      Parameters:
      document - the document on which the locks will be established
      user - the user for which the locks are being established
      canEdit - whether the user currently can edit the document
      Returns:
      true if a pessimistic lock should be added, false otherwise
    • checkExistingPessimisticLocks

      protected void checkExistingPessimisticLocks(org.kuali.rice.krad.document.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 locks
      userOwnedLockDescriptors - the list of lock descriptors for the current user
      otherOwnedLockDescriptors - the map of other lock descriptors to all of the other users that own them
    • createNewPessimisticLock

      protected org.kuali.rice.krad.document.authorization.PessimisticLock createNewPessimisticLock(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user)
      Creates a new PessimisticLock on a document for a user.

      If the document uses 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 established
      user - the user for which the locks are being established
      Returns:
      the newly created lock object
    • getDocumentActions

      @Deprecated public Set getDocumentActions(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user, Set<String> documentActions)
      Deprecated.
      Specified by:
      getDocumentActions in interface org.kuali.rice.krad.service.PessimisticLockService
    • hasPreRouteEditAuthorization

      @Deprecated protected boolean hasPreRouteEditAuthorization(org.kuali.rice.krad.document.Document document, org.kuali.rice.kim.api.identity.Person user)
      Deprecated.
      Different mechanism of obtaining authorization in KRAD
      This 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 check
      user - - current user
      Returns:
      true if the document is using Pessimistic Locking, the user has initiate authorization (see
      invalid reference
      #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
      invalid reference
      #hasInitiateAuthorization(Document, Person)
      .
    • usesPessimisticLocking

      @Deprecated protected boolean usesPessimisticLocking(org.kuali.rice.krad.document.Document document)
      Deprecated.
    • establishWorkflowPessimisticLocking

      public void establishWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document document)
      This method creates a new PessimisticLock when Workflow processing requires one
      Specified by:
      establishWorkflowPessimisticLocking in interface org.kuali.rice.krad.service.PessimisticLockService
      Parameters:
      document - - the document to create the lock against and add the lock to
      See Also:
      • invalid reference
        org.kuali.rice.kns.document.authorization.DocumentAuthorizer#establishWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document)
    • releaseWorkflowPessimisticLocking

      public void releaseWorkflowPessimisticLocking(org.kuali.rice.krad.document.Document document)
      This method releases locks created via the establishWorkflowPessimisticLocking(Document) method for the given document
      Specified by:
      releaseWorkflowPessimisticLocking in interface org.kuali.rice.krad.service.PessimisticLockService
      Parameters:
      document - - document to release locks from
      See Also:
      • invalid reference
        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 clear PessimisticLock objects required by Workflow.

      The default is the Kuali system user defined by
      invalid reference
      RiceConstants#SYSTEM_USER
      . This method can be overridden by implementing documents if another user is needed.
      Returns:
      a valid Person object
    • establishLocks

      @Deprecated public Map establishLocks(org.kuali.rice.krad.document.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 new PessimisticLock object 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:
      establishLocks in interface org.kuali.rice.krad.service.PessimisticLockService
      See Also:
      • invalid reference
        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(org.kuali.rice.krad.document.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 the isEntryEditMode(java.util.Map.Entry) method.
      Parameters:
      document - - document to verify lock creation against
      editMode - - edit modes list to check for 'entry type' edit modes
      user - - 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 protected Map getEditModeWithEditableModesRemoved(Map currentEditMode)
      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 the isEntryEditMode(java.util.Map.Entry) method to identify if an edit mode is defined as an 'entry type' edit mode. It also uses the getEntryEditModeReplacementMode(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 protected boolean isEntryEditMode(Map.Entry entry)
      Deprecated.
      This method is used to check if the given Map.Entry is 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 - - the Map.Entry object that contains an edit mode such as the ones returned but
      invalid reference
      #getEditMode(Document, Person)
      Returns:
      true if the given entry has a key signifying an 'entry type' edit mode and the value is equal to
      invalid reference
      #EDIT_MODE_DEFAULT_TRUE_VALUE
      ... false if not
    • getEntryEditModeReplacementMode

      protected Map getEntryEditModeReplacementMode(Map.Entry entry)
      This method is used to return values needed to replace the given 'entry type' edit mode Map.Entry with 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 org.kuali.rice.krad.document.authorization.PessimisticLock createNewPessimisticLock(org.kuali.rice.krad.document.Document document, Map editMode, org.kuali.rice.kim.api.identity.Person user)
      Deprecated.
      This method creates a new PessimisticLock object 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 on
      editMode - - current edit modes for given user
      user - - 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

      public org.kuali.rice.krad.service.DataDictionaryService getDataDictionaryService()
    • setDataDictionaryService

      public void setDataDictionaryService(org.kuali.rice.krad.service.DataDictionaryService dataDictionaryService)
    • getPermissionService

      public org.kuali.rice.kim.api.permission.PermissionService getPermissionService()
    • setDataObjectService

      public void setDataObjectService(org.kuali.rice.krad.data.DataObjectService dataObjectService)