{
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
if (parent != null)
{
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);
if (newFolder && (folderImpl.getIdentity() != 0))
{
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folderPath, TransactionedOperation.ADD_OPERATION));
}
else
{
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folderPath, TransactionedOperation.UPDATE_OPERATION));
}
// 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))
{
delegator.notifyNewNode(folder);
}
else
{
delegator.notifyUpdatedNode(folder);
}
}
// update deep recursively if specified
if (deep)
{
// update recursively, (breadth first)
updateFolderNodes(folderImpl);
}
}
catch (FolderNotUpdatedException fnue)
{
throw fnue;
}
catch (SecurityException se)
{
throw se;
}
catch (Exception e)
{
throw new FolderNotUpdatedException("Folder " + folder.getPath() + " not updated.", e);
}
}