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.sites.action.PostMembershipRequestAction.java

License:Open Source License

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

    try {/*  ww  w.  jav  a2 s  . com*/
        long groupId = ParamUtil.getLong(actionRequest, "groupId");
        String comments = ParamUtil.getString(actionRequest, "comments");

        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        MembershipRequestServiceUtil.addMembershipRequest(groupId, comments, serviceContext);

        SessionMessages.add(actionRequest, "membership_request_sent");

        sendRedirect(actionRequest, actionResponse);
    } 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 MembershipRequestCommentsException) {

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

            setForward(actionRequest, "portlet.sites_admin.post_membership_request");
        } else {
            throw e;
        }
    }
}

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

License:Open Source License

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

    try {/*  w w w . j  av  a  2s. c  om*/
        ActionUtil.getGroup(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.sites_admin.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.sites_admin.post_membership_request"));
}

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

License:Open Source License

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

    try {//w w w  . j a  v  a  2 s.c  om
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

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

        int statusId = ParamUtil.getInteger(actionRequest, "statusId");
        String replyComments = ParamUtil.getString(actionRequest, "replyComments");

        ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

        MembershipRequestServiceUtil.updateStatus(membershipRequestId, replyComments, statusId, serviceContext);

        if (statusId == MembershipRequestConstants.STATUS_APPROVED) {
            MembershipRequest membershipRequest = MembershipRequestServiceUtil
                    .getMembershipRequest(membershipRequestId);

            LiveUsers.joinGroup(themeDisplay.getCompanyId(), membershipRequest.getGroupId(),
                    new long[] { membershipRequest.getUserId() });
        }

        SessionMessages.add(actionRequest, "membership_reply_sent");

        sendRedirect(actionRequest, actionResponse);
    } 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 MembershipRequestCommentsException) {

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

            setForward(actionRequest, "portlet.sites_admin.reply_membership_request");
        } else {
            throw e;
        }
    }
}

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

License:Open Source License

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

    try {/*  ww w.  j a  v a2  s  .co m*/
        ActionUtil.getGroup(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.sites_admin.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.sites_admin.reply_membership_request"));
}

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

License:Open Source License

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

    try {/*from ww  w .  ja  v  a 2 s.  c  o  m*/
        ActionUtil.getGroup(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchGroupException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.sites_admin.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.sites_admin.view_membership_requests"));
}

From source file:com.liferay.portlet.softwarecatalog.action.EditFrameworkVersionAction.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 {//from   w ww  .ja  v a2s  . co  m
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateFrameworkVersion(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteFrameworkVersion(actionRequest);
        }

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

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

            setForward(actionRequest, "portlet.software_catalog.error");
        } else if (e instanceof FrameworkVersionNameException) {

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

From source file:com.liferay.portlet.softwarecatalog.action.EditFrameworkVersionAction.java

License:Open Source License

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

    try {//from w  w w . j a v  a 2 s  .c  o  m
        ActionUtil.getFrameworkVersion(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchFrameworkVersionException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.software_catalog.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.software_catalog.edit_framework_version"));
}

From source file:com.liferay.portlet.softwarecatalog.action.EditLicenseAction.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 . ja  v  a 2  s . c  o m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateLicense(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteLicense(actionRequest);
        }

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

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

            setForward(actionRequest, "portlet.software_catalog.error");
        } else if (e instanceof LicenseNameException) {

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

From source file:com.liferay.portlet.softwarecatalog.action.EditLicenseAction.java

License:Open Source License

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

    try {/*  w  w w. j a  v a  2s.co m*/
        ActionUtil.getLicense(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchLicenseException || e instanceof PrincipalException) {

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

            return mapping.findForward("portlet.software_catalog.error");
        } else {
            throw e;
        }
    }

    return mapping.findForward(getForward(renderRequest, "portlet.software_catalog.edit_license"));
}

From source file:com.liferay.portlet.softwarecatalog.action.EditProductEntryAction.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  .  j a  va 2s  .c o  m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateProductEntry(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteProductEntry(actionRequest);
        }

        if (Validator.isNotNull(cmd)) {
            sendRedirect(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchProductEntryException || e instanceof PrincipalException) {

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

            setForward(actionRequest, "portlet.software_catalog.error");
        } else if (e instanceof DuplicateProductEntryModuleIdException
                || e instanceof ProductEntryAuthorException || e instanceof ProductEntryNameException
                || e instanceof ProductEntryLicenseException || e instanceof ProductEntryPageURLException
                || e instanceof ProductEntryScreenshotsException
                || e instanceof ProductEntryShortDescriptionException
                || e instanceof ProductEntryTypeException) {

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