Package org.exoplatform.portal.webui.workspace

Examples of org.exoplatform.portal.webui.workspace.UIPortalApplication


        }
    }

    public static class ChangeApplicationListActionListener extends EventListener<UIPortal> {
        public void execute(Event<UIPortal> event) throws Exception {
            UIPortalApplication application = Util.getUIPortalApplication();
            UIPortalComposer composer = application.findFirstComponentOfType(UIPortalComposer.class);
            UITabPane uiTabPane = composer.getChild(UITabPane.class);
            String appListId = uiTabPane.getChild(UIApplicationList.class).getId();
            uiTabPane.replaceChild(appListId, composer.createUIComponent(UIApplicationList.class, null, null));
        }
View Full Code Here


            if (uiUserInfo.getUserName().equals(event.getRequestContext().getRemoteUser())) {
                UserProfileHandler hanlder = service.getUserProfileHandler();
                UserProfile userProfile = hanlder.findUserProfileByName(event.getRequestContext().getRemoteUser());
                String language = userProfile.getAttribute(Constants.USER_LANGUAGE);

                UIPortalApplication uiApp = Util.getUIPortalApplication();
                if (language == null || language.trim().length() < 1)
                    return;
                LocaleConfigService localeConfigService = event.getSource().getApplicationComponent(LocaleConfigService.class);
                LocaleConfig localeConfig = localeConfigService.getLocaleConfig(language);
                if (localeConfig == null)
                    localeConfig = localeConfigService.getDefaultLocaleConfig();
                PortalRequestContext prqCtx = Util.getPortalRequestContext();
                prqCtx.setLocale(localeConfig.getLocale());

                // GTNPORTAL-3244: A workaround to update localization in the popup messages
                ResourceBundle bundle = Util.getPortalRequestContext().getApplication().getResourceBundle(localeConfig.getLocale());
                for(AbstractApplicationMessage message : uiApp.getUIPopupMessages().getErrors()) {
                    message.setResourceBundle(bundle);
                }
                for(AbstractApplicationMessage message : uiApp.getUIPopupMessages().getWarnings()) {
                    message.setResourceBundle(bundle);
                }
                for(AbstractApplicationMessage message : uiApp.getUIPopupMessages().getInfos()) {
                    message.setResourceBundle(bundle);
                }
                Util.getPortalRequestContext().addUIComponentToUpdateByAjax(
                        uiApp.findFirstComponentOfType(UIWorkingWorkspace.class));
                Util.getPortalRequestContext().ignoreAJAXUpdateOnPortlets(true);
            }

            UIAccountEditInputSet accountInput = uiUserInfo.getChild(UIAccountEditInputSet.class);
            UIUserProfileInputSet userProfile = uiUserInfo.getChild(UIUserProfileInputSet.class);
View Full Code Here

            boolean isShowImport = uiForm.getUIFormCheckBoxInput(SHOW_IMPORT).isChecked();
            PortletRequestContext pcontext = (PortletRequestContext) WebuiRequestContext.getCurrentInstance();
            PortletPreferences pref = pcontext.getRequest().getPreferences();
            pref.setValue(SHOW_IMPORT, Boolean.toString(isShowImport));
            pref.store();
            UIPortalApplication portalApp = Util.getUIPortalApplication();
            if (portalApp.getModeState() == UIPortalApplication.NORMAL_MODE)
                pcontext.setApplicationMode(PortletMode.VIEW);

        }
