// get user profile
UserProfile profile = null;
try {
profile = profileManager.getUserProfile(getID(), true);
} catch (GetFailedException e) {
throw new ProcessExecutionException("Could not get user profile.", e);
}
index = profile.getFileByPath(file, root);
// validate
if (index == null) {
throw new ProcessExecutionException("File index not found in user profile");
} else if (!index.canWrite()) {
throw new ProcessExecutionException("Not allowed to delete this file (read-only permissions)");
}
// check preconditions
if (index.isFolder()) {
FolderIndex folder = (FolderIndex) index;
if (!folder.getChildren().isEmpty()) {
throw new ProcessExecutionException("Cannot delete a directory that is not empty.");
}
}
// remove the node from the tree
FolderIndex parentIndex = index.getParent();
parentIndex.removeChild(index);
// store for later
context.provideIndex(index);
context.setParentNode(parentIndex);
// store for rollback
this.parentIndexKey = parentIndex.getFilePublicKey();
try {
profileManager.readyToPut(profile, getID());
} catch (PutFailedException e) {
throw new ProcessExecutionException("Could not put user profile.");
}
if (index.isFile()) {
/**
* Delete the meta file and all chunks