DocumentCollection: warning! 18 Feb 2004
Uh oh. I wonder if this is a bug in the Domino Java classes. Here’s one for you to try. This morning, Stefan Kassal posted a query on the Lotus Developer Domain entitled “Max parameter in db.search() in java does strange things…”. I was intrigued and set out to test his claim. Sure enough, an object implementing the DocumentCollection interface behaves in an unexpected way, with potentially catastrophic results. This is in both releases 5.x and 6.5.
Here’s how to try this out. Create some dummy documents using the same form for all, noting how many documents you create. You should then knock up an agent to get a DocumentCollection handle on just some of these documents. See what happens when you call the removeAll(true) method:
Session session = getSession();
AgentContext ac = session.getAgentContext();
Database db = ac.getCurrentDatabase();
String formula = "Form=\"YOUR_FORM_NAME\"";
// Number to include in collection must be less
// than total # of docs in db using form
DocumentCollection dc = db.search(formula, null, 10);
// Works as expected:
int count = dc.getCount();
System.out.println("Doc count is " + count);
// Doesn't work as expected:
dc.removeAll(true);
Eeek! Can’t be right, surely?