Examples: IsEncrypted, IsProtected, IsSaveToDisk, IsSigned, and IsSummary properties
- This agent determines the encryption, protection, save-to-disk,
and summary status of the items in a document.
import lotus.domino.*; import java.util.Vector; import java.util.Enumeration; 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 = db.getAllDocuments(); Document doc = dc.getFirstDocument(); if (doc != null) { Enumeration items = doc.getItems().elements(); while (items.hasMoreElements()) { Item item = (Item)items.nextElement(); System.out.println(item.getName()); if (item.isEncrypted()) System.out.print(" encrypted"); else System.out.print(" not encrypted"); if (item.isProtected()) System.out.print(" * protected"); else System.out.print(" * not protected"); if (item.isSaveToDisk()) System.out.print("* saved to disk"); else System.out.print(" * not saved to disk"); if (item.isSigned()) System.out.print(" * signed"); else System.out.print(" * not signed"); if (item.isSummary()) System.out.println(" * summarized"); else System.out.println(" * not summarized"); } } } catch(Exception e) { e.printStackTrace(); } } }
- This agent sets encryption on for an item and encrypts the document
containing it.
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 = db.getAllDocuments(); Document doc = dc.getFirstDocument(); while (doc != null) { Item item = doc.getFirstItem("Body"); if (item != null) { item.setEncrypted(true); doc.encrypt(); doc.save(true, true); } doc = dc.getNextDocument(); } } catch(Exception e) { e.printStackTrace(); } } }