Examples: unlock method (Agent - Java)

This example attempts to unlock the agent named "Main Agent." Unlocking is successful if the effective user is one of the lock holders.

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();
      // Design locking must be enabled
      if (db.isDesignLockingEnabled()) {
        // Get agent and unlock
        // Not unlocked if exception thrown
        Agent agent = db.getAgent("Main Agent");
        System.out.println("Agent unlocked");
        System.out.println("Design locking not enabled");

    } catch(NotesException e) {
        System.out.println(e.id + "Agent not unlocked");

    } catch(Exception e) {