View Full Code Here

    public static class CreatePageActionListener extends EventListener<UIPageNodeForm> {
        public void execute(Event<UIPageNodeForm> event) throws Exception {
            UIPageNodeForm uiForm = event.getSource();
            UIPageSelector pageSelector = uiForm.findFirstComponentOfType(UIPageSelector.class);

            UIPortalApplication uiPortalApp = Util.getUIPortalApplication();

            UIFormInputSet uiInputSet = pageSelector.getChild(UIFormInputSet.class);
            List<UIComponent> children = uiInputSet.getChildren();
            /*********************************************************************/
            for (UIComponent uiChild : children) {
                if (uiChild instanceof UIFormInputBase) {
                    UIFormInputBase uiInput = (UIFormInputBase) uiChild;
                    if (!uiInput.isValid())
                        continue;
                    List<Validator> validators = uiInput.getValidators();
                    if (validators == null)
                        continue;
                    try {
                        for (Validator validator : validators)
                            validator.validate(uiInput);
                    } catch (MessageException ex) {
                        uiPortalApp.addMessage(ex.getDetailMessage());
                        return;
                    } catch (Exception ex) {
                        // TODO: This is a critical exception and should be handle in the UIApplication
                        uiPortalApp.addMessage(new ApplicationMessage(ex.getMessage(), null));
                        return;
                    }
                }
            }

            UserACL userACL = uiForm.getApplicationComponent(UserACL.class);

            String ownerId = uiForm.getOwner();
            String[] accessPermission = new String[1];
            accessPermission[0] = "*:" + ownerId;
            String editPermission = userACL.getMakableMT() + ":" + ownerId;

            if (SiteType.PORTAL.equals(uiForm.getOwnerType())) {
                UIPortal uiPortal = Util.getUIPortal();
                accessPermission = uiPortal.getAccessPermissions();
                editPermission = uiPortal.getEditPermission();
            }

            UIFormStringInput uiPageName = uiInputSet.getChildById("pageName");
            UIFormStringInput uiPageTitle = uiInputSet.getChildById("pageTitle");

            PageState pageState = new PageState(uiPageTitle.getValue(), null, false, null,
                    accessPermission != null ? Arrays.asList(accessPermission) : null, editPermission);

            // check page is exist
            PageKey pageKey = PageKey.parse(uiForm.getOwnerType().getName() + "::" + ownerId + "::" + uiPageName.getValue());
            PageService pageService = uiForm.getApplicationComponent(PageService.class);
            PageContext existPage = pageService.loadPage(pageKey);
            if (existPage != null) {
                uiPortalApp.addMessage(new ApplicationMessage("UIPageForm.msg.sameName", null));
                return;
            }
            pageSelector.setPage(new PageContext(pageKey, pageState));
            event.getRequestContext().addUIComponentToUpdateByAjax(pageSelector);
        }
View Full Code Here

        }
    }

    public static class EditPageNodeActionListener extends BaseActionListener<UIRightClickPopupMenu> {
        public void execute(Event<UIRightClickPopupMenu> event) throws Exception {
            UIPortalApplication uiApp = Util.getUIPortalApplication();
            UIRightClickPopupMenu popupMenu = event.getSource();
            UINavigationNodeSelector uiNodeSelector = popupMenu.getAncestorOfType(UINavigationNodeSelector.class);

            String nodeID = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
            TreeNode node = uiNodeSelector.findNode(nodeID);
            try {
                node = rebaseNode(node, uiNodeSelector);
                if (node == null)
                    return;
            } catch (NavigationServiceException ex) {
                handleError(ex.getError(), uiNodeSelector);
                return;
            }

            UserPortalConfigService userService = uiNodeSelector.getApplicationComponent(UserPortalConfigService.class);

            // get selected page
            String pageId = node.getPageRef();
            PageContext pageContext = (pageId != null) ? userService.getPageService().loadPage(PageKey.parse(pageId)) : null;
            if (pageContext != null) {
                UserACL userACL = uiApp.getApplicationComponent(UserACL.class);
                if (!userACL.hasEditPermission(pageContext)) {
                    uiApp.addMessage(new ApplicationMessage("UIPageBrowser.msg.UserNotPermission", new String[] { pageId }, 1));
                    return;
                }

                uiApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
                // uiWorkingWS.setRenderedChild(UIPortalToolPanel.class);
                // uiWorkingWS.addChild(UIPortalComposer.class, "UIPageEditor",
                // null);

                UIWorkingWorkspace uiWorkingWS = uiApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
                UIPortalToolPanel uiToolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class).setRendered(true);
                uiWorkingWS.setRenderedChild(UIEditInlineWorkspace.class);

                UIPortalComposer portalComposer = uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class)
                        .setRendered(true);
                portalComposer.setShowControl(true);
                portalComposer.setEditted(false);
                portalComposer.setCollapse(false);
                portalComposer.setId("UIPageEditor");
                portalComposer.setComponentConfig(UIPortalComposer.class, "UIPageEditor");

                uiToolPanel.setShowMaskLayer(false);
                uiToolPanel.setWorkingComponent(UIPage.class, null);
                UIPage uiPage = (UIPage) uiToolPanel.getUIComponent();

                if (pageContext.getState().getDisplayName() == null)
                    pageContext.getState().builder().displayName(node.getLabel());

                Page page = userService.getDataStorage().getPage(pageId);
                pageContext.update(page);

                // convert Page to UIPage
                PortalDataMapper.toUIPage(uiPage, page);
                Util.getPortalRequestContext().addUIComponentToUpdateByAjax(uiWorkingWS);
                Util.getPortalRequestContext().ignoreAJAXUpdateOnPortlets(true);
            } else {
                uiApp.addMessage(new ApplicationMessage("UIPageNodeSelector.msg.notAvailable", null));
            }
        }
