public void crawlDirectDatasets(InvDataset ds, CancelTask task, PrintStream out, Object context, boolean release) {
boolean isCatRef = (ds instanceof InvCatalogRef);
boolean skipScanChildren = skipDatasetScan && (ds instanceof InvCatalogRef) && (ds.findProperty("DatasetScan") != null);
if (isCatRef) {
InvCatalogRef catref = (InvCatalogRef) ds;
if (out != null)
out.println(" **CATREF " + catref.getURI() + " (" + ds.getName() + ") ");
countCatrefs++;
if (!listen.getCatalogRef( catref, context)) {
if (release) catref.release();
return;
}
}
// get datasets with data access ("leaves")
List<InvDataset> dlist = ds.getDatasets();
List<InvDataset> leaves = new ArrayList<InvDataset>();
for (InvDataset dds : dlist) {
if (dds.hasAccess())
leaves.add(dds);
}
if (leaves.size() > 0) {
if (type == USE_FIRST_DIRECT) {
InvDataset dds = (InvDataset) leaves.get(0);
listen.getDataset(dds, context);
} else if (type == USE_RANDOM_DIRECT) {
listen.getDataset(chooseRandom(leaves), context);
} else if (type == USE_RANDOM_DIRECT_NOT_FIRST_OR_LAST) {
listen.getDataset(chooseRandomNotFirstOrLast(leaves), context);
} else { // do all of them
for (InvDataset dds : leaves) {
listen.getDataset(dds, context);
if ((task != null) && task.isCancel()) break;
}
}
}
// recurse
if (!skipScanChildren) {
for (InvDataset dds : dlist) {
if (dds.hasNestedDatasets())
crawlDirectDatasets(dds, task, out, context, release);
if ((task != null) && task.isCancel())
break;
}
}
/* if (out != null) {
int took = (int) (System.currentTimeMillis() - start);
out.println(" ** " + ds.getName() + " took " + took + " msecs\n");
} */
if (ds instanceof InvCatalogRef && release) {
InvCatalogRef catref = (InvCatalogRef) ds;
catref.release();
}
}