FileType docType = getUserSelectedNode().getDocType();
if (getUserSelectedNode().getDocType() == FileType.Folder)
{
Folder sourceFolder = getJetspeedFolder(oldPath);
Node sourceParentNode = sourceFolder.getParent();
try
{
String destFolderPath = newPath + JETSPEED_PATH_SEPRATOR + newName;
getServiceLocator().getPageManager().deepCopyFolder(sourceFolder, destFolderPath, getFolderOwner(sourceFolder));
Folder destFolder = getServiceLocator().getPageManager().getFolder(destFolderPath);
if (destFolder.getParent() != null)
{
setFolderTreeNodeLoadedByPath(destFolder.getParent(), false);
}
if (!copy)
{
folderAction(sourceFolder, REMOVE_ACTION);
if (sourceParentNode != null)
{
setFolderTreeNodeLoadedByPath(sourceParentNode, false);
}
}
}
catch (Exception e)
{
log.error("Failed to copy folder.", e);
}
}
else if (docType == FileType.Page)
{
Page sourcePage = getJetspeedPage(oldPath);
Node sourceParentNode = sourcePage.getParent();
try
{
Page newPage = getServiceLocator().getPageManager().copyPage(sourcePage, newPath + JETSPEED_PATH_SEPRATOR + newName, copyIds);
PageAction(newPage, SAVE_ACTION);
if (newPage.getParent() != null)
{
setFolderTreeNodeLoadedByPath(newPage.getParent(), false);
}
if (!copy)
{
PageAction(sourcePage, REMOVE_ACTION);
if (sourceParentNode != null)
{
setFolderTreeNodeLoadedByPath(sourceParentNode, false);
}
}
}
catch (NodeException e)
{
log.error("Failed to copy page.", e);
}
}
else if (docType == FileType.Link)
{
Link sourceLink = getJetspeedLink(oldPath);
Node sourceParentNode = sourceLink.getParent();
try
{
Link newLink = getServiceLocator().getPageManager().copyLink(sourceLink, newPath + JETSPEED_PATH_SEPRATOR + newName);
linkAction(newLink, SAVE_ACTION);