View Full Code Here

    public static class AddNavigationActionListener extends EventListener<UIGroupNavigationManagement> {
        public void execute(Event<UIGroupNavigationManagement> event) throws Exception {
            PortalRequestContext prContext = Util.getPortalRequestContext();
            // UIGroupNavigationManagement uicomp = event.getSource();
            UIPortalApplication uiApp = (UIPortalApplication) prContext.getUIApplication();
            // UIGroupNavigationPortlet uiPortlet = (UIGroupNavigationPortlet) uicomp.getParent();
            UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);

            UIAddGroupNavigation uiNewPortal = uiMaskWS.createUIComponent(UIAddGroupNavigation.class, null, null);
            uiMaskWS.setUIComponent(uiNewPortal);
            uiMaskWS.setShow(true);
            prContext.addUIComponentToUpdateByAjax(uiMaskWS);
View Full Code Here

            UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
            String defaultPortalName = service.getDefaultPortal();

            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIPortalApplication uiPortalApp = Util.getUIPortalApplication();

            if (defaultPortalName.equals(portalName)) {
                uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.delete-default-portal",
                        new String[] { defaultPortalName }, ApplicationMessage.WARNING));
                return;
            }

            DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
            UserACL acl = uicomp.getApplicationComponent(UserACL.class);

            PortalConfig pConfig = dataStorage.getPortalConfig(portalName);
            if (pConfig != null) {
                if (acl.hasPermission(pConfig)) {
                    service.removeUserPortalConfig(portalName);
                } else {
                    uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
                            new String[] { pConfig.getName() }));
                    return;
                }
            } else {
                if (uicomp.stillKeptInPageList(portalName)) {
                    uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.portal-not-exist",
                            new String[] { portalName }));
                }
                return;
            }

            if (pConfig == null && !Util.getUIPortal().getName().equals(portalName)) {
                uiPortalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-deletePermission",
                        new String[] { portalName }));
                return;
            }

            if (pConfig == null || Util.getUIPortal().getName().equals(portalName)) {
View Full Code Here

            UISiteManagement uicomp = event.getSource();
            String portalName = event.getRequestContext().getRequestParameter(OBJECTID);
            UserPortalConfigService service = uicomp.getApplicationComponent(UserPortalConfigService.class);
            DataStorage dataStorage = uicomp.getApplicationComponent(DataStorage.class);
            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIPortalApplication portalApp = (UIPortalApplication) prContext.getUIApplication();
            UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);

            PortalConfig pConfig = dataStorage.getPortalConfig(portalName);

            if (pConfig == null) {
                portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.portal-not-exist",
                        new String[] { portalName }));
                uiWorkingWS.updatePortletsByName("UserToolbarSitePortlet");
                return;
            }

            UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
            if (!userACL.hasEditPermission(pConfig)) {
                portalApp.addMessage(new ApplicationMessage("UISiteManagement.msg.Invalid-editPermission",
                        new String[] { pConfig.getName() }));
                return;
            }

            // UIEditInlineWorkspace uiEditWS = uiWorkingWS.addChild(UIEditInlineWorkspace.class, null,
            // UIPortalApplication.UI_EDITTING_WS_ID);
            UIEditInlineWorkspace uiEditWS = uiWorkingWS.getChildById(UIPortalApplication.UI_EDITTING_WS_ID);
            UIPortalComposer uiComposer = uiEditWS.getComposer().setRendered(true);
            uiComposer.setEditted(false);
            uiComposer.setCollapse(false);
            uiComposer.setShowControl(true);
            uiComposer.setComponentConfig(UIPortalComposer.class, null);
            uiComposer.setId(UIPortalComposer.UIPORTAL_COMPOSER);

            UIPortal uiPortal = Util.getUIPortal();
            uiWorkingWS.setBackupUIPortal(uiPortal);

            UIPortal editPortal = uiWorkingWS.createUIComponent(UIPortal.class, null, null);
            PortalDataMapper.toUIPortal(editPortal, pConfig);
            uiEditWS.setUIComponent(editPortal);

            // Check if edit current portal
            if (uiPortal.getName().equals(editPortal.getName())) {
                // editPortal.setSelectedNode(uiPortal.getSelectedNode());
                // editPortal.setNavigation(uiPortal.getNavigation());
                // editPortal.setSelectedPath(uiPortal.getSelectedPath());
                editPortal.setNavPath(uiPortal.getNavPath());
                UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);
                siteBody.setUIComponent(null);
            }

            editPortal.refreshUIPage();
            portalApp.setModeState(UIPortalApplication.APP_BLOCK_EDIT_MODE);
            uiWorkingWS.setRenderedChild(UIPortalApplication.UI_EDITTING_WS_ID);

            prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
            prContext.ignoreAJAXUpdateOnPortlets(true);
        }
