@Override
public void run() {
try {
System.out.println("Starting NotesRunner");
Session session = NotesFactory.createSession();
Long sessId = getLotusId(session);
sessionid.set(sessId);
Database db = session.getDatabase("", "names.nsf");
System.out.println("Db id:" + getLotusId(db));
int i = 0;
try {
lotus.domino.DocumentCollection allDocs = db.getAllDocuments();
System.out.println("All Collection has " + allDocs.getCount() + " documents");
int[] nids = new int[allDocs.getCount()];
lotus.domino.Document doc = allDocs.getFirstDocument();
lotus.domino.Document nextDoc = null;
while (doc != null) {
nextDoc = allDocs.getNextDocument(doc);
nids[i++] = Integer.valueOf(doc.getNoteID(), 16);
doc.recycle();
doc = nextDoc;
}
System.out.println("noteid array has " + nids.length + " entries");
allDocs.recycle();
// lotus.domino.DocumentCollection newColl = db.getModifiedDocuments(session.createDateTime(new java.util.Date()));
lotus.domino.DocumentCollection newColl = db.getAllUnreadDocuments();
System.out.println("New Coll has " + newColl.getCount() + " documents");
// lotus.domino.DocumentCollection emptyColl = db.createDocumentCollection();
newColl.intersect(nids[0]);
System.out.println("New Coll has " + newColl.getCount() + " documents");
for (int nid : nids) {
newColl.merge(nid);
}
System.out.println("Merged Collection has " + newColl.getCount() + " documents");
newColl.recycle();
} catch (Throwable t) {
t.printStackTrace();
System.out.println("Exception at loop point " + i);
}
session.recycle();
} catch (Throwable t) {
t.printStackTrace();
}
System.out.println("FINI!");
}