Boolean allVersions, UnfileObject unfileObjects, Boolean continueOnFailure, ExtensionsData extension) {
LOG.debug("start deleteTree()");
StoredObject so = validator.deleteTree(context, repositoryId, folderId, allVersions, unfileObjects, extension);
List<String> failedToDeleteIds = new ArrayList<String>();
FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
if (null == allVersions) {
allVersions = true;
}
if (null == unfileObjects) {
unfileObjects = UnfileObject.DELETE;
}
if (null == continueOnFailure) {
continueOnFailure = false;
}
ObjectStore objectStore = fStoreManager.getObjectStore(repositoryId);
if (null == so) {
throw new CmisInvalidArgumentException("Cannot delete object with id " + folderId + ". Object does not exist.");
}
if (!(so instanceof Folder)) {
throw new CmisInvalidArgumentException("deleteTree can only be invoked on a folder, but id " + folderId
+ " does not refer to a folder");
}
if (unfileObjects == UnfileObject.UNFILE) {
throw new CmisNotSupportedException("This repository does not support unfile operations.");
}
// check if it is the root folder
if (folderId.equals(objectStore.getRootFolder().getId())) {
throw new CmisNotSupportedException("You can't delete a root folder");
}
// recursively delete folder
deleteRecursive(objectStore, (Folder) so, continueOnFailure, allVersions, failedToDeleteIds, context.getUsername());
result.setIds(failedToDeleteIds);
LOG.debug("stop deleteTree()");
return result;
}