View Full Code Here

        }
        return selectedNavigation.isModifiable();
    }

    private boolean hasEditPermissionOnPortal() {
        UIPortalApplication portalApp = Util.getUIPortalApplication();
        UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace> findComponentById(UIPortalApplication.UI_WORKING_WS_ID)
                .findFirstComponentOfType(UIPortal.class);
        UserACL userACL = portalApp.getApplicationComponent(UserACL.class);
        return userACL.hasEditPermissionOnPortal(currentUIPortal.getSiteType().getName(), currentUIPortal.getName(),
                currentUIPortal.getEditPermission());
    }
View Full Code Here

        return userACL.hasEditPermissionOnPortal(currentUIPortal.getSiteType().getName(), currentUIPortal.getName(),
                currentUIPortal.getEditPermission());
    }

    private boolean hasEditPermissionOnPage() throws Exception {
        UIPortalApplication portalApp = Util.getUIPortalApplication();
        UIWorkingWorkspace uiWorkingWS = portalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
        UIPageBody pageBody = uiWorkingWS.findFirstComponentOfType(UIPageBody.class);
        if (pageBody == null) {
            return false;
        }

        UIPage uiPage = (UIPage) pageBody.getUIComponent();
        UserACL userACL = portalApp.getApplicationComponent(UserACL.class);

        if (uiPage != null) {
            return userACL.hasEditPermissionOnPage(uiPage.getSiteKey().getTypeName(), uiPage.getSiteKey().getName(),
                    uiPage.getEditPermission());
        } else {
            UIPortal currentUIPortal = portalApp.<UIWorkingWorkspace> findComponentById(UIPortalApplication.UI_WORKING_WS_ID)
                    .findFirstComponentOfType(UIPortal.class);
            UserNode currentNode = currentUIPortal.getSelectedUserNode();
            PageKey pageKey = currentNode.getPageRef();
            if (pageKey == null) {
                return false;
            } else {
                PageService pageService = portalApp.getApplicationComponent(PageService.class);
                PageContext page = pageService.loadPage(pageKey);
                if (page == null) {
                    return false;
                } else {
                    return userACL.hasEditPermission(page);
View Full Code Here

TOP

Related Classes of org.exoplatform.portal.webui.workspace.UIPortalApplication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.