handlerFactory.getDocumentHandler(node.getType()).removeDocument((Document)node);
}
catch (Exception e)
{
File documentFile = new File(this.documentRootDir, node.getPath());
throw new FailedToDeleteFolderException(documentFile.getAbsolutePath()+" document cannot be deleted.");
}
}
((NodeSetImpl)folderImpl.getAllNodes()).remove(node);
}
}
catch (FailedToDeleteFolderException fdfe)
{
throw fdfe;
}
catch (Exception e)
{
throw new FailedToDeleteFolderException(e.getMessage());
}
// remove underlying folder and unknown files
File folderFile = new File(this.documentRootDir, path);
File metadataFile = null;
if ((folderImpl.getFolderMetaData() != null) && (folderImpl.getFolderMetaData().getPath() != null))
{
metadataFile = new File(this.documentRootDir, folderImpl.getFolderMetaData().getPath());
}
if (folderFile.exists() && folderFile.isDirectory())
{
// attempt to clean folder for delete
String[] contents = folderFile.list();
for (int i = 0; (i < contents.length); i++)
{
File contentFile = new File(folderFile, contents[i]);
if ((metadataFile == null) || !contentFile.equals(metadataFile))
{
if (!deleteFile(contentFile))
{
throw new FailedToDeleteFolderException(folderFile.getAbsolutePath()+" unrecognized folder contents cannot be deleted.");
}
}
}
// delete folder and metadata
if ((metadataFile != null) && metadataFile.exists() && !metadataFile.delete())
{
throw new FailedToDeleteFolderException(folderFile.getAbsolutePath()+" folder metadata cannot be deleted.");
}
// delete folder and all remaining folder contents
// unless folder is root folder which should be
// preserved as PSML "mount point"
if (!path.equals(Folder.PATH_SEPARATOR) && !folderFile.delete())
{
throw new FailedToDeleteFolderException(folderFile.getAbsolutePath()+" folder cannot be deleted.");
}
}
else
{
throw new FailedToDeleteFolderException(folderFile.getAbsolutePath()+" not found.");
}
// remove from cache
fileCache.remove(path);