use of com.adobe.acs.commons.fam.actions.ActionBatch in project acs-aem-commons by Adobe-Consulting-Services.
the class DeepPrune method purgeJobs.
private void purgeJobs(ActionManager manager) {
ActionBatch batch = new ActionBatch(manager, batchSize);
batch.setRetryCount(retryCount);
batch.setRetryWait(retryWait);
TreeFilteringResourceVisitor visitor = new TreeFilteringResourceVisitor();
visitor.setDepthFirstMode();
visitor.setTraversalFilter(res -> visitor.isFolder(res) && !shouldIgnore(res));
AtomicInteger lastLevel = new AtomicInteger(0);
visitor.setResourceVisitor((res, level) -> {
if (level >= minPurgeDepth && !shouldIgnore(res) && folderRule.matcher.apply(res.getName())) {
if (lastLevel.getAndSet(level) != level) {
batch.commitBatch();
}
String path = res.getPath();
batch.add(rr -> deleteResource(rr, path));
}
});
visitor.setLeafVisitor((res, level) -> {
if (!shouldIgnore(res)) {
if (lastLevel.getAndSet(level) != level) {
batch.commitBatch();
}
String path = res.getPath();
batch.add(rr -> deleteResource(rr, path));
}
});
manager.deferredWithResolver(rr -> {
Resource res = rr.getResource(startingFolder);
if (res != null) {
visitor.accept(res);
}
batch.commitBatch();
});
}
use of com.adobe.acs.commons.fam.actions.ActionBatch in project acs-aem-commons by Adobe-Consulting-Services.
the class FolderRelocator method moveNodes.
private void moveNodes(ActionManager step3) {
ActionBatch batch = new ActionBatch(step3, batchSize);
batch.setRetryCount(10);
TreeFilteringResourceVisitor folderVisitor = new TreeFilteringResourceVisitor();
folderVisitor.setBreadthFirstMode();
folderVisitor.setLeafVisitor((res, level) -> {
String path = res.getPath();
if (!path.endsWith("jcr:content")) {
batch.add(rr -> moveItem(rr, path));
}
});
sourceToDestination.keySet().forEach(sourcePath -> beginStep(step3, sourcePath, folderVisitor));
batch.commitBatch();
}
Aggregations