Package org.exoplatform.portal.application

Examples of org.exoplatform.portal.application.PortalRequestContext


     * 3) if the requested nodePath is not equals to the current one or current page no longer exists, then an event of type
     * PageNodeEvent.CHANGE_NODE is sent to the associated EventListener; a call to super is then done.
     */
    @Override
    public void processAction(WebuiRequestContext context) throws Exception {
        PortalRequestContext pcontext = (PortalRequestContext) context;
        // String requestURI = pcontext.getRequestURI();
        RequestNavigationData requestNavData = pcontext.getNavigationData();

        boolean isAjax = pcontext.useAjax();

        if (!isAjax) {
            if (isAjaxInLastRequest) {
                isAjaxInLastRequest = false;
                if (requestNavData.equals(lastNonAjaxRequestNavData) && !requestNavData.equals(lastRequestNavData)) {
                    NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE).setNode(getCurrentSite().getSelectedUserNode());
                    pcontext.sendRedirect(nodeURL.toString());
                    return;
                }
            }
            lastNonAjaxRequestNavData = requestNavData;
        }

        isAjaxInLastRequest = isAjax;

        if (!requestNavData.equals(lastRequestNavData)) {
            lastRequestNavData = requestNavData;

            StringBuilder js = new StringBuilder("eXo.env.server.portalBaseURL=\"");
            js.append(getBaseURL()).append("\";\n");

            String url = getPortalURLTemplate();
            js.append("eXo.env.server.portalURLTemplate=\"");
            js.append(url).append("\";");

            pcontext.getJavascriptManager().require("SHARED/base").addScripts(js.toString());

            SiteKey siteKey = new SiteKey(pcontext.getSiteType(), pcontext.getSiteName());
            PageNodeEvent<UIPortalApplication> pnevent = new PageNodeEvent<UIPortalApplication>(this,
                    PageNodeEvent.CHANGE_NODE, siteKey, pcontext.getNodePath());
            broadcast(pnevent, Event.Phase.PROCESS);
        }

        if (!isAjax) {
            lastNonAjaxRequestNavData = requestNavData;
        }

        if (pcontext.isResponseComplete()) {
            return;
        }

        if (currentSite == null || currentSite.getSelectedUserNode() == null) {
            pcontext.sendError(HttpServletResponse.SC_NOT_FOUND);
        }

        super.processAction(pcontext);
    }
View Full Code Here


        }
    }

    public static class AbortSiteEditionActionListener extends EventListener<UIPortalComposer> {
        public void execute(Event<UIPortalComposer> event) throws Exception {
            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIPortalApplication uiPortalApp = (UIPortalApplication) prContext.getUIApplication();
            uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
            UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
            UIEditInlineWorkspace uiEditWS = uiWorkingWS.getChild(UIEditInlineWorkspace.class);
            uiEditWS.getComposer().setEditted(false);
            uiEditWS.setRendered(false);
            uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
            prContext.ignoreAJAXUpdateOnPortlets(true);
            UISiteBody siteBody = uiWorkingWS.findFirstComponentOfType(UISiteBody.class);

            UIPortal uiPortal = uiWorkingWS.getBackupUIPortal();
            uiPortal.refreshUIPage();
            siteBody.setUIComponent(uiPortal);

            UserNode currentNode = uiPortal.getSelectedUserNode();
            SiteKey siteKey = currentNode.getNavigation().getKey();
            PageNodeEvent<UIPortalApplication> pnevent = new PageNodeEvent<UIPortalApplication>(uiPortalApp,
                    PageNodeEvent.CHANGE_NODE, siteKey, currentNode.getURI());
            uiPortalApp.broadcast(pnevent, Event.Phase.PROCESS);

            prContext.addUIComponentToUpdateByAjax(uiWorkingWS);
            JavascriptManager jsManager = prContext.getJavascriptManager();
            jsManager.require("SHARED/portal", "portal").addScripts(
                    "eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
        }
View Full Code Here

        HttpServletResponse res = (HttpServletResponse) response;

        try {
            // Due to forwards, and includes the filter might be reentered
            // If current requestContext exists use its Locale
            PortalRequestContext context = PortalRequestContext.getCurrentInstance();
            if (context != null && context.getLocale() != null) {
                // No need to wrap if reentered
                boolean skipWrapping = currentLocale.get() != null;
                // overwrite any already set currentLocale
                currentLocale.set(context.getLocale());
                if (!skipWrapping) {
                    req = new HttpRequestWrapper(req);
                }
                chain.doFilter(req, res);
                return;
View Full Code Here

     * <div class="MarkupHeadElements"> tag f) additional scripts are in <div class="ImmediateScripts">, JS GMD modules will be loaded by
     * generated JS command on AMD js loader, and is put into PortalResponseScript block g) Then the scripts and the
     * skins to reload are set in the <div class="PortalResponseScript">
     */
    public void processRender(WebuiRequestContext context) throws Exception {
        PortalRequestContext pcontext = (PortalRequestContext) context;

        JavascriptManager jsMan = context.getJavascriptManager();
        // Add JS resource of current portal
        String portalOwner = pcontext.getPortalOwner();
        jsMan.loadScriptResource(ResourceScope.PORTAL, portalOwner);

        //
        Writer w = context.getWriter();
        if (!context.useAjax()) {
            // Support for legacy resource declaration
            jsMan.loadScriptResource(ResourceScope.SHARED, JavascriptConfigParser.LEGACY_JAVA_SCRIPT);
            // Need to add bootstrap as immediate since it contains the loader
            jsMan.loadScriptResource(ResourceScope.SHARED, "bootstrap");

            super.processRender(context);
        } else {
            UIMaskWorkspace uiMaskWS = getChildById(UIPortalApplication.UI_MASK_WS_ID);
            if (uiMaskWS.isUpdated())
                pcontext.addUIComponentToUpdateByAjax(uiMaskWS);
            if (getUIPopupMessages().hasMessage()) {
                pcontext.addUIComponentToUpdateByAjax(getUIPopupMessages());
            }

            Set<UIComponent> list = context.getUIComponentToUpdateByAjax();
            List<UIPortlet> uiPortlets = new ArrayList<UIPortlet>(3);
            List<UIComponent> uiDataComponents = new ArrayList<UIComponent>(5);

            if (list != null) {
                for (UIComponent uicomponent : list) {
                    if (uicomponent instanceof UIPortlet)
                        uiPortlets.add((UIPortlet) uicomponent);
                    else
                        uiDataComponents.add(uicomponent);
                }
            }
            w.write("<div class=\"PortalResponse\">");
            w.write("<div class=\"PortalResponseData\">");
            for (UIComponent uicomponent : uiDataComponents) {
                if (log.isDebugEnabled())
                    log.debug("AJAX call: Need to refresh the UI component " + uicomponent.getName());
                renderBlockToUpdate(uicomponent, context, w);
            }
            w.write("</div>");

            if (!context.getFullRender()) {
                for (UIPortlet uiPortlet : uiPortlets) {
                    if (log.isDebugEnabled())
                        log.debug("AJAX call: Need to refresh the Portlet " + uiPortlet.getId());

                    w.write("<div class=\"PortletResponse\" style=\"display: none\">");
                    w.append("<div class=\"PortletResponsePortletId\">" + uiPortlet.getId() + "</div>");
                    w.append("<div class=\"PortletResponseData\">");

                    /*
                     * If the portlet is using our UI framework or supports it then it will return a set of block to updates. If
                     * there is not block to update the javascript client will see that as a full refresh of the content part
                     */
                    uiPortlet.processRender(context);

                    w.append("</div>");
                    w.append("<div class=\"PortletResponseScript\"></div>");
                    w.write("</div>");
                }
            }
            w.write("<div class=\"MarkupHeadElements\">");
            List<String> headElems = ((PortalRequestContext) context).getExtraMarkupHeadersAsStrings();
            for (String elem : headElems) {
                w.write(elem);
            }
            w.write("</div>");
            w.write("<div class=\"LoadingScripts\">");
            writeLoadingScripts(pcontext);
            w.write("</div>");
            w.write("<div class=\"PortalResponseScript\">");
            JavascriptManager jsManager = pcontext.getJavascriptManager();
            String skin = getAddSkinScript(pcontext.getControllerContext(), list);
            if (skin != null) {
                jsManager.require("SHARED/skin", "skin").addScripts(skin);
            }
            w.write(jsManager.getJavaScripts());
            w.write("</div>");
View Full Code Here

     * anonymous user or no skin setting in user profile, use the skin setting in portal config
     *
     * @throws Exception
     */
    public void reloadPortalProperties() throws Exception {
        PortalRequestContext context = Util.getPortalRequestContext();
        String user = context.getRemoteUser();
        String portalSkin = null;
        OrganizationService orgService = getApplicationComponent(OrganizationService.class);

        if (user != null) {
            UserProfile userProfile = orgService.getUserProfileHandler().findUserProfileByName(user);
            if (userProfile != null) {
                portalSkin = userProfile.getUserInfoMap().get(Constants.USER_SKIN);
            } else {
                if (log.isWarnEnabled())
                    log.warn("Could not load user profile for " + user + ". Using default portal locale.");
            }
        }

        // use the skin from the user profile if available, otherwise use from the portal config
        if (portalSkin != null && portalSkin.trim().length() > 0) {
            skin_ = portalSkin;
        } else {
            String userPortalConfigSkin = context.getUserPortalConfig().getPortalConfig().getSkin();
            if (userPortalConfigSkin != null && userPortalConfigSkin.trim().length() > 0)
                skin_ = userPortalConfigSkin;
        }
    }
View Full Code Here

    public UIPopupWindow getHelpWindow() {
        return uiHelpWindow;
    }

    protected void updateUIPortal(Event<? extends UIPageWizard> event) {
        PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();

        UIPortal uiPortal = Util.getUIPortal();
        uiPortal.setRenderSibling(UIPortal.class);
        pcontext.ignoreAJAXUpdateOnPortlets(true);
    }
View Full Code Here

        pcontext.ignoreAJAXUpdateOnPortlets(true);
    }

    void updateWizardComponent() {
        UIPortalApplication uiPortalApp = getAncestorOfType(UIPortalApplication.class);
        PortalRequestContext pcontext = Util.getPortalRequestContext();

        UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
        pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);

        pcontext.ignoreAJAXUpdateOnPortlets(true);
    }
View Full Code Here

     *
     * @return return portal url template
     * @throws UnsupportedEncodingException
     */
    public String getPortalURLTemplate() throws UnsupportedEncodingException {
        PortalRequestContext pcontext = Util.getPortalRequestContext();
        ComponentURL urlTemplate = pcontext.createURL(ComponentURL.TYPE);
        urlTemplate.setMimeType(MimeType.PLAIN);
        urlTemplate.setPath(pcontext.getNodePath());
        urlTemplate.setResource(EMPTY_COMPONENT);
        urlTemplate.setAction("_portal:action_");

        return urlTemplate.toString();
    }
View Full Code Here

        return urlTemplate.toString();
    }

    public String getBaseURL() throws UnsupportedEncodingException  {
        PortalRequestContext pcontext = Util.getPortalRequestContext();
        NodeURL nodeURL = pcontext.createURL(NodeURL.TYPE, new NavigationResource(pcontext.getSiteKey(), pcontext.getNodePath()));
        return nodeURL.toString();
    }
View Full Code Here

    public static class AbortActionListener extends EventListener<UIPageWizard> {
        public void execute(Event<UIPageWizard> event) throws Exception {
            UIPortalApplication uiPortalApp = event.getSource().getAncestorOfType(UIPortalApplication.class);
            uiPortalApp.setModeState(UIPortalApplication.NORMAL_MODE);
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();

            UIPortal uiPortal = Util.getUIPortal();
            uiPortal.setRenderSibling(UIPortal.class);
            pcontext.ignoreAJAXUpdateOnPortlets(true);

            UIWorkingWorkspace uiWorkingWS = uiPortalApp.getChildById(UIPortalApplication.UI_WORKING_WS_ID);
            uiWorkingWS.findFirstComponentOfType(UIPortalComposer.class).setRendered(false);
            uiWorkingWS.setRenderedChild(UIPortalApplication.UI_VIEWING_WS_ID);
            UIPortalToolPanel toolPanel = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
            toolPanel.setUIComponent(null);
            pcontext.addUIComponentToUpdateByAjax(uiWorkingWS);
            JavascriptManager jsManager = event.getRequestContext().getJavascriptManager();
            jsManager.require("SHARED/portal", "portal").addScripts(
                    "eXo.portal.portalMode=" + UIPortalApplication.NORMAL_MODE + ";");
        }
View Full Code Here

TOP

Related Classes of org.exoplatform.portal.application.PortalRequestContext

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.