// Request all organizations
ArrayList namePatterns = new ArrayList();
namePatterns.add("%");
BulkResponse res = bqm.findOrganizations(null, namePatterns, null, null, null, null);
// Wait until the request has completed
System.out.println("Request submitted - id = " + res.getRequestId());
while (!res.isAvailable()) {
System.out.println("Request status: " + res.getStatus());
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
}
System.out.println("Request completed");
// Process results (if any)
Collection coll = res.getCollection();
System.out.println("Request found " + coll.size());
Iterator iter = coll.iterator();
while (iter.hasNext()) {
Organization org = (Organization)iter.next();
System.out.println("\t" + org.getName().getValue());
}
// Process exceptions (if any)
Collection exceptions = res.getExceptions();
if (exceptions != null && !exceptions.isEmpty()){
System.out.println("Error while searching");
iter = exceptions.iterator();
while (iter.hasNext()) {
((Exception)iter.next()).printStackTrace(System.out);
}
}