// create underlying folder if it does not exist
File folderFile = new File(documentRootDir, path);
if ((folderFile.exists() && !folderFile.isDirectory()) || (!folderFile.exists() && !folderFile.mkdir()))
{
throw new FailedToUpdateFolderException(folderFile.getAbsolutePath()+" does not exist and cannot be created.");
}
// update metadata
try
{
FolderMetaDataImpl metadata = folderImpl.getFolderMetaData();
metadata.setPath(path + Folder.PATH_SEPARATOR + FolderMetaDataImpl.DOCUMENT_TYPE);
metadataDocHandler.updateDocument(metadata);
}
catch (Exception e)
{
throw new FailedToUpdateFolderException(folderFile.getAbsolutePath()+" failed to update folder.metadata", e);
}
// add to cache
addToCache(path, folder);
}