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) 

Source Link

Usage

From source file:com.liferay.portlet.portletconfiguration.action.EditPermissionsAction.java

License:Open Source License

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

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

    try {//  w  w w  .jav a  2 s .  c om
        if (cmd.equals("group_permissions")) {
            updateGroupPermissions(actionRequest);
        } else if (cmd.equals("guest_permissions")) {
            updateGuestPermissions(actionRequest);
        } else if (cmd.equals("organization_permissions")) {
            updateOrganizationPermissions(actionRequest);
        } else if (cmd.equals("role_permissions")) {
            updateRolePermissions(actionRequest);
        } else if (cmd.equals("user_group_permissions")) {
            updateUserGroupPermissions(actionRequest);
        } else if (cmd.equals("user_permissions")) {
            updateUserPermissions(actionRequest);
        }

        if (PropsValues.PERMISSIONS_USER_CHECK_ALGORITHM < 5) {
            String redirect = ParamUtil.getString(actionRequest, "permissionsRedirect");

            sendRedirect(actionRequest, actionResponse, redirect);
        } else {
            addSuccessMessage(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof PrincipalException) {
            SessionErrors.add(actionRequest, e.getClass().getName());

            setForward(actionRequest, "portlet.portlet_configuration.error");
        } else {
            throw e;
        }
    }
}

From source file:com.liferay.portlet.portletconfiguration.action.EditPermissionsAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

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

    long groupId = themeDisplay.getScopeGroupId();

    String portletResource = ParamUtil.getString(renderRequest, "portletResource");
    String modelResource = ParamUtil.getString(renderRequest, "modelResource");
    String resourcePrimKey = ParamUtil.getString(renderRequest, "resourcePrimKey");

    String selResource = portletResource;

    if (Validator.isNotNull(modelResource)) {
        selResource = modelResource;//from   ww  w.  ja  va  2 s .  c  om
    }

    try {
        PermissionServiceUtil.checkPermission(groupId, selResource, resourcePrimKey);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());

        setForward(renderRequest, "portlet.portlet_configuration.error");
    }

    Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletResource);

    if (portlet != null) {
        renderResponse.setTitle(getTitle(portlet, renderRequest));
    }

    return mapping.findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_permissions"));
}

From source file:com.liferay.portlet.portletconfiguration.action.EditPublicRenderParametersAction.java

License:Open Source License

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

    Portlet portlet = null;/*w w  w . j a  v  a 2s  .  c o m*/

    try {
        portlet = getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());

        setForward(actionRequest, "portlet.portlet_configuration.error");
    }

    updatePreferences(actionRequest, portlet);

    if (SessionErrors.isEmpty(actionRequest)) {
        String portletResource = ParamUtil.getString(actionRequest, "portletResource");

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION);

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

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

From source file:com.liferay.portlet.portletconfiguration.action.EditPublicRenderParametersAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    Portlet portlet = null;//  w  w  w . j  a  va 2  s  . c  om

    try {
        portlet = getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());

        return mapping.findForward("portlet.portlet_configuration.error");
    }

    ActionUtil.getLayoutPublicRenderParameters(renderRequest);

    ActionUtil.getPublicRenderParameterConfigurationList(renderRequest, portlet);

    renderResponse.setTitle(getTitle(portlet, renderRequest));

    return mapping.findForward(
            getForward(renderRequest, "portlet.portlet_configuration.edit_public_render_parameters"));
}

From source file:com.liferay.portlet.portletconfiguration.action.EditScopeAction.java

License:Open Source License

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

    Portlet portlet = null;// w  w w  .  j  a v  a 2  s .  c  o  m

    try {
        portlet = getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());

        setForward(actionRequest, "portlet.portlet_configuration.error");
    }

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

    if (cmd.equals(Constants.SAVE)) {
        updateScope(actionRequest, portlet);
    }

    if (SessionErrors.isEmpty(actionRequest)) {
        String portletResource = ParamUtil.getString(actionRequest, "portletResource");

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION);

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

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

From source file:com.liferay.portlet.portletconfiguration.action.EditScopeAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    Portlet portlet = null;/*from  w  w  w  .j ava 2  s.  co m*/

    try {
        portlet = getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());

        return mapping.findForward("portlet.portlet_configuration.error");
    }

    renderResponse.setTitle(getTitle(portlet, renderRequest));

    return mapping.findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_scope"));
}

From source file:com.liferay.portlet.portletconfiguration.action.EditSharingAction.java

License:Open Source License

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

    Portlet portlet = null;/*from   ww  w . ja v a  2  s .  co m*/

    try {
        portlet = getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());

        setForward(actionRequest, "portlet.portlet_configuration.error");
    }

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

    Layout layout = themeDisplay.getLayout();

    PortletPreferences preferences = PortletPreferencesFactoryUtil.getLayoutPortletSetup(layout,
            portlet.getPortletId());

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

    if (tabs2.equals("any-website")) {
        updateAnyWebsite(actionRequest, preferences);
    } else if (tabs2.equals("facebook")) {
        updateFacebook(actionRequest, preferences);
    } else if (tabs2.equals("friends")) {
        updateFriends(actionRequest, preferences);
    } else if (tabs2.equals("opensocial-gadget")) {
        updateGoogleGadget(actionRequest, preferences);
    } else if (tabs2.equals("netvibes")) {
        updateNetvibes(actionRequest, preferences);
    }

    preferences.store();

    if (SessionErrors.isEmpty(actionRequest)) {
        String portletResource = ParamUtil.getString(actionRequest, "portletResource");

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_REFRESH_PORTLET, portletResource);

        SessionMessages.add(actionRequest,
                portletConfig.getPortletName() + SessionMessages.KEY_SUFFIX_UPDATED_CONFIGURATION);

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

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

From source file:com.liferay.portlet.portletconfiguration.action.EditSharingAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    Portlet portlet = null;/* ww  w . j  a  va 2  s  . co  m*/

    try {
        portlet = getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());

        return mapping.findForward("portlet.portlet_configuration.error");
    }

    renderResponse.setTitle(getTitle(portlet, renderRequest));

    return mapping.findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_sharing"));
}

From source file:com.liferay.portlet.portletconfiguration.action.EditSupportedClientsAction.java

License:Open Source License

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

    Portlet portlet = null;/*from ww  w . jav a2s .  c o  m*/

    try {
        portlet = getPortlet(actionRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(actionRequest, PrincipalException.class.getName());

        setForward(actionRequest, "portlet.portlet_configuration.error");
    }

    updateSupportedClients(portlet, actionRequest);

    sendRedirect(actionRequest, actionResponse);
}

From source file:com.liferay.portlet.portletconfiguration.action.EditSupportedClientsAction.java

License:Open Source License

@Override
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {

    Portlet portlet = null;//from   w  w w.  java  2s.c o m

    try {
        portlet = getPortlet(renderRequest);
    } catch (PrincipalException pe) {
        SessionErrors.add(renderRequest, PrincipalException.class.getName());

        return mapping.findForward("portlet.portlet_configuration.error");
    }

    renderResponse.setTitle(getTitle(portlet, renderRequest));

    return mapping
            .findForward(getForward(renderRequest, "portlet.portlet_configuration.edit_supported_clients"));
}