Examples: resolve method
- This agent resolves a database URL showing various ways to construct
the URL.
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(); // Construct URL using getURL String theURL = db.getURL(); System.out.println(theURL + " - using getURL"); Database target = (Database)session.resolve(theURL); System.out.println(target.getTitle()); // Construct URL using getFileName theURL = "notes:///" + db.getFileName() + "?OpenDatabase"; System.out.println(theURL + " - using getFileName"); target = (Database)session.resolve(theURL); System.out.println(target.getTitle()); // Construct URL using getReplicaID theURL = "notes:///" + db.getReplicaID() + "?OpenDatabase"; System.out.println(theURL + " - using getReplicaID"); target = (Database)session.resolve(theURL); System.out.println(target.getTitle()); // Construct URL using literal database name theURL = "notes:///Document+examples+2?OpenDatabase"; // Also OK: "notes:///Document examples 2?OpenDatabase" // Also OK: "notes:///Document+examples+2.nsf?OpenDatabase" // Also OK: "notes:///Document examples 2.nsf?OpenDatabase" System.out.println(theURL + " - using literal database name"); target = (Database)session.resolve(theURL); System.out.println(target.getTitle()); // Construct URL using literal replica ID theURL = "notes:///__8525690D006AC34D.nsf?OpenDatabase"; // Also OK: "notes:///8525690D006AC34D?OpenDatabase"; System.out.println(theURL + " - using literal replica ID"); target = (Database)session.resolve(theURL); System.out.println(target.getTitle()); } catch(NotesException e) { System.out.println(e.id + e.text); e.printStackTrace(); } } }
- This agent resolves the URL for a view.
import lotus.domino.*; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) String theURL = "notes:///Document examples 2/Main View?OpenView"; System.out.println(theURL); View v = (View)session.resolve(theURL); System.out.println(v.getName()); } catch(Exception e) { e.printStackTrace(); } } }