public static Page toPageModel(UIPage uiPage) { Page model = new Page(uiPage.getStorageId()); toContainer(model, uiPage); model.setOwnerId(uiPage.getSiteKey().getName()); model.setOwnerType(uiPage.getSiteKey().getTypeName()); model.setIcon(uiPage.getIcon()); model.setPageId(uiPage.getPageId()); model.setTitle(uiPage.getTitle()); model.setAccessPermissions(uiPage.getAccessPermissions()); model.setEditPermission(uiPage.getEditPermission()); model.setFactoryId(uiPage.getFactoryId()); model.setShowMaxWindow(uiPage.isShowMaxWindow()); model.setModifiable(uiPage.isModifiable()); return model; }
public void invokeSetBindingBean(Object bean) throws Exception { String ownerType = getUIFormSelectBox("ownerType").getValue(); String ownerId = getUIStringInput("ownerId").getValue(); // As ownerId is now normalized, we have to maker sure that owenerId of 'group' type starts with // a '/' if (PortalConfig.GROUP_TYPE.equals(ownerType) && ownerId.charAt(0) != '/') { ownerId = "/" + ownerId; } Page page = (Page) bean; page.setPageId(getUIStringInput("pageId").getValue()); page.setOwnerType(ownerType); page.setOwnerId(ownerId); page.setName(getUIStringInput("name").getValue()); String title = getUIStringInput("title").getValue(); if (title == null || title.trim().length() < 1) title = page.getName(); page.setTitle(title); if (!page.isShowMaxWindow()) { page.setShowMaxWindow((Boolean) getUIFormCheckBoxInput("showMaxWindow").getValue()); } if (!PortalConfig.USER_TYPE.equals(page.getOwnerType())) { page.setAccessPermissions( uiPermissionSetting.getChild(UIListPermissionSelector.class).getValue()); page.setEditPermission(uiPermissionSetting.getChild(UIPermissionSelector.class).getValue()); } UserACL userACL = getApplicationComponent(UserACL.class); userACL.hasPermission(page); UIFormInputItemSelector uiTemplate = getChildById("Template"); if (uiTemplate != null) { SelectItemOption<?> itemOption = uiTemplate.getSelectedItemOption(); if (itemOption != null) { page.setFactoryId(itemOption.getIcon()); // page.setTemplate((String)itemOption.getValue()); if (page.getFactoryId().equals(Page.DESKTOP_PAGE)) page.setShowMaxWindow(true); } } UIPageTemplateOptions uiConfigOptions = getChild(UIPageTemplateOptions.class); if (uiConfigOptions == null) return; Page selectedPage = uiConfigOptions.createPageFromSelectedOption(page.getOwnerType(), page.getOwnerId()); if (selectedPage == null) return; page.setChildren(selectedPage.getChildren()); page.setFactoryId(selectedPage.getFactoryId()); if (Page.DESKTOP_PAGE.equals(page.getFactoryId())) page.setShowMaxWindow(true); }
/** * Rename page node. * * @param newNodeLabel * @param space * @return * @since 1.2.8 */ private UserNode renamePageNode(String newNodeLabel, Space space) { UserPortalConfigService configService = getApplicationComponent(UserPortalConfigService.class); DataStorage dataService = getApplicationComponent(DataStorage.class); try { UserNode renamedNode = SpaceUtils.getSpaceUserNode(space); UserNode parentNode = renamedNode.getParent(); String newNodeName = SpaceUtils.cleanString(newNodeLabel); if (parentNode.getChild(newNodeName) != null) { newNodeName = newNodeName + "_" + System.currentTimeMillis(); } // renamedNode.setLabel(newNodeLabel); renamedNode.setName(newNodeName); Page page = dataService.getPage(renamedNode.getPageRef().format()); if (page != null) { page.setTitle(newNodeLabel); dataService.save(page); } SpaceUtils.getUserPortal().saveNode(parentNode, null); space.setUrl(newNodeName); SpaceUtils.changeSpaceUrlPreference(renamedNode, space, newNodeLabel); List<UserNode> userNodes = new ArrayList<UserNode>(renamedNode.getChildren()); for (UserNode childNode : userNodes) { SpaceUtils.changeSpaceUrlPreference(childNode, space, newNodeLabel); } return renamedNode; } catch (Exception e) { LOG.warn(e.getMessage(), e); return null; } }