Package org.apache.sling.api.resource
Class ResourceUtil.BatchResourceRemover
java.lang.Object
org.apache.sling.api.resource.ResourceUtil.BatchResourceRemover
- Enclosing class:
ResourceUtil
A batch resource remover deletes resources in batches. Once the batch
size (threshold) is reached, an intermediate commit is performed. Resource
trees are deleted resource by resource starting with the deepest children first.
Once all resources have been passed to the batch resource remover, a final
commit needs to be called on the resource resolver.
- Since:
- 2.6 (Sling API Bundle 2.8.0)
-
Constructor Summary
ConstructorsConstructorDescriptionBatchResourceRemover(int batchSize) Creates a remover that commits after each batch of deleted resources. -
Method Summary
-
Constructor Details
-
BatchResourceRemover
public BatchResourceRemover(int batchSize) Creates a remover that commits after each batch of deleted resources.- Parameters:
batchSize- The batch size, or a value less than one to use the default of 50
-
-
Method Details
-
delete
Deletes a resource and its descendants, committing whenever the batch size is reached. CallResourceResolver.commit()afterwards to persist any remaining deletions.- Parameters:
rsrc- The resource to delete- Throws:
PersistenceException- If deleting a resource or committing a batch fails
-