public void execute(Event<UIAdminToolbarContainer> event) throws Exception { UIAdminToolbarContainer uicomp = event.getSource(); UserNavigation edittedNavigation = Utils.getSelectedNavigation(); WebuiRequestContext context = event.getRequestContext(); UIApplication uiApplication = context.getUIApplication(); if (edittedNavigation == null) { uiApplication.addMessage( new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null)); return; } UserACL userACL = uicomp.getApplicationComponent(UserACL.class); if (edittedNavigation.getKey().getType().equals(SiteType.PORTAL)) { String portalName = Util.getPortalRequestContext().getPortalOwner(); UserPortalConfigService configService = uicomp.getApplicationComponent(UserPortalConfigService.class); UserPortalConfig userPortalConfig = configService.getUserPortalConfig( portalName, context.getRemoteUser(), PortalRequestContext.USER_PORTAL_CONTEXT); if (userPortalConfig == null) { uiApplication.addMessage( new ApplicationMessage( "UISiteManagement.msg.portal-not-exist", new String[] {portalName})); return; } if (!userACL.hasEditPermission(userPortalConfig.getPortalConfig())) { uiApplication.addMessage( new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null)); return; } } else if (edittedNavigation.getKey().getType().equals(PortalConfig.GROUP_TYPE)) { if (!userACL.hasEditPermissionOnNavigation( SiteKey.group(edittedNavigation.getKey().getTypeName()))) { uiApplication.addMessage( new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission", null)); return; } } if (uicomp.naviManager == null) { uicomp.naviManager = uicomp.createUIComponent(UINavigationManagement.class, null, null); } Utils.createPopupWindow( uicomp, uicomp.naviManager, EDIT_NAVIGATION_POPUP_CONTAINER_ID, 400, -1, -1); uicomp.naviManager.setSiteKey(edittedNavigation.getKey()); UserPortal userPortal = getUserPortal(); UINavigationNodeSelector selector = uicomp.naviManager.getChild(UINavigationNodeSelector.class); selector.setEdittedNavigation(edittedNavigation); selector.setUserPortal(userPortal); selector.initTreeData(); context.addUIComponentToUpdateByAjax(uicomp); }
public void execute(Event<UISpaceNavigationManagement> event) throws Exception { PortalRequestContext prContext = Util.getPortalRequestContext(); UISpaceNavigationManagement uiManagement = event.getSource(); UISpaceNavigationNodeSelector uiNodeSelector = uiManagement.getChild(UISpaceNavigationNodeSelector.class); UserPortalConfigService portalConfigService = uiManagement.getApplicationComponent(UserPortalConfigService.class); UIPortalApplication uiPortalApp = (UIPortalApplication) prContext.getUIApplication(); UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID); prContext.addUIComponentToUpdateByAjax(uiWorkingWS); prContext.ignoreAJAXUpdateOnPortlets(true); UserNavigation navigation = uiNodeSelector.getEdittedNavigation(); SiteKey siteKey = navigation.getKey(); String editedOwnerId = siteKey.getName(); // Check existed UserPortalConfig userPortalConfig; if (SiteType.PORTAL.equals(siteKey.getType())) { userPortalConfig = portalConfigService.getUserPortalConfig( editedOwnerId, event.getRequestContext().getRemoteUser()); if (userPortalConfig == null) { prContext .getUIApplication() .addMessage( new ApplicationMessage( "UIPortalForm.msg.notExistAnymore", null, ApplicationMessage.ERROR)); return; } } else { userPortalConfig = portalConfigService.getUserPortalConfig( prContext.getPortalOwner(), event.getRequestContext().getRemoteUser()); } UserNavigation persistNavigation = userPortalConfig.getUserPortal().getNavigation(siteKey); if (persistNavigation == null) { prContext .getUIApplication() .addMessage( new ApplicationMessage( "UINavigationManagement.msg.NavigationNotExistAnymore", null, ApplicationMessage.ERROR)); return; } uiNodeSelector.save(); }
public boolean isSpaceManager() throws Exception { if (spaceService != null) { UserNavigation currentUserNavigation = Util.getUIPortal().getSelectedUserNode().getNavigation(); if (SiteType.GROUP.equals((currentUserNavigation.getKey().getType())) && currentUserNavigation.getKey().getName().contains("/spaces")) { String remoteUser = getUserId(); String spaceId = currentUserNavigation.getKey().getName(); Space space = spaceService.getSpaceByGroupId(spaceId); return (space != null && spaceService.hasSettingPermission(space, remoteUser)); } } return true; }
private static UserNode getEditorNode(String editorPageURI) { UserPortal userPortal = Util.getPortalRequestContext().getUserPortalConfig().getUserPortal(); List<UserNavigation> allNavs = userPortal.getNavigations(); for (UserNavigation nav : allNavs) { if (nav.getKey().getType().equals(SiteType.GROUP)) { UserNode userNode = userPortal.resolvePath(nav, null, editorPageURI); if (userNode != null) { return userNode; } } } return null; }
@Override public void execute(Event<UIPopupWindow> event) throws Exception { UIPopupWindow uiPopup = event.getSource(); UISpaceNavigationManagement uiSpaceNavManagement = uiPopup.getAncestorOfType(UISpaceNavigationManagement.class); UISpaceNavigationNodeSelector selector = uiSpaceNavManagement.getChild(UISpaceNavigationNodeSelector.class); UserNavigation contextNavigation = selector.getEdittedNavigation(); uiPopup.setShow(false); uiSpaceNavManagement.setOwner(contextNavigation.getKey().getName()); uiSpaceNavManagement.setOwnerType(contextNavigation.getKey().getTypeName()); selector.setEdittedNavigation(contextNavigation); selector.initTreeData(); event.getRequestContext().addUIComponentToUpdateByAjax(uiSpaceNavManagement); }
public void reloadTreeData() throws Exception { UserPortal userPortal = Util.getUIPortalApplication().getUserPortalConfig().getUserPortal(); SpaceService spaceService = getApplicationComponent(SpaceService.class); String spaceUrl = Utils.getSpaceUrlByContext(); Space space = spaceService.getSpaceByUrl(spaceUrl); UserNavigation groupNav = SpaceUtils.getGroupNavigation(space.getGroupId()); setOwner(groupNav.getKey().getName()); setOwnerType(groupNav.getKey().getTypeName()); UISpaceNavigationNodeSelector selector = getChild(UISpaceNavigationNodeSelector.class); selector.setEdittedNavigation(groupNav); selector.setUserPortal(userPortal); selector.initTreeData(); }
public ResourceBundle getBundle(UserNavigation navigation) { ExoContainer container = ExoContainerContext.getCurrentContainer(); ResourceBundleManager rbMgr = (ResourceBundleManager) container.getComponentInstanceOfType(ResourceBundleManager.class); Locale locale = Util.getPortalRequestContext().getLocale(); return rbMgr.getNavigationResourceBundle( locale.getLanguage(), navigation.getKey().getTypeName(), navigation.getKey().getName()); }
public static boolean hasEditPermissionOnNavigation() throws Exception { UserNavigation selectedNavigation = getSelectedNavigation(); if (selectedNavigation == null) return false; return selectedNavigation.isModifiable(); }