throws UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException, StorageException
{
List<String> shadowPaths = transformMaster2Shadow(item.getPath());
if (shadowPaths != null && !shadowPaths.isEmpty()) {
ResourceStoreRequest req = new ResourceStoreRequest(shadowPaths.get(0));
req.getRequestContext().setParentContext(item.getItemContext());
try {
deleteItem(false, req);
}
catch (ItemNotFoundException e) {
// NEXUS-5673: just ignore it silently, this might happen when
// link to be deleted was not found in shadow (like a parent folder was deleted
// or M2 checksum file in master)
// simply ignoring this is okay, as our initial goal is to lessen log spam.
// If parent cleanup fails below, thats fine too, superclass with handle the
// exception. This catch here is merely to logic continue with empty parent cleanup
}
// we need to clean up empty shadow parent directories
String parentPath =
req.getRequestPath().substring(0, req.getRequestPath().lastIndexOf(item.getName()));
ResourceStoreRequest parentRequest = new ResourceStoreRequest(parentPath);
while (parentRequest != null) {
StorageItem parentItem = null;
parentItem = this.retrieveItem(false, parentRequest);
// this should be a collection Item
if (StorageCollectionItem.class.isInstance(parentItem)) {
StorageCollectionItem parentCollectionItem = (StorageCollectionItem) parentItem;
try {
if (parentCollectionItem.list().size() == 0) {
deleteItem(false, parentRequest);
parentRequest = new ResourceStoreRequest(parentCollectionItem.getParentPath());
}
else {
// exit loop
parentRequest = null;
}