Class ResourceLocks

java.lang.Object
nl.info.webdav.locking.ResourceLocks
All Implemented Interfaces:
IResourceLocks

public class ResourceLocks extends Object implements IResourceLocks
Simple locking management for concurrent data access, NOT the webdav locking.
  • Field Details

  • Constructor Details

    • ResourceLocks

      public ResourceLocks()
  • Method Details

    • lock

      public boolean lock(ITransaction transaction, String path, String owner, boolean exclusive, int depth, int timeout, boolean temporary) throws LockFailedException
      Description copied from interface: IResourceLocks
      Tries to lock the resource at "path".
      Specified by:
      lock in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - what resource to lock
      owner - the owner of the lock
      exclusive - if the lock should be exclusive (or shared)
      depth - depth
      timeout - lock duration in seconds.
      Returns:
      true if the resource at path was successfully locked, false if an existing lock prevented this
      Throws:
      LockFailedException - if the lock failed
    • unlock

      public boolean unlock(ITransaction transaction, String id, String owner)
      Description copied from interface: IResourceLocks
      Unlocks all resources at "path" (and all sub-folders if existing) that have the same owner.
      Specified by:
      unlock in interface IResourceLocks
      Parameters:
      transaction - the transaction
      id - id to the resource to unlock
      owner - who wants to unlock
    • unlockTemporaryLockedObjects

      public void unlockTemporaryLockedObjects(ITransaction transaction, String path, String owner)
      Description copied from interface: IResourceLocks
      Unlocks all resources at "path" (and all sub-folders if existing) that have the same owner.
      Specified by:
      unlockTemporaryLockedObjects in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - what resource to unlock
      owner - who wants to unlock
    • checkTimeouts

      public void checkTimeouts(ITransaction transaction, boolean temporary)
      Description copied from interface: IResourceLocks
      Deletes LockedObjects, where timeout has reached.
      Specified by:
      checkTimeouts in interface IResourceLocks
      Parameters:
      transaction - the transaction
      temporary - check timeout on temporary or real locks
    • exclusiveLock

      public boolean exclusiveLock(ITransaction transaction, String path, String owner, int depth, int timeout) throws LockFailedException
      Description copied from interface: IResourceLocks
      Tries to lock the resource at "path" exclusively.
      Specified by:
      exclusiveLock in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - what resource to lock
      owner - the owner of the lock
      depth - depth
      timeout - lock duration in seconds.
      Returns:
      true if the resource at path was successfully locked, false if an existing lock prevented this
      Throws:
      LockFailedException - if the lock failed
    • sharedLock

      public boolean sharedLock(ITransaction transaction, String path, String owner, int depth, int timeout) throws LockFailedException
      Description copied from interface: IResourceLocks
      Tries to lock the resource at "path" shared.
      Specified by:
      sharedLock in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - what resource to lock
      owner - the owner of the lock
      depth - depth
      timeout - lock Duration in seconds.
      Returns:
      true if the resource at path was successfully locked, false if an existing lock prevented this
      Throws:
      LockFailedException - if the lock failed
    • getLockedObjectByID

      public LockedObject getLockedObjectByID(ITransaction transaction, String id)
      Description copied from interface: IResourceLocks
      Gets the LockedObject corresponding to specified id.
      Specified by:
      getLockedObjectByID in interface IResourceLocks
      Parameters:
      transaction - the transaction
      id - lock token to requested resource
      Returns:
      LockedObject or null if no LockedObject on specified path exists
    • getLockedObjectByPath

      public LockedObject getLockedObjectByPath(ITransaction transaction, String path)
      Description copied from interface: IResourceLocks
      Gets the locked object on specified path.
      Specified by:
      getLockedObjectByPath in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - the path to requested resource
      Returns:
      LockedObject or null if no LockedObject on specified path exists
    • getTempLockedObjectByID

      public LockedObject getTempLockedObjectByID(ITransaction transaction, String id)
      Description copied from interface: IResourceLocks
      Gets the LockedObject corresponding to specified id (lock token).
      Specified by:
      getTempLockedObjectByID in interface IResourceLocks
      Parameters:
      transaction - the transaction
      id - the lock token to requested resource
      Returns:
      LockedObject or null if no LockedObject on specified path exists
    • getTempLockedObjectByPath

      public LockedObject getTempLockedObjectByPath(ITransaction transaction, String path)
      Description copied from interface: IResourceLocks
      Gets the LockedObject on specified path.
      Specified by:
      getTempLockedObjectByPath in interface IResourceLocks
      Parameters:
      transaction - the transaction
      path - path to requested resource
      Returns:
      LockedObject or null if no LockedObject on specified path exists