JAVA/CORBA CLASSES


Examples: lock method
This agent attempts to lock the selected document for all members of the "Guys" group. Locking is successful if the document is not yet locked, or the document is locked but the effective user is a member of Guys. A provisional lock is allowed if the administration server is not available.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();

     // (Your code goes here)
     Database db = agentContext.getCurrentDatabase();
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     
     // Document locking must be enabled
     if (db.isDocumentLockingEnabled()) {
       // Get document and lock
       // Not locked if return is false or exception thrown
       Document doc = dc.getFirstDocument();
       if (doc.lock("Guys", true))
         System.out.println("Document locked");
       else
         System.out.println("Document not locked");
     }
     else
       System.out.println("Document locking not enabled");

   } catch(NotesException e) {
     if (e.id == NotesError.NOTES_ERR_LOCKED)
       System.out.println("Document not locked (exception)");
     else
       e.printStackTrace();

   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also