return nodeName.toString();
}
public UserNode renamePageNode(String nodeName, String newNodeLabel) {
try {
UserNode parentNode = getParentTab();
if (parentNode == null || parentNode.getChild(nodeName) == null) {
return null;
}
String newNodeName = buildName(newNodeLabel);
if (parentNode.getChild(newNodeName) != null) {
newNodeName = newNodeName + "_" + System.currentTimeMillis();
}
UserNode renamedNode = parentNode.getChild(nodeName);
renamedNode.setName(newNodeName);
// Distinguish between "Extended label mode" and basic label mode.
// In "Extended label mode" node.getLabel() == null.
if (renamedNode.getLabel() != null) {
renamedNode.setLabel(newNodeLabel);
} else {
renamedNode.setResolvedLabel(newNodeLabel);
}
// Rename the page only in basic label mode.
// For "Extended label mode" use page editor.
if (renamedNode.getPageRef() != null && renamedNode.getLabel() != null) {
PageContext page = configService.getPageService().loadPage(renamedNode.getPageRef());
if (page != null) {
PageState state = page.getState();
String encodedLabel = HTMLEntityEncoder.getInstance().encode(newNodeLabel);
page.setState(state.builder().displayName(encodedLabel).build());
configService.getPageService().savePage(page);
// Update UIPage cache on UIPortal.
uiPortal.setUIPage(renamedNode.getPageRef().format(), null);
}
}
getUserPortal().saveNode(parentNode, null);
return renamedNode;