Example usage for com.liferay.portal.kernel.servlet SessionMessages KEY_SUFFIX_CLOSE_REDIRECT

List of usage examples for com.liferay.portal.kernel.servlet SessionMessages KEY_SUFFIX_CLOSE_REDIRECT

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.servlet SessionMessages KEY_SUFFIX_CLOSE_REDIRECT.

Prototype

String KEY_SUFFIX_CLOSE_REDIRECT

To view the source code for com.liferay.portal.kernel.servlet SessionMessages KEY_SUFFIX_CLOSE_REDIRECT.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.lists.web.internal.portlet.DDLPortlet.java

License:Open Source License

protected void setCloseRedirect(ActionRequest actionRequest) {
    String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

    if (Validator.isNull(closeRedirect)) {
        return;/*from w ww.  j a va 2 s. c om*/
    }

    SessionMessages.add(actionRequest,
            _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
}

From source file:com.liferay.dynamic.data.mapping.web.internal.portlet.action.DDMBaseMVCActionCommand.java

License:Open Source License

protected String getRedirect(ActionRequest actionRequest) {
    String redirect = ParamUtil.getString(actionRequest, "redirect");

    String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

    if (Validator.isNull(closeRedirect)) {
        return redirect;
    }//from  w  w  w .  j  a  v a2 s .  c o m

    redirect = HttpUtil.setParameter(redirect, "closeRedirect", closeRedirect);

    SessionMessages.add(actionRequest,
            PortalUtil.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);

    return redirect;
}

From source file:com.liferay.portlet.dynamicdatamapping.action.CopyStructureAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {/*from   w  w  w .  j a  va  2 s .c  o m*/
        DDMStructure structure = copyStructure(actionRequest);

        String redirect = getSaveAndContinueRedirect(portletConfig, actionRequest, structure);

        String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

        if (Validator.isNotNull(closeRedirect)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchStructureException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.dynamic_data_mapping.error");
        } else if (e instanceof StructureNameException) {
            SessionErrors.add(actionRequest, e.getClass().getName(), e);
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutsAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {//ww  w . j  a v a2s. c  o  m
        checkPermissions(actionRequest);
    } catch (PrincipalException pe) {
        return;
    }

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    //Modification start
    SessionErrorsUtil.clear(actionRequest);
    SessionErrors.clear(actionRequest);
    //Modification end

    try {
        String redirect = ParamUtil.getString(actionRequest, "redirect");
        String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

        Layout layout = null;
        String oldFriendlyURL = StringPool.BLANK;

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateLayout(actionRequest, actionResponse);

            layout = (Layout) returnValue[0];
            oldFriendlyURL = (String) returnValue[1];

            redirect = updateCloseRedirect(redirect, null, layout, oldFriendlyURL);
            closeRedirect = updateCloseRedirect(closeRedirect, null, layout, oldFriendlyURL);
        } else if (cmd.equals(Constants.DELETE)) {
            Object[] returnValue = SitesUtil.deleteLayout(actionRequest, actionResponse);

            Group group = (Group) returnValue[0];
            oldFriendlyURL = (String) returnValue[1];
            long newRefererPlid = (Long) returnValue[2];

            redirect = updateCloseRedirect(redirect, group, null, oldFriendlyURL);
            redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);
            // ===================== start of change https://jira.playtech.corp/browse/WPL-2040
            redirect = HttpUtil.setParameter(redirect, actionResponse.getNamespace() + "selPlid",
                    newRefererPlid);
            // ===================== end of change
            closeRedirect = updateCloseRedirect(closeRedirect, group, null, oldFriendlyURL);
        } else if (cmd.equals("copy_from_live")) {
            StagingUtil.copyFromLive(actionRequest);
        } else if (cmd.equals("display_order")) {
            updateDisplayOrder(actionRequest);
        } else if (cmd.equals("delete_layout_revision")) {
            deleteLayoutRevision(actionRequest);
        } else if (cmd.equals("enable")) {
            enableLayout(actionRequest);
        } else if (cmd.equals("publish_to_live")) {
            StagingUtil.publishToLive(actionRequest);
        } else if (cmd.equals("publish_to_remote")) {
            StagingUtil.publishToRemote(actionRequest);
        } else if (cmd.equals("reset_customized_view")) {
            LayoutTypePortlet layoutTypePortlet = themeDisplay.getLayoutTypePortlet();

            if ((layoutTypePortlet != null) && layoutTypePortlet.isCustomizable()
                    && layoutTypePortlet.isCustomizedView()) {

                layoutTypePortlet.resetUserPreferences();
            }
        } else if (cmd.equals("reset_prototype")) {
            SitesUtil.resetPrototype(themeDisplay.getLayout());
        } else if (cmd.equals("schedule_copy_from_live")) {
            StagingUtil.scheduleCopyFromLive(actionRequest);
        } else if (cmd.equals("schedule_publish_to_live")) {
            StagingUtil.schedulePublishToLive(actionRequest);
        } else if (cmd.equals("schedule_publish_to_remote")) {
            StagingUtil.schedulePublishToRemote(actionRequest);
        } else if (cmd.equals("select_layout_set_branch")) {
            selectLayoutSetBranch(actionRequest);
        } else if (cmd.equals("select_layout_branch")) {
            selectLayoutBranch(actionRequest);
        } else if (cmd.equals("unschedule_copy_from_live")) {
            StagingUtil.unscheduleCopyFromLive(actionRequest);
        } else if (cmd.equals("unschedule_publish_to_live")) {
            StagingUtil.unschedulePublishToLive(actionRequest);
        } else if (cmd.equals("unschedule_publish_to_remote")) {
            StagingUtil.unschedulePublishToRemote(actionRequest);
        } else if (cmd.equals("update_layout_revision")) {
            updateLayoutRevision(actionRequest, themeDisplay);
        }

        if (Validator.isNotNull(closeRedirect)) {
            LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletConfig;

            SessionMessages.add(actionRequest,
                    liferayPortletConfig.getPortletId() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT,
                    closeRedirect);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchLayoutException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass());

            setForward(actionRequest, "portlet.layouts_admin.error");
        } else if (e instanceof ImageTypeException || e instanceof LayoutFriendlyURLException
                || e instanceof LayoutHiddenException || e instanceof LayoutNameException
                || e instanceof LayoutParentLayoutIdException || e instanceof LayoutSetVirtualHostException
                || e instanceof LayoutTypeException || e instanceof RequiredLayoutException
                || e instanceof UploadException) {

            if (e instanceof LayoutFriendlyURLException) {
                SessionErrors.add(actionRequest, LayoutFriendlyURLException.class.getName(), e);
            } else {
                SessionErrors.add(actionRequest, e.getClass(), e);
            }
        } else if (e instanceof DuplicateLockException || e instanceof LayoutPrototypeException
                || e instanceof RemoteExportException || e instanceof RemoteOptionsException
                || e instanceof SystemException) {

            SessionErrors.add(actionRequest, e.getClass(), e);

            String redirect = ParamUtil.getString(actionRequest, "pagesRedirect");

            sendRedirect(actionRequest, actionResponse, redirect);
        } else {
            throw e;
        }
    } finally {
        SessionErrorsUtil.copyFromSessionErrors(actionRequest);
    }
}

From source file:com.liferay.portlet.layoutsadmin.action.EditLayoutSetAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    try {//from  ww w.ja  v a2  s. c o  m
        checkPermissions(actionRequest);
    } catch (PrincipalException pe) {
        return;
    }

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {
        if (cmd.equals(Constants.UPDATE)) {
            updateLayoutSet(actionRequest, actionResponse);
        }

        String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

        if (Validator.isNotNull(closeRedirect)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
        }

        sendRedirect(actionRequest, actionResponse);
    } catch (Exception e) {
        if (e instanceof PrincipalException || e instanceof SystemException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.layouts_admin.error");
        } else if (e instanceof FileSizeException || e instanceof ImageTypeException
                || e instanceof UploadException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.sites.action.EditGroupAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    try {/*w w  w.j  a v  a2 s . c o  m*/
        String closeRedirect = ParamUtil.getString(actionRequest, "closeRedirect");

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            Object[] returnValue = updateGroup(actionRequest);

            Group group = (Group) returnValue[0];
            String oldFriendlyURL = (String) returnValue[1];
            String oldStagingFriendlyURL = (String) returnValue[2];
            long newRefererPlid = (Long) returnValue[3];

            redirect = HttpUtil.setParameter(redirect, "doAsGroupId", group.getGroupId());
            redirect = HttpUtil.setParameter(redirect, "refererPlid", newRefererPlid);

            closeRedirect = updateCloseRedirect(closeRedirect, group, themeDisplay, oldFriendlyURL,
                    oldStagingFriendlyURL);
        } else if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.RESTORE)) {

            updateActive(actionRequest, cmd);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteGroup(actionRequest);
        }

        if (Validator.isNotNull(closeRedirect)) {
            SessionMessages.add(actionRequest,
                    portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_CLOSE_REDIRECT, closeRedirect);
        }

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.sites_admin.error");
        } else if (e instanceof AssetCategoryException || e instanceof AssetTagException
                || e instanceof DuplicateGroupException || e instanceof GroupFriendlyURLException
                || e instanceof GroupNameException || e instanceof LayoutSetVirtualHostException
                || e instanceof RemoteExportException || e instanceof RemoteOptionsException
                || e instanceof RequiredGroupException || e instanceof SystemException) {

            SessionErrors.add(actionRequest, e.getClass().getName(), e);

            if (cmd.equals(Constants.DEACTIVATE) || cmd.equals(Constants.DELETE)
                    || cmd.equals(Constants.RESTORE)) {

                if (Validator.isNotNull(redirect)) {
                    actionResponse.sendRedirect(redirect);
                }
            }
        } else {
            throw e;
        }
    }
}