Examples: unlock method (View - Java)

This example attempts to unlock the view named "Main." 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 view and unlock
        // Not unlocked if exception thrown
        View view = db.getView("Main");
        view.unlock();
        System.out.println("View unlocked");
      }
      else
        System.out.println("Design locking not enabled");

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

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