Locking documents and design elements (Java)

Locks permit you to synchronize multi-user access to documents and the following design elements: agents, forms, and views.

To permit locking in a database:

  • The database must have an administration (master lock) server. You can set and check the administration server with NotesACL.AdministrationServer.
  • Locking must be enabled. You can set and check locking through:
    • NotesDatabase.IsDocumentLockingEnabled
    • NotesDatabase.IsDesignLockingEnabled.

The following methods manipulate locks:

Document

Agent

Form

View

getLockHolders

getLockHolders

getLockHolders

getLockHolders

lock

lock

lock

lock

lockProvisional

lockProvisional

lockProvisional

lockProvisional

unLock

unLock

unLock

unLock

To apply a lock, call lock or lockProvisional. The first parameter specifies the lock holder or holders, and defaults to the effective user. The lockHolders property returns the current lock holders.

A lock is:

  • Persistent if the administration server is available and lock is called. If the administration server is not available and provisional locks are not permitted (second parameter to lock is false), an error is raised.
  • Provisional if the administration server is not available, lock is called, and the second parameter is true; or lockProvisional is called.

To serialize or otherwise limit access to a document or design element, apply lock or lockProvisional and examine the return status:

  • true means either:
    • No lock is in effect and your lock is applied.
    • A lock is in effect but the effective user is one of the lock holders. The lock stays in effect.
  • false means a lock is in effect and the effective user is not one of the lock holders.

The typical protocol is to proceed on true, and to exit or wait on false.

Locks are not supported in Web applications.