lock (Document - Java)

Locks a document.

Note: This method is new with Release 6.5.

Defined in

Document

Syntax

public boolean lock()
    throws NotesException
public boolean lock(String name)
    throws NotesException
public boolean lock(String name, boolean provisionalok)
    throws NotesException
public boolean lock(java.util.Vector names)
    throws NotesException
public boolean lock(java.util.Vector names, boolean provisionalok)
    throws NotesException

Parameters

String name
java.util.Vector names

The names of the lock holders. Each lock holder must be a user or group. Defaults to one lock holder: the effective user. The empty string ("") is not permitted.

boolean provisionalok
  • true to permit the placement of a provisional lock
  • false (default) to not permit a provisional lock

Return value

boolean
  • true if the lock is placed
  • false if the lock is not placed

Usage

IsDocumentLockingEnabled in Database must be true or this method throws an exception.

This method:

  • places a persistent lock if the administration (master lock) server is available.
  • places a provisional lock if the administration server is not available and the second parameter is true.
  • throws an exception if the administration server is not available and the second parameter is false.

The following actions occur depending on the current lock status:

  • If the document is not locked, this method places the lock and returns true.
  • If the document is locked and the current user is one of the lock holders, this method returns true.
  • If the document is locked and the current user is not one of the lock holders, this method returns false.

If the document is modified by another user before the lock can be placed, this method throws an exception.

Example