JAVA/CORBA CLASSES
import lotus.domino.*; import java.util.Vector; public class JavaAgent extends AgentBase { public void NotesMain() { try { Session session = getSession(); AgentContext agentContext = session.getAgentContext(); // (Your code goes here) Database db = agentContext.getCurrentDatabase(); // Open DXL file named after current database Stream stream = session.createStream(); String filename = "c:\\dxl\\"; filename = filename + db.getFileName(); filename = filename.substring(0, filename.length() - 3) + "dxl"; if (stream.open(filename)) { System.out.println("Opened " + filename); stream.truncate(); // Create note collection of all agents NoteCollection nc = db.createNoteCollection(false); nc.setSelectAgents(true); nc.buildCollection(); if (nc.getCount() > 0) { // Build temporary note collection of agents whose // names contain the word "example" NoteCollection ncEx = db.createNoteCollection(false); nc.buildCollection(); String id = nc.getFirstNoteID(); Vector agents = db.getAgents(); // For each agent, use corresponding note from nc collection for (int i = 0; i < agents.size(); i++) { Agent agent = (Agent)agents.elementAt(i); String name = agent.getName(); if (name.toLowerCase().indexOf("example") >= 0) { ncEx.add(id); } id = nc.getNextNoteID(id); } // Reduce nc collection to examples by intersecting nc.intersect(ncEx); // Export note collection as DXL if (nc.getCount() > 0) { DxlExporter exporter = session.createDxlExporter(); String output = exporter.exportDxl(nc); stream.writeText(output); stream.close(); System.out.println(nc.getCount() + " notes exported"); } else System.out.println("No notes exported"); } else System.out.println("No agents in database"); } else { System.out.println("Cannot open " + filename); } } catch(Exception e) { e.printStackTrace(); } } }
See Also