{
try
{
// dereference folder in case proxy is supplied
folder = (Folder)ProxyHelper.getRealObject(folder);
FolderImpl folderImpl = (FolderImpl)folder;
// look up and set parent folder if required
FolderImpl parent = (FolderImpl)folder.getParent();
if ((parent == null) && !folder.getPath().equals(Folder.PATH_SEPARATOR))
{
// access folder by path
String folderPath = folder.getPath();
String parentPath = folderPath.substring(0, folderPath.lastIndexOf(Folder.PATH_SEPARATOR));
if (parentPath.length() == 0)
{
parentPath = Folder.PATH_SEPARATOR;
}
try
{
parent = (FolderImpl)getFolder(parentPath);
}
catch (FolderNotFoundException fnfe)
{
throw new FolderNotUpdatedException("Missing parent folder: " + parentPath);
}
// check for edit access on parent folder; folder
// access not checked on create
parent.checkAccess(JetspeedActions.EDIT);
// update folder and mark cache transaction
folder.setParent(parent);
storeEntity(folder, folderPath, true);
// reset parent folder folders cache
parent.resetFolders(false);
// notify page manager listeners
delegator.notifyNewNode(folder);
}
else
{
// determine if folder is new by checking autoincrement id
boolean newFolder = (folderImpl.getIdentity() == 0);
// check for edit access on folder and parent folder
// if not being initially created; access is not
// checked on create
String folderPath = folder.getPath();
if (!newFolder || !folderPath.equals(Folder.PATH_SEPARATOR))
{
folder.checkAccess(JetspeedActions.EDIT);
}
// create root folder or update folder and mark cache transaction
storeEntity(folder, folderPath, (newFolder && (folderImpl.getIdentity() != 0)));
// reset parent folder folders cache in case
// parent is holding an out of date copy of
// this folder that was removed from the cache
// before this one was accessed
if (parent != null)
{
parent.resetFolders(false);
}
// notify page manager listeners
if (newFolder && (folderImpl.getIdentity() != 0))
{