Examples of PortalRequestContext


Examples of org.exoplatform.portal.application.PortalRequestContext

* @version $Revision$
*/
public class UIPageActionListener {
    public static class ChangeNodeActionListener extends EventListener<UIPortalApplication> {
        public void execute(Event<UIPortalApplication> event) throws Exception {
            PortalRequestContext pcontext = PortalRequestContext.getCurrentInstance();
            UserPortal userPortal = pcontext.getUserPortalConfig().getUserPortal();
            UIPortalApplication uiPortalApp = event.getSource();
            UIPortal showedUIPortal = uiPortalApp.getCurrentSite();

            UserNodeFilterConfig.Builder builder = UserNodeFilterConfig.builder();
            builder.withReadCheck();

            PageNodeEvent<UIPortalApplication> pageNodeEvent = (PageNodeEvent<UIPortalApplication>) event;
            String nodePath = pageNodeEvent.getTargetNodeUri();

            UserNode targetNode = null;
            SiteKey siteKey = pageNodeEvent.getSiteKey();
            if (siteKey != null) {
                if (pcontext.getRemoteUser() == null
                        && (siteKey.getType().equals(SiteType.GROUP) || siteKey.getType().equals(SiteType.USER))) {
                    NavigationService service = uiPortalApp.getApplicationComponent(NavigationService.class);
                    NavigationContext navContext = service.loadNavigation(siteKey);
                    if (navContext != null) {
                        uiPortalApp.setLastRequestNavData(null);
                        pcontext.requestAuthenticationLogin();
                        return;
                    }
                }

                UserNavigation navigation = userPortal.getNavigation(siteKey);
                if (navigation != null) {
                    targetNode = userPortal.resolvePath(navigation, builder.build(), nodePath);
                    if (targetNode == null) {
                        // If unauthenticated users have no permission on PORTAL node and URL is valid, they will be required to
                        // login
                        if (pcontext.getRemoteUser() == null && siteKey.getType().equals(SiteType.PORTAL)) {
                            targetNode = userPortal.resolvePath(navigation, null, nodePath);
                            if (targetNode != null) {
                                uiPortalApp.setLastRequestNavData(null);
                                pcontext.requestAuthenticationLogin();
                                return;
                            }
                        } else {
                            // If path to node is invalid, get the default node instead of.
                            targetNode = userPortal.getDefaultPath(navigation, builder.build());
                        }
                    }
                }
            }

            if (targetNode == null) {
                targetNode = userPortal.getDefaultPath(builder.build());
                if (targetNode == null) {
                    if (showedUIPortal != null) {
                        UIPageBody uiPageBody = showedUIPortal.findFirstComponentOfType(UIPageBody.class);
                        uiPageBody.setUIComponent(null);
                    }
                    return;
                }
            }

            UserNavigation targetNav = targetNode.getNavigation();
            UserNode currentNavPath = null;
            if (showedUIPortal != null) {
                currentNavPath = showedUIPortal.getNavPath();
            }

            if (currentNavPath != null && currentNavPath.getNavigation().getKey().equals(targetNav.getKey())) {
                // Case 1: Both navigation type and id are not changed, but current page node is changed and it is not a first
                // request.
                if (!currentNavPath.getURI().equals(targetNode.getURI())) {
                    showedUIPortal.setNavPath(targetNode);
                }
            } else {
                // Case 2: Either navigation type or id has been changed
                // First, we try to find a cached UIPortal
                UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
                uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
                uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
                showedUIPortal = uiPortalApp.getCachedUIPortal(targetNav.getKey());
                if (showedUIPortal != null) {
                    showedUIPortal.setNavPath(targetNode);
                    uiPortalApp.setCurrentSite(showedUIPortal);

                    DataStorage storageService = uiPortalApp.getApplicationComponent(DataStorage.class);
                    PortalConfig associatedPortalConfig = storageService.getPortalConfig(targetNav.getKey().getTypeName(),
                            targetNav.getKey().getName());
                    UserPortalConfig userPortalConfig = pcontext.getUserPortalConfig();

                    // Update layout-related data on UserPortalConfig
                    userPortalConfig.setPortalConfig(associatedPortalConfig);
                } else {
                    showedUIPortal = buildUIPortal(targetNav.getKey(), uiPortalApp, pcontext.getUserPortalConfig());
                    if (showedUIPortal == null) {
                        return;
                    }
                    showedUIPortal.setNavPath(targetNode);
                    uiPortalApp.setCurrentSite(showedUIPortal);
                    uiPortalApp.putCachedUIPortal(showedUIPortal);
                }
            }

            showedUIPortal.refreshUIPage();
            pcontext.setFullRender(true);
            pcontext.addUIComponentToUpdateByAjax(uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID));
        }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

        }
    }

    public static class CreatePortalActionListener extends EventListener<UIWorkingWorkspace> {
        public void execute(Event<UIWorkingWorkspace> event) throws Exception {
            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIPortalApplication uiApp = event.getSource().getAncestorOfType(UIPortalApplication.class);
            UserACL userACL = uiApp.getApplicationComponent(UserACL.class);
            if (!userACL.hasCreatePortalPermission()) {
                uiApp.addMessage(new ApplicationMessage("UIPortalBrowser.msg.Invalid-createPermission", null));
                return;
            }
            UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
            UIPortalForm uiNewPortal = uiMaskWS.createUIComponent(UIPortalForm.class, "CreatePortal", "UIPortalForm");
            uiNewPortal.initPortalTemplateTab();
            uiMaskWS.setUIComponent(uiNewPortal);
            uiMaskWS.setShow(true);
            prContext.addUIComponentToUpdateByAjax(uiMaskWS);
        }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

        }
    }

    public abstract static class MoveActionListener extends EventListener<UITabContainer> {
        public void doMove(Event<UITabContainer> event, boolean isToLeft) {
            PortalRequestContext context = (PortalRequestContext) event.getRequestContext();
            UITabContainer container = event.getSource();
            String objectId = event.getRequestContext().getRequestParameter(OBJECTID);
            if (container == null || objectId == null) {
                return;
            }
            container.moveTab(container, objectId, isToLeft);
            context.addUIComponentToUpdateByAjax(container);
            context.ignoreAJAXUpdateOnPortlets(true);
            context.getJavascriptManager().require("SHARED/portalComposer", "portalComposer")
                    .addScripts("portalComposer.toggleSaveButton();");
        }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

    public static class AddTabActionListener extends EventListener<UITabContainer> {
        @Override
        public void execute(Event<UITabContainer> event) throws Exception {
            UITabContainer container = event.getSource();
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
            if (container == null) {
                return;
            }

            List<UIComponent> children = container.getChildren();
            for (UIComponent child : children) {
                if (child.isRendered() && child instanceof UIContainer) {
                    UIContainer newTabContainer = container.addChild(UIContainer.class, null, null);
                    newTabContainer.setTemplate(child.getTemplate());
                    child.setRendered(false);
                    newTabContainer.setRendered(true);
                    newTabContainer.setId(String.valueOf(Math.abs(newTabContainer.hashCode())));
                    pcontext.addUIComponentToUpdateByAjax(container);
                    pcontext.ignoreAJAXUpdateOnPortlets(true);
                    pcontext.getJavascriptManager().require("SHARED/portalComposer", "portalComposer")
                            .addScripts("portalComposer.toggleSaveButton();");
                    return;
                }
            }
        }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

         * to a separate writer first, then render the UIPortalApplication page as normal, outputting the contents of the
         * separate writer where the child elements should be rendered. Its messy but required for portlet markup header
         * setting.
         */

        PortalRequestContext prc = (PortalRequestContext) context;
        OutputStream responseOutputStream = prc.getResponse().getOutputStream();

        PortalPrinter parentWriter = new PortalPrinter(responseOutputStream, true, 5000);
        PortalPrinter childWriter = new PortalPrinter(responseOutputStream, true, 25000, true);

        context.setWriter(childWriter);
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

     *
     * @param context the context
     */
    public static void updatePortal(PortletRequestContext context) {
        UIPortalApplication portalApplication = Util.getUIPortalApplication();
        PortalRequestContext portalRequestContext = (PortalRequestContext) context.getParentAppRequestContext();
        UIWorkingWorkspace uiWorkingWS = portalApplication.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
        portalRequestContext.addUIComponentToUpdateByAjax(uiWorkingWS);
        portalRequestContext.ignoreAJAXUpdateOnPortlets(true);
    }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

        UIFormInputThemeSelector uiThemeSelector = new UIFormInputThemeSelector(FIELD_THEME, null);
        SkinService skinService = getApplicationComponent(SkinService.class);
        uiThemeSelector.getChild(UIItemThemeSelector.class).setValues(skinService.getPortletThemes());
        addUIFormInput(uiThemeSelector);

        PortalRequestContext prc = Util.getPortalRequestContext();
        if (prc.getSiteType() != SiteType.USER) {
            UIListPermissionSelector uiListPermissionSelector = createUIComponent(UIListPermissionSelector.class, null, null);
            uiListPermissionSelector.configure(WebuiRequestContext.generateUUID("UIListPermissionSelector"), "accessPermissions");
            uiListPermissionSelector.addValidator(EmptyIteratorValidator.class);
            UIFormInputSet uiPermissionSet = createUIComponent(UIFormInputSet.class, "PortletPermission", null);
            uiPermissionSet.addChild(uiListPermissionSelector);
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

                        dataService.save(page);
                    }
                    break;
                }
            }
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
            pcontext.ignoreAJAXUpdateOnPortlets(false);
            pcontext.setResponseComplete(true);
            pcontext.getWriter().write(EventListener.RESULT_OK);
        }
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

        return uiPortlet_.getSupportModes().contains("edit");
    }

    public String getEditModeContent() {
        try {
            PortalRequestContext prcontext = (PortalRequestContext) WebuiRequestContext.getCurrentInstance();
            prcontext.ignoreAJAXUpdateOnPortlets(true);

            PortletInvocation portletInvocation = uiPortlet_.create(RenderInvocation.class, prcontext);
            RenderInvocation renderInvocation = (RenderInvocation) portletInvocation;
            // make sure we are in the EDIT mode, and not whatever the current portlet mode is for the Portlet
            renderInvocation.setMode(Mode.create(PortletMode.EDIT.toString()));
View Full Code Here

Examples of org.exoplatform.portal.application.PortalRequestContext

    public static class RemoveChildActionListener extends EventListener<UIPage> {
        public void execute(Event<UIPage> event) throws Exception {
            UIPage uiPage = event.getSource();
            String id = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
            if (uiPage.isModifiable()) {
                uiPage.removeChildById(id);
                Page page = (Page) PortalDataMapper.buildModelObject(uiPage);
                if (page.getChildren() == null) {
                    page.setChildren(new ArrayList<ModelObject>());
                }

                //
                PageService pageService = uiPage.getApplicationComponent(PageService.class);
                PageState pageState = new PageState(page.getTitle(), page.getDescription(), page.isShowMaxWindow(),
                        page.getFactoryId(), page.getAccessPermissions() != null ? Arrays.asList(page.getAccessPermissions())
                                : null, page.getEditPermission());
                pageService.savePage(new PageContext(page.getPageKey(), pageState));

                //
                DataStorage dataService = uiPage.getApplicationComponent(DataStorage.class);
                dataService.save(page);

                //
                pcontext.ignoreAJAXUpdateOnPortlets(false);
                pcontext.setResponseComplete(true);
                pcontext.getWriter().write(EventListener.RESULT_OK);
            } else {
                org.exoplatform.webui.core.UIApplication uiApp = pcontext.getUIApplication();
                uiApp.addMessage(new ApplicationMessage("UIPage.msg.EditPermission.null", null));
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.