Package org.exoplatform.portal.application

Examples of org.exoplatform.portal.application.PortalRequestContext


     * @param context - request context
     * @return markup to render on browser
     * @see PortletExceptionHandleService
     */
    public Text generateRenderMarkup(PortletInvocationResponse pir, WebuiRequestContext context) {
        PortalRequestContext prcontext = (PortalRequestContext) context;

        Text markup = null;
        if (pir instanceof FragmentResponse) {
            JavascriptManager jsMan = context.getJavascriptManager();
            jsMan.loadScriptResource(ResourceScope.PORTLET, getApplicationId());

            FragmentResponse fragmentResponse = (FragmentResponse) pir;
            switch (fragmentResponse.getType()) {
                case FragmentResponse.TYPE_CHARS:
                    markup = Text.create(fragmentResponse.getContent());
                    break;
                case FragmentResponse.TYPE_BYTES:
                    markup = Text.create(fragmentResponse.getBytes(), Charset.forName("UTF-8"));
                    break;
                case FragmentResponse.TYPE_EMPTY:
                    markup = Text.create("");
                    break;
            }
            setConfiguredTitle(fragmentResponse.getTitle());

            // setup portlet properties
            if (fragmentResponse.getProperties() != null) {
                // setup transport headers
                if (fragmentResponse.getProperties().getTransportHeaders() != null) {
                    MultiValuedPropertyMap<String> transportHeaders = fragmentResponse.getProperties().getTransportHeaders();
                    for (String key : transportHeaders.keySet()) {
                        if (JAVASCRIPT_DEPENDENCY.equals(key)) {
                            for (String value : transportHeaders.getValues(key)) {
                                jsMan.require(value);
                            }
                        } else {
                            for (String value : transportHeaders.getValues(key)) {
                                prcontext.getResponse().setHeader(key, value);
                            }
                        }
                    }
                }

                // setup up portlet cookies
                if (fragmentResponse.getProperties().getCookies() != null) {
                    List<Cookie> cookies = fragmentResponse.getProperties().getCookies();
                    for (Cookie cookie : cookies) {
                        prcontext.getResponse().addCookie(cookie);
                    }
                }

                // setup markup headers
                if (fragmentResponse.getProperties().getMarkupHeaders() != null) {
                    MultiValuedPropertyMap<Element> markupHeaders = fragmentResponse.getProperties().getMarkupHeaders();

                    List<Element> markupElements = markupHeaders.getValues(MimeResponse.MARKUP_HEAD_ELEMENT);
                    if (markupElements != null) {
                        for (Element element : markupElements) {
                            if (!context.useAjax() && "title".equals(element.getNodeName().toLowerCase())
                                    && element.getFirstChild() != null) {
                                String title = element.getFirstChild().getNodeValue();
                                prcontext.getRequest().setAttribute(PortalRequestContext.REQUEST_TITLE, title);
                            } else {
                                prcontext.addExtraMarkupHeader(element, getId());
                            }
                        }
                    }
                }
            }
View Full Code Here


    }

    public static class CreateActionListener extends EventListener<UIPortalForm> {
        public synchronized void execute(Event<UIPortalForm> event) throws Exception {
            UIPortalForm uiForm = event.getSource();
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
            String template = uiForm.getChild(UIFormInputItemSelector.class).getSelectedItemOption().getValue().toString();
            String portalName = uiForm.getUIStringInput(FIELD_NAME).getValue();
            DataStorage dataService = uiForm.getApplicationComponent(DataStorage.class);
            PortalConfig config = dataService.getPortalConfig(portalName);
            if (config != null) {
View Full Code Here

    public static class EditInfoActionListener extends EventListener<UIPageBrowser> {
        public void execute(Event<UIPageBrowser> event) throws Exception {
            UIPageBrowser uiPageBrowser = event.getSource();
            WebuiRequestContext context = event.getRequestContext();
            PortalRequestContext pcontext = (PortalRequestContext) context.getParentAppRequestContext();
            UIPortalApplication uiPortalApp = (UIPortalApplication) pcontext.getUIApplication();
            String id = context.getRequestParameter(OBJECTID);
            UserPortalConfigService service = uiPageBrowser.getApplicationComponent(UserPortalConfigService.class);

            // Check existence of the page
            PageContext pageContext = (id != null) ? service.getPage(PageKey.parse(id)) : null;
View Full Code Here

        }
    }

    public static class AddNewActionListener extends EventListener<UIPageBrowser> {
        public void execute(Event<UIPageBrowser> event) throws Exception {
            PortalRequestContext prContext = Util.getPortalRequestContext();
            UIPortalApplication uiApp = (UIPortalApplication) prContext.getUIApplication();
            UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
            UIPageForm uiPageForm = uiMaskWS.createUIComponent(UIPageForm.class, "UIBrowserPageForm", "UIPageForm");
            uiPageForm.buildForm(null);
            uiMaskWS.setUIComponent(uiPageForm);
            uiMaskWS.setShow(true);

            UIFormSelectBox slcOwnerType = uiPageForm.getUIFormSelectBox(UIPageForm.OWNER_TYPE);
            List<SelectItemOption<String>> types = slcOwnerType.getOptions();
            for (int i = 0; i < types.size(); i++) {
                if (PortalConfig.USER_TYPE.equals(types.get(i).getValue())) {
                    types.remove(types.get(i));
                    break;
                }
            }
            slcOwnerType.setOptions(types);
            Event<UIComponent> slcEvent = uiPageForm.createEvent("ChangeOwnerType", Phase.DECODE, event.getRequestContext());
            slcEvent.broadcast();

            prContext.addUIComponentToUpdateByAjax(uiMaskWS);
        }
View Full Code Here

    public static class SavePageActionListener extends UIPageForm.SaveActionListener {
        public void execute(Event<UIPageForm> event) throws Exception {
            UIPageForm uiPageForm = event.getSource();
            UIPortalApplication uiPortalApp = uiPageForm.getAncestorOfType(UIPortalApplication.class);
            PortalRequestContext pcontext = Util.getPortalRequestContext();
            UIPage uiPage = uiPageForm.getUIPage();
            Page page = new Page();
            uiPageForm.invokeSetBindingBean(page);
            DataStorage dataService = uiPageForm.getApplicationComponent(DataStorage.class);
            // create new page
View Full Code Here

                        uiPortal.setMaximizedUIComponent(null);
                    }
                }
            }

            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();

            org.exoplatform.portal.webui.container.UIContainer uiParent = uiComponentTobeRemoved.getParent();
            if (UITabContainer.TAB_CONTAINER.equals(uiParent.getFactoryId())) {
                /*
                 * Check if it is removing the last tab then we will remove the TabContainer as well
View Full Code Here

        module.require("SHARED/portalComposer", "portalComposer").addScripts("portalComposer.toggleSaveButton();");
    }

    public static class MoveChildActionListener extends EventListener<UIContainer> {
        public void execute(Event<UIContainer> event) throws Exception {
            PortalRequestContext pcontext = (PortalRequestContext) event.getRequestContext();
            String insertPosition = pcontext.getRequestParameter("insertPosition");
            int position = -1;
            try {
                position = Integer.parseInt(insertPosition);
            } catch (Exception exp) {
                position = -1;
            }

            boolean newComponent = false;
            String paramNewComponent = pcontext.getRequestParameter("isAddingNewly");

            if (paramNewComponent != null)
                newComponent = Boolean.valueOf(paramNewComponent).booleanValue();

            UIPortalApplication uiApp = event.getSource().getAncestorOfType(UIPortalApplication.class);
            UIPortalComposer portalComposer = uiApp.findFirstComponentOfType(UIPortalComposer.class);

            if (newComponent) {
                portalComposer.updateWorkspaceComponent();
                pcontext.ignoreAJAXUpdateOnPortlets(true);
            }

            UIWorkingWorkspace uiWorkingWS = uiApp.getChild(UIWorkingWorkspace.class);
            UIComponent uiWorking = uiWorkingWS.findFirstComponentOfType(UIPortalToolPanel.class);
            if (!uiWorking.isRendered()) {
                UIEditInlineWorkspace uiEditWS = uiWorkingWS.getChild(UIEditInlineWorkspace.class);
                uiWorking = uiEditWS.getUIComponent();
            }

            String sourceId = pcontext.getRequestParameter("srcID");
            UIComponent uiSource = uiWorking.findComponentById(sourceId);

            UIContainer uiTarget = uiWorking.findComponentById(pcontext.getRequestParameter("targetID"));
            if (position < 0 && uiTarget.getChildren().size() > 0) {
                position = uiTarget.getChildren().size();
            } else if (position < 0) {
                position = 0;
            }

            if (uiSource == null) {
                UITabPane subTabPane = portalComposer.getChild(UITabPane.class);
                UIContainerList uiContainerConfig = subTabPane.getChild(UIContainerList.class);
                if (uiContainerConfig != null && subTabPane.getSelectedTabId().equals(uiContainerConfig.getId())) {
                    org.exoplatform.portal.webui.container.UIContainer uiContainer = uiTarget.createUIComponent(
                            org.exoplatform.portal.webui.container.UIContainer.class, null, null);
                    Container container = uiContainerConfig.getContainer(sourceId);
                    // GTNPORTAL-3118: IBM JDK creates negative hashCodes and drag and drop webui logic expects abs values.
                    container.setId(String.valueOf(Math.abs(container.hashCode())));
                    uiContainer.setStorageId(container.getStorageId());
                    PortalDataMapper.toUIContainer(uiContainer, container);
                    String[] accessPers = uiContainer.getAccessPermissions();
                    for (String accessPer : accessPers) {
                        if (accessPer.equals(""))
                            accessPer = null;
                    }
                    if (accessPers == null || accessPers.length == 0)
                        accessPers = new String[] { UserACL.EVERYONE };
                    uiContainer.setAccessPermissions(accessPers);
                    uiSource = uiContainer;
                } else {
                    Application app = null;
                    UIApplicationList appList = uiApp.findFirstComponentOfType(UIApplicationList.class);
                    app = appList.getApplication(sourceId);
                    ApplicationType applicationType = app.getType();

                    //
                    UIPortlet uiPortlet = uiTarget.createUIComponent(UIPortlet.class, null, null);
                    // Only setting title for Gadgets as it's using Portlet wrapper for displaying
                    if (app.getType().equals(ApplicationType.GADGET)) {
                        uiPortlet.setTitle(app.getDisplayName());
                    }
                    uiPortlet.setDescription(app.getDescription());
                    List<String> accessPersList = app.getAccessPermissions();
                    String[] accessPers = accessPersList.toArray(new String[accessPersList.size()]);
                    for (String accessPer : accessPers) {
                        if (accessPer.equals(""))
                            accessPers = null;
                    }
                    if (accessPers == null || accessPers.length == 0)
                        accessPers = new String[] { UserACL.EVERYONE };
                    uiPortlet.setAccessPermissions(accessPers);
                    UIPage uiPage = uiTarget.getAncestorOfType(UIPage.class);

                    // Hardcode on state to fix error while drag/drop Dashboard
                    if ("dashboard/DashboardPortlet".equals(app.getContentId())) {
                        TransientApplicationState state = new TransientApplicationState<Object>(app.getContentId());
                        uiPortlet.setState(new PortletState(state, applicationType));
                    } else {
                        ApplicationState state;
                        // if we have a new portlet added to the page we need for it to have its own state.
                        // otherwise all new portlets added to a page will have the same state.
                        if (newComponent) {
                            state = new TransientApplicationState<Object>(app.getContentId());

                            // if the portlet is not new, then we should clone it from the original portlet
                        } else {
                            state = new CloneApplicationState<Object>(app.getStorageId());
                        }
                        uiPortlet.setState(new PortletState(state, applicationType));
                    }
                    uiPortlet.setPortletInPortal(uiTarget instanceof UIPortal);

                    // TODO Wait to fix issue EXOGTN-213 and then
                    // we should get "showInfobar" from current UI portal instead of Storage service
                    UIPortal currentPortal = Util.getUIPortal();
                    DataStorage storage = uiApp.getApplicationComponent(DataStorage.class);
                    uiPortlet.setShowInfoBar(storage.getPortalConfig(currentPortal.getSiteKey().getTypeName(),
                            currentPortal.getSiteKey().getName()).isShowInfobar());
                    uiSource = uiPortlet;
                }
                List<UIComponent> children = uiTarget.getChildren();
                uiSource.setParent(uiTarget);
                children.add(position, uiSource);
                return;
            }

            org.exoplatform.portal.webui.container.UIContainer uiParent = uiSource.getParent();
            if (uiParent == uiTarget) {
                int currentIdx = uiTarget.getChildren().indexOf(uiSource);
                if (position <= currentIdx) {
                    uiTarget.getChildren().add(position, uiSource);
                    currentIdx++;
                    uiTarget.getChildren().remove(currentIdx);
                    return;
                }
                uiTarget.getChildren().remove(currentIdx);
                if (position >= uiTarget.getChildren().size()) {
                    position = uiTarget.getChildren().size();
                }
                uiTarget.getChildren().add(position, uiSource);
                return;
            }

            uiTarget.getChildren().add(position, uiSource);
            uiSource.setParent(uiTarget);

            if (UITabContainer.TAB_CONTAINER.equals(uiParent.getFactoryId())) {
                if (uiParent.getChildren().size() == 1) {
                    UIContainer uiTabParent = uiParent.getParent();
                    if (uiTabParent.getChildren().size() > 1) {
                        removeUIComponent(uiParent, pcontext, false);
                    } else {
                        removeUIComponent(uiTabParent, pcontext, false);
                    }
                } else {
                    uiParent.getChildren().remove(uiSource);
                    pcontext.addUIComponentToUpdateByAjax(uiParent);
                    pcontext.ignoreAJAXUpdateOnPortlets(true);
                }
            } else if (org.exoplatform.portal.webui.container.UIContainer.TABLE_COLUMN_CONTAINER
                    .equals(uiParent.getFactoryId()) && uiParent.getChildren().size() == 1) {
                removeUIComponent(uiParent, pcontext, false);
            } else {
View Full Code Here

     * through JavascriptManager
     *
     * @return
     */
    public Map<String, Boolean> getScripts() {
        PortalRequestContext prc = PortalRequestContext.getCurrentInstance();
        JavascriptManager jsMan = prc.getJavascriptManager();

        //
        FetchMap<ResourceId> requiredResources = jsMan.getScriptResources();
        log.debug("Resource ids to resolve: {}", requiredResources);

View Full Code Here

     * this map will be used by GateIn JS module loader (currently, it is requirejs)
     * @throws Exception
     */
    public JSONObject getJSConfig() throws Exception {
        JavascriptConfigService service = getApplicationComponent(JavascriptConfigService.class);
        PortalRequestContext prc = PortalRequestContext.getCurrentInstance();
        return service.getJSConfig(prc.getControllerContext(), prc.getLocale());
    }
View Full Code Here

    /**
     * Check current portal name, if it's changing, reload portal properties (for now, skin setting)
     */
    @Override
    public void processDecode(WebuiRequestContext context) throws Exception {
        PortalRequestContext prc = (PortalRequestContext) context;
        String portalName = prc.getUserPortalConfig().getPortalName();
        if (!Safe.equals(portalName, lastPortal)) {
            reloadPortalProperties();
            lastPortal = portalName;
        }
        super.processDecode(context);
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.