Package wt.locks

Class LockHelper

java.lang.Object
wt.locks.LockHelper
All Implemented Interfaces:
Externalizable, Serializable

public final class LockHelper extends Object implements Externalizable
Provides an abstraction as the API (Application Programming Interface) to the lock services. This API includes only class methods and must be used accordingly. These methods can be categorized as local and remote invocations. The local methods are getters of information, typically from cookies, that are held in the client. The remote methods serve as wrappers to services that promote server-side functionality to clients.

Supported API: true

Extendable: false
See Also:
  • Field Details

    • LOCKED

      public static final boolean LOCKED
      An indication, passed to getSearchCondition, to build a search condition to find all locked objects. If it is used in conjunction with a principal then the search condition is built to find all objects locked by the principal.

      Supported API: true
      See Also:
    • UNLOCKED

      public static final boolean UNLOCKED
      An indication, passed to getSearchCondition, to build a search condition to find all unlocked objects. If it is used in conjunction with a principal then the search condition is built to find all objects not locked by the principal.

      Supported API: true
      See Also:
    • service

      public static final LockService service


      Supported API: true
  • Method Details

    • assignLock

      public static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note) throws WTException, LockException, WTPropertyVetoException
      Assigns a lock on the given lockable object by the given principal. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.

      Supported API: true
      Parameters:
      object -
      locker -
      note -
      Returns:
      Lockable
      Throws:
      WTException
      LockException
      WTPropertyVetoException
    • releaseLock

      public static Lockable releaseLock(Lockable object) throws WTException, LockException, WTPropertyVetoException
      Releases the lock that has been placed on the given lockable object. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.

      Supported API: true
      Parameters:
      object -
      Returns:
      Lockable
      Throws:
      WTException
      LockException
      WTPropertyVetoException
    • isLocked

      public static boolean isLocked(Lockable object) throws LockException
      Tests if the given object has been locked.

      Supported API: true
      Parameters:
      object -
      Returns:
      boolean
      Throws:
      LockException
    • getDate

      public static Timestamp getDate(Lockable object) throws LockException
      Gets the time when the object was locked.

      Supported API: true
      Parameters:
      object -
      Returns:
      Timestamp
      Throws:
      LockException
    • getNote

      public static String getNote(Lockable object) throws LockException
      Gets the reason why the object was locked.

      Supported API: true
      Parameters:
      object -
      Returns:
      String
      Throws:
      LockException
    • getLocker

      public static WTPrincipal getLocker(Lockable object) throws LockException
      Gets the principal who placed the lock. If this is done directly from an existing object, the lock of which has been set, then the principal exists within the lock and can be immediately returned. Otherwise, the object and its lock was initialized via a query and the principal does not exist within the lock. So the principal must be fetched from the database given the OID for the principal stored within the lock.

      Supported API: true
      Parameters:
      object -
      Returns:
      WTPrincipal
      Throws:
      LockException
    • getLockerReference

      public static WTPrincipalReference getLockerReference(Lockable object) throws LockException
      Gets the principal who placed the lock. If this is done directly from an existing object, the lock of which has been set, then the principal exists within the lock and can be immediately returned. Otherwise, the object and its lock was initialized via a query and the principal does not exist within the lock. So the principal must be fetched from the database given the OID for the principal stored within the lock.

      Supported API: true
      Parameters:
      object -
      Returns:
      WTPrincipalReference
      Throws:
      LockException
    • getSearchCondition

      public static SearchCondition getSearchCondition(Class target, boolean state) throws LockException, QueryException
      Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked. This search condition can be used as a way to find out what objects are (un)locked regardless of who is the principal.

      Supported API: true
      Parameters:
      target -
      state -
      Returns:
      SearchCondition
      Throws:
      LockException
      QueryException
    • getSearchCondition

      public static SearchCondition getSearchCondition(Class target, WTPrincipal principal, boolean state) throws WTException, LockException, QueryException
      Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal. This search condition can be used as a way to find out what objects are (un)locked based on a particular principal.

      Supported API: true
      Parameters:
      target -
      principal -
      state -
      Returns:
      SearchCondition
      Throws:
      WTException
      LockException
      QueryException
    • getSearchCondition

      public static SearchCondition getSearchCondition(Class target, WTPrincipalReference principal, boolean state) throws WTException, LockException, QueryException
      Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal. This search condition can be used as a way to find out what objects are (un)locked based on a particular principal.

      Supported API: true
      Parameters:
      target -
      principal -
      state -
      Returns:
      SearchCondition
      Throws:
      WTException
      LockException
      QueryException
    • releaseLock

      public static WTCollection releaseLock(WTCollection objectSet) throws WTException, LockException, WTPropertyVetoException
      Releases the lock that has been placed on the given collection of lockable objects.

      Supported API: true
      Parameters:
      objectSet -
      Returns:
      WTCollection
      Throws:
      WTException
      LockException
      WTPropertyVetoException
      See Also:
      • releaseLock(Lockable object)
    • assignLock

      public static WTCollection assignLock(WTCollection lockables, WTPrincipalReference locker, String note) throws LockException
      Assigns a lock on the given lockable objects by the given principal. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.

      Supported API: true
      Parameters:
      lockables -
      locker -
      note -
      Returns:
      WTCollection
      Throws:
      LockException
    • assignLock

      public static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note, Timestamp date) throws WTException, LockException, WTPropertyVetoException
      Assigns a lock on the given lockable object to the given principal, note and date. If the principal is null the current session principal is used. If the date is null the current system time down to milliseconds is used. This method is only intended to be used when loading information into the lockable object before it is persisted. Otherwise, if it is already persistent an exception will occur. This method is synchronous to allow for concurrent processing on shared lockable objects between threads.

      Supported API: true
      Parameters:
      object -
      locker -
      note -
      date -
      Returns:
      Lockable
      Throws:
      WTException
      LockException
      WTPropertyVetoException