UserPreferencesManager upm = (UserPreferencesManager) ui.getPreferencesManager();
IUserLayoutManager ulm = upm.getUserLayoutManager();
// element ID of the tab to be renamed
String tabId = request.getParameter("tabId");
IUserLayoutFolderDescription tab = (IUserLayoutFolderDescription) ulm
.getNode(tabId);
// desired new name
String tabName = request.getParameter("tabName");
if (!ulm.canUpdateNode(tab)) {
log.warn("Attempting to rename an immutable tab");
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return null;
}
/*
* Update the tab and save the layout
*/
tab.setName(StringUtils.isBlank(tabName) ? DEFAULT_TAB_NAME : tabName);
final boolean updated = ulm.updateNode(tab);
if (updated) {
try {
// save the user's layout