Example usage for com.liferay.portal.kernel.servlet SessionErrors add

List of usage examples for com.liferay.portal.kernel.servlet SessionErrors add

Introduction

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

Prototype

public static void add(PortletRequest portletRequest, String key, Object value) 

Source Link

Usage

From source file:com.liferay.so.configurations.portlet.ConfigurationsPortlet.java

License:Open Source License

public void updateGeneralConfigurations(ActionRequest actionRequest, ActionResponse actionResponse)
        throws Exception {

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

    boolean addSitePermission = ParamUtil.get(actionRequest, "addSitePermission", true);

    updateRolePermissions(themeDisplay.getCompanyId(), addSitePermission);

    UnicodeProperties properties = PropertiesParamUtil.getProperties(actionRequest, "preferences--");

    PortletPreferences portletPreferences = PortletPreferencesLocalServiceUtil.getPreferences(
            themeDisplay.getCompanyId(), themeDisplay.getCompanyId(), PortletKeys.PREFS_OWNER_TYPE_COMPANY,
            LayoutConstants.DEFAULT_PLID, PortletKeys.SO_CONFIGURATIONS);

    for (Map.Entry<String, String> entry : properties.entrySet()) {
        portletPreferences.setValue(entry.getKey(), entry.getValue());
    }/*from w  ww .  ja v a 2s  .co m*/

    try {
        portletPreferences.store();
    } catch (ValidatorException ve) {
        SessionErrors.add(actionRequest, ValidatorException.class.getName(), ve);
    }
}

From source file:com.liferay.so.notifications.portlet.NotificationsPortlet.java

License:Open Source License

public void updateMemberRequest(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    long memberRequestId = ParamUtil.getLong(actionRequest, "memberRequestId");
    int status = ParamUtil.getInteger(actionRequest, "status");

    try {/*from www.  jav  a 2s  .c o  m*/
        MemberRequestLocalServiceUtil.updateMemberRequest(themeDisplay.getUserId(), memberRequestId, status);
    } catch (Exception e) {
        if ((e instanceof MemberRequestAlreadyUsedException)
                || (e instanceof MemberRequestInvalidUserException)) {

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

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

    ChannelHubManagerUtil.confirmDelivery(themeDisplay.getCompanyId(), themeDisplay.getUserId(),
            notificationEventUuid, false);
}

From source file:com.liferay.staging.bar.web.internal.portlet.action.DeleteLayoutBranchMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId");

    long currentLayoutBranchId = ParamUtil.getLong(actionRequest, "currentLayoutBranchId");

    try {/*from  w  w w  .jav  a2 s. c o  m*/
        _layoutBranchService.deleteLayoutBranch(layoutBranchId);

        SessionMessages.add(actionRequest, "pageVariationDeleted");

        if (layoutBranchId == currentLayoutBranchId) {
            SessionMessages.add(actionRequest,
                    _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_PORTLET_NOT_AJAXABLE);
        }

        ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
    } catch (Exception e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        actionResponse.setRenderParameter("mvcPath", "/error.jsp");
    }
}

From source file:com.liferay.staging.bar.web.internal.portlet.action.DeleteLayoutSetBranchMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId");

    long currentLayoutBranchId = ParamUtil.getLong(actionRequest, "currentLayoutBranchId");

    if (layoutSetBranchId == currentLayoutBranchId) {
        SessionMessages.add(actionRequest,
                _portal.getPortletId(actionRequest) + SessionMessages.KEY_SUFFIX_PORTLET_NOT_AJAXABLE);
    }//w  w w  . ja  v a2  s .  c o  m

    try {
        _layoutSetBranchService.deleteLayoutSetBranch(layoutSetBranchId);

        SessionMessages.add(actionRequest, "sitePageVariationDeleted");

        ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
    } catch (Exception e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        actionResponse.setRenderParameter("mvcPath", "/error.jsp");
    }
}

From source file:com.liferay.staging.bar.web.internal.portlet.action.EditLayoutBranchMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long layoutBranchId = ParamUtil.getLong(actionRequest, "layoutBranchId");

    long layoutRevisionId = ParamUtil.getLong(actionRequest, "copyLayoutRevisionId");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    try {/*from ww w . j  a  v  a2s  .c  o m*/
        if (layoutBranchId <= 0) {
            _layoutBranchService.addLayoutBranch(layoutRevisionId, name, description, false, serviceContext);

            SessionMessages.add(actionRequest, "pageVariationAdded");
        } else {
            _layoutBranchService.updateLayoutBranch(layoutBranchId, name, description, serviceContext);

            SessionMessages.add(actionRequest, "pageVariationUpdated");
        }

        ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
    } catch (Exception e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        if (e instanceof LayoutBranchNameException) {
            actionResponse.setRenderParameter("mvcPath", "/edit_layout_branch.jsp");
        } else {
            actionResponse.setRenderParameter("mvcPath", "/error.jsp");
        }
    }
}

From source file:com.liferay.staging.bar.web.internal.portlet.action.EditLayoutSetBranchMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    long layoutSetBranchId = ParamUtil.getLong(actionRequest, "layoutSetBranchId");

    long groupId = ParamUtil.getLong(actionRequest, "groupId");
    boolean privateLayout = ParamUtil.getBoolean(actionRequest, "privateLayout");
    String name = ParamUtil.getString(actionRequest, "name");
    String description = ParamUtil.getString(actionRequest, "description");
    long copyLayoutSetBranchId = ParamUtil.getLong(actionRequest, "copyLayoutSetBranchId",
            LayoutSetBranchConstants.ALL_BRANCHES);

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    try {/*from ww  w .  ja v  a2  s.com*/
        if (layoutSetBranchId <= 0) {
            _layoutSetBranchService.addLayoutSetBranch(groupId, privateLayout, name, description, false,
                    copyLayoutSetBranchId, serviceContext);

            SessionMessages.add(actionRequest, "sitePageVariationAdded");
        } else {
            _layoutSetBranchLocalService.updateLayoutSetBranch(layoutSetBranchId, name, description,
                    serviceContext);

            SessionMessages.add(actionRequest, "sitePageVariationUpdated");
        }

        ActionUtil.addLayoutBranchSessionMessages(actionRequest, actionResponse);
    } catch (Exception e) {
        SessionErrors.add(actionRequest, e.getClass(), e);

        if (e instanceof LayoutSetBranchNameException) {
            actionResponse.setRenderParameter("mvcPath", "/edit_layout_set_branch.jsp");
        } else {
            actionResponse.setRenderParameter("mvcPath", "/error.jsp");
        }
    }
}