Examples: LastFTIndexed property (Database - Java)

  1. This agent prints the last update date of the full-text index for the current database if it has an index.
    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();
          if (db.isFTIndexed()) {
            DateTime dt = db.getLastFTIndexed();
            System.out.println("Database \"" + title + 
                  "\" last full-text indexed on " + 
                  dt.getDateOnly()); }
          else
            System.out.println("Database \"" + title +
            "\" is not full-text indexed");
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }
  2. This agent is the same as the preceding one but checks the return value of getLastFTIndexed for existence of the index, allowing for both local and remote implementations.
    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 dt = db.getLastFTIndexed();
          if (dt != null && dt.getLocalTime().length() > 0)
            System.out.println("Database \"" + title + 
                  "\" last full-text indexed on " + 
                  dt.getDateOnly()); }
          else
            System.out.println("Database \"" + title +
            "\" is not full-text indexed");
        } catch(Exception e) {
          e.printStackTrace();
        }
      }
    }