wt.locks
Class LockHelper

java.lang.Object
  extended bywt.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:
Lockable, LockService, Serialized Form

Field Summary
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
static boolean LOCKED
          An indication, passed to getSearchCondition, to build a search condition to find all locked objects.
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
static LockService service
          

Supported API: true
static boolean UNLOCKED
          An indication, passed to getSearchCondition, to build a search condition to find all unlocked objects.
 
Constructor Summary
LockHelper()
           
 
Method Summary
static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note)
          Assigns a lock on the given lockable object by the given principal.
static Lockable assignLock(Lockable object, WTPrincipalReference locker, String note, Timestamp date)
          Assigns a lock on the given lockable object to the given principal, note and date.
static Timestamp getDate(Lockable object)
          Gets the time when the object was locked.
static WTPrincipal getLocker(Lockable object)
          Gets the principal who placed the lock.
static WTPrincipalReference getLockerReference(Lockable object)
          Gets the principal who placed the lock.
static String getNote(Lockable object)
          Gets the reason why the object was locked.
static SearchCondition getSearchCondition(Class target, boolean state)
          Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked.
static SearchCondition getSearchCondition(Class target, WTPrincipal principal, boolean state)
          Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal.
static SearchCondition getSearchCondition(Class target, WTPrincipalReference principal, boolean state)
          Gets a SearchCondition to be appended to a query of all the objects that are either locked or unlocked for a given principal.
static boolean isLocked(Lockable object)
          Tests if the given object has been locked.
static Lockable lock(Lockable object)
          Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable)
static Lockable lock(Lockable object, String note)
          Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,String)
static Lockable lock(Lockable object, WTPrincipal locker)
          Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,WTPrincipalReference)
static Lockable lock(Lockable object, WTPrincipal locker, String note)
          Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,WTPrincipalReference,String)
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(LockHelper thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
static Lockable releaseLock(Lockable object)
          Releases the lock that has been placed on the given lockable object.
static WTCollection releaseLock(WTCollection objectSet)
          Releases the lock that has been placed on the given collection of lockable objects.
static Lockable unlock(Lockable object)
          Deprecated. Replaced by LockHelper.service.unlock(Lockable)
static Lockable unlock(Lockable object, WTPrincipal locker)
          Deprecated. Replaced by LockHelper.service.unlock(Lockable,WTPrincipalReference)
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

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:
Constant Field Values

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:
Constant Field Values

service

public static final LockService service


Supported API: true


serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values
Constructor Detail

LockHelper

public LockHelper()
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(LockHelper thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

lock

public static Lockable lock(Lockable object,
                            WTPrincipal locker,
                            String note)
                     throws WTException,
                            LockException,
                            WTPropertyVetoException,
                            PersistenceException
Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,WTPrincipalReference,String)

Promotes server-side functionality for the locking of business objects (e.g., documents). This type of lock is a logical mechanism to restrict concurrent access, not a database lock. When a lock is placed on an object by a principal, that user or group is the only agency able to then modify the object.

However, if an object is lockable but has not yet been locked, then any agency has unrestricted access to the object until it has been locked.



Supported API: false

Parameters:
object -
locker -
note -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#assignLocker(Lockable,WTPrincipalReference), wt.locks.LockHelper#service#lock(Lockable,WTPrincipalReference,String)

lock

public static Lockable lock(Lockable object,
                            WTPrincipal locker)
                     throws WTException,
                            LockException,
                            WTPropertyVetoException,
                            PersistenceException
Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,WTPrincipalReference)

Defaults the note to be null and invokes the main lock method.

Supported API: false

Parameters:
object -
locker -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#assignLocker(Lockable,WTPrincipalReference), wt.locks.LockHelper#service#lock(Lockable,WTPrincipalReference,String)

lock

public static Lockable lock(Lockable object,
                            String note)
                     throws WTException,
                            LockException,
                            WTPropertyVetoException,
                            PersistenceException
Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable,String)

Defaults the principal to be null, which makes the principal the session's user, and invokes the main lock method.

Supported API: false

Parameters:
object -
note -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#assignLocker(Lockable,WTPrincipalReference), wt.locks.LockHelper#service#lock(Lockable,WTPrincipalReference,String)

lock

public static Lockable lock(Lockable object)
                     throws WTException,
                            LockException,
                            WTPropertyVetoException,
                            PersistenceException
Deprecated. Replaced by assignLocker(Lockable,WTPrincipalReference) or LockHelper.service.lock(Lockable)

Defaults the note to be null, the principal to be null, which makes the principal the session's user, and invokes the main lock method.

Supported API: false

Parameters:
object -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#assignLocker(Lockable,WTPrincipalReference), wt.locks.LockHelper#service#lock(Lockable,WTPrincipalReference,String)

unlock

public static Lockable unlock(Lockable object,
                              WTPrincipal locker)
                       throws WTException,
                              LockException,
                              WTPropertyVetoException,
                              PersistenceException
Deprecated. Replaced by LockHelper.service.unlock(Lockable,WTPrincipalReference)

Promotes server-side functionality for releasing a business object's lock. When a lock is released off of an object, its access becomes unrestricted.

Supported API: false

Parameters:
object -
locker -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#service#unlock(Lockable,WTPrincipalReference)

unlock

public static Lockable unlock(Lockable object)
                       throws WTException,
                              LockException,
                              WTPropertyVetoException,
                              PersistenceException
Deprecated. Replaced by LockHelper.service.unlock(Lockable)

Defaults the principal to be null, which makes the principal the session's user, and invokes the main unlock method.

Supported API: false

Parameters:
object -
Returns:
Lockable
Throws:
WTException
LockException
WTPropertyVetoException
PersistenceException
See Also:
wt.locks.LockHelper#service#unlock(Lockable)

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 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