Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Created March 8, 2013 12:43
Show Gist options
  • Save cfalzone/5116242 to your computer and use it in GitHub Desktop.
Save cfalzone/5116242 to your computer and use it in GitHub Desktop.
private void cleanHostFromSitemapFiles(Host host){
FolderAPI folderAPI = APILocator.getFolderAPI();
FileAPI fileAPI = APILocator.getFileAPI();
Folder folder = null;
try {
folder = folderAPI.findFolderByPath(XML_SITEMAPS_FOLDER, host, systemUser, true);
} catch(Exception e) {
Logger.error(this, "Not able to find the folder", e);
return;
}
if (InodeUtils.isSet(folder.getInode())) {
List<File> files = null;
try {
files = folderAPI.getFiles(folder, systemUser, false);
} catch(Exception e) {
Logger.error(this, "Not able to get the files in the folder", e);
return;
}
for (File file : files) {
try {
fileAPI.delete((File) file, systemUser, false);
} catch(Exception e) {
Logger.error(this, "Could not delete the file: "+file.getFileName(), e);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment