{
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);
getPersistenceBrokerTemplate().store(folder);
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), TransactionedOperation.ADD_OPERATION));
// 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 = folder.getId().equals("0");
// check for edit access on folder and parent folder
// if not being initially created; access is not
// checked on create
if (!newFolder || !folder.getPath().equals(Folder.PATH_SEPARATOR))
{
folder.checkAccess(JetspeedActions.EDIT);
}
// create root folder or update folder and mark cache transaction
getPersistenceBrokerTemplate().store(folder);
if (newFolder && !folder.getId().equals("0"))
{
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), TransactionedOperation.ADD_OPERATION));
}
else
{
DatabasePageManagerCache.addTransaction(new TransactionedOperation(folder.getPath(), 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 && !folder.getId().equals("0"))
{
delegator.notifyNewNode(folder);
}
else
{
delegator.notifyUpdatedNode(folder);
}
}
// update deep recursively if specified
if (deep)
{
// update recursively, (breadth first)
updateFolderNodes((FolderImpl)folder);
}
}
catch (FolderNotUpdatedException fnue)
{
throw fnue;
}
catch (SecurityException se)
{
throw se;
}
catch (Exception e)
{
throw new FolderNotUpdatedException("Folder " + folder.getPath() + " not updated.", e);
}
}