Examples: save method (Document - Java)

This agent saves a document. The agent keeps trying if the document is not saved because someone else modified it while the program was running.

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.search("Subject = 
                    \"Test appendItemValue\"");
      if (dc.getCount() == 1) {
        Document doc = dc.getFirstDocument();
        Integer intObj = new Integer(303);
        doc.replaceItemValue("integer", intObj);
        do {} while (!doc.save(false, false, true)); }
    } catch(NotesException e) {
      e.printStackTrace();
    }
  }
}