例: updateFTIndex method

次のエージェントは、現在のデータベースの全文索引がこの 2 日間に更新されていない場合に、索引を更新します。

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();
      String title = db.getTitle();
      DateTime lastDT = db.getLastFTIndexed();
      DateTime nowDT = session.createDateTime("Today");
      nowDT.setNow();
      int daysSince = 
          nowDT.timeDifference(lastDT) / 86400;
      if (daysSince > 2) {
        System.out.println("Database ¥"" + title +
                "¥" was last full-text indexed " + 
                 daysSince + " days ago");
        System.out.println("Updating");
        db.updateFTIndex(true); }
      else
        System.out.println("Database ¥"" + title +
             "¥" was full-text indexed less 
              than two days ago");
        
    } catch(Exception e) {
      e.printStackTrace();
    }
  }
}