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.login.action.LoginAction.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);

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;/*from  w  w w .  ja  v a2s  .c  om*/
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest);

        login(themeDisplay, actionRequest, actionResponse, preferences);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            setForward(actionRequest, "portlet.login.login_redirect");
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass().getName());
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass().getName());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

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

            PortalUtil.sendError(e, actionRequest, actionResponse);
        }
    }
}

From source file:com.liferay.portlet.login.action.OpenIdAction.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);

    if (actionRequest.getRemoteUser() != null) {
        actionResponse.sendRedirect(themeDisplay.getPathMain());

        return;// w w w  .ja va2s .c  om
    }

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

    try {
        if (cmd.equals(Constants.READ)) {
            String redirect = readOpenIdResponse(themeDisplay, actionRequest, actionResponse);

            if (Validator.isNull(redirect)) {
                redirect = PortalUtil.getPortalURL(actionRequest) + themeDisplay.getURLSignIn();
            }

            sendRedirect(actionRequest, actionResponse, redirect);
        } else {
            sendOpenIdRequest(themeDisplay, actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof DuplicateUserEmailAddressException) {
            SessionErrors.add(actionRequest, e.getClass().getName());
        } else if (e instanceof OpenIDException) {
            if (_log.isInfoEnabled()) {
                _log.info("Error communicating with OpenID provider: " + e.getMessage());
            }

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else {
            _log.error("Error processing the OpenID login", e);

            PortalUtil.sendError(e, actionRequest, actionResponse);
        }
    }
}

From source file:com.liferay.portlet.login.action.SampleLoginAction.java

License:Open Source License

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

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

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;//from   w  ww .  ja va 2  s. com
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        login(themeDisplay, actionRequest, actionResponse);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            setForward(actionRequest, "portlet.login.login_redirect");
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass());
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

            SessionErrors.add(actionRequest, e.getClass());
        } else {
            _log.error(e, e);

            PortalUtil.sendError(e, actionRequest, actionResponse);

            return;
        }

        postProcessAuthFailure(actionRequest, actionResponse);
    }
}

From source file:com.liferay.portlet.login.action.STORKAction.java

License:Apache 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);
    long companyId = themeDisplay.getCompanyId();

    if (!STORKUtil.isEnabled(companyId)) {
        throw new PrincipalException();
    }//from w w  w  . j av a2s.com

    String storkMandatoryAttr = PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_AUTH_LOCAL_SEARCH_FILTER,
            FedPropsValues.STORK_AUTH_LOCAL_SEARCH_FILTER);
    Map<String, String> storkUserMapping = getAttrMap(
            PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_USER_MAPPING));

    if (ParamUtil.getString(actionRequest, "StorkAction", "none").equals("login")) {
        byte[] decSamlToken = PEPSUtil.decodeSAMLToken(ParamUtil.getString(actionRequest, "SAMLResponse"));
        STORKSAMLEngine storkEngine = STORKSAMLEngine.getInstance("SP");
        STORKAuthnResponse authnResponse = null;
        try {
            authnResponse = storkEngine.validateSTORKAuthnResponse(decSamlToken,
                    PortalUtil.getHttpServletRequest(actionRequest).getRemoteHost());
        } catch (Exception ex) {
            _log.error("Could not validate token for Saml Response");
            _log.error(ex);
            setForward(actionRequest, "portlet.login.stork.error");
            return;
        }
        _log.debug("Authentication response status: " + authnResponse.getStatusCode() + "(reason: "
                + authnResponse.getSubStatusCode() + ") and this is a fail: " + authnResponse.isFail());
        if (!authnResponse.isFail()) {
            Map<String, PersonalAttribute> mPersAttr = createPersonalAttributeMap(
                    authnResponse.getPersonalAttributeList().values());

            User user = null;
            if (storkMandatoryAttr.equals("screenName")) {
                _log.debug("Finding user using the " + storkUserMapping.get("screenName"));
                if (mPersAttr.containsKey(storkUserMapping.get("screenName"))) {
                    Iterator<String> pa = mPersAttr.get(storkUserMapping.get("screenName")).getValue()
                            .iterator();

                    while (pa.hasNext() && user == null) {
                        String screenName = pa.next();
                        try {
                            user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);
                        } catch (NoSuchUserException nse) {
                            _log.info("User screenName: " + screenName + " is not registered");
                        }
                    }
                } else {
                    actionResponse.sendRedirect(
                            PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_AUTH_PAGE_MISS_ATTRIBUTE,
                                    FedPropsValues.STORK_AUTH_PAGE_MISS_ATTRIBUTE));
                    _log.info("Stork authentication miss the matching attribute. Impossible to identify users");
                    return;
                }
            }
            if (storkMandatoryAttr.equals("uuid")) {
                _log.debug("Finding user using the " + storkUserMapping.get("uuid"));
                if (mPersAttr.containsKey(storkUserMapping.get("uuid"))) {
                    Iterator<String> pa = mPersAttr.get(storkUserMapping.get("uuid")).getValue().iterator();

                    while (pa.hasNext() && user == null) {
                        String uuid = pa.next();
                        try {
                            user = UserLocalServiceUtil.getUserByUuid(uuid);
                        } catch (NoSuchUserException nse) {
                            _log.info("User uuid: " + uuid + " is not registered");
                        }
                    }
                } else {
                    actionResponse.sendRedirect(
                            PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_AUTH_PAGE_MISS_ATTRIBUTE,
                                    FedPropsValues.STORK_AUTH_PAGE_MISS_ATTRIBUTE));
                    _log.info("Stork authentication miss the matching attribute. Impossible to identify users");
                    return;
                }

            }
            if (storkMandatoryAttr.equals("emailAddress")) {
                _log.debug("Finding user using the " + storkUserMapping.get("emailAddress"));
                if (mPersAttr.containsKey(storkUserMapping.get("emailAddress"))) {
                    Iterator<String> pa = mPersAttr.get(storkUserMapping.get("emailAddress")).getValue()
                            .iterator();

                    while (pa.hasNext() && user == null) {
                        Pattern pat = Pattern.compile("[\\w\\-]([\\.\\w\\-])+@([\\w\\-]+\\.)+[a-zA-Z]{2,4}");
                        Matcher mailMatch;

                        mailMatch = pat.matcher(pa.next());
                        while (mailMatch.find() && user == null) {
                            if (Validator.isNotNull(mailMatch.group())) {
                                try {
                                    user = UserLocalServiceUtil.getUserByEmailAddress(companyId,
                                            mailMatch.group());
                                } catch (NoSuchUserException nse) {
                                    _log.info("Mail: " + mailMatch.group() + " is not registered");
                                }
                            }
                        }

                    }
                } else {
                    actionResponse.sendRedirect(
                            PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_AUTH_PAGE_MISS_ATTRIBUTE,
                                    FedPropsValues.STORK_AUTH_PAGE_MISS_ATTRIBUTE));
                    _log.info("Stork authentication miss the matching attribute. Impossible to identify users");
                    return;
                }

            }

            if (user == null && PrefsPropsUtil.getBoolean(companyId, FedPropsKeys.STORK_AUTH_LDLAP_CHECK,
                    FedPropsValues.STORK_AUTH_LDLAP_CHECK)) {
                _log.debug("User not found, check on LDAP");
                //                    user=getUserFromLdap();

                String originalLdapFilter = PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                        FedPropsKeys.STORK_AUTH_LDAP_SEARCH_FILTER,
                        FedPropsValues.STORK_AUTH_LDAP_SEARCH_FILTER);
                List<String> lstLdapFilter = null;
                try {
                    lstLdapFilter = generateFilters(companyId,
                            mPersAttr.get(storkUserMapping.get("screenName")),
                            mPersAttr.get(storkUserMapping.get("emailAddress")),
                            mPersAttr.get(storkUserMapping.get("firstName")),
                            mPersAttr.get(storkUserMapping.get("lastName")), originalLdapFilter);
                } catch (STORKException se) {
                    _log.error(se.getMessage());
                    actionResponse.sendRedirect(
                            PrefsPropsUtil.getString(companyId, FedPropsKeys.STORK_AUTH_PAGE_MISS_ATTRIBUTE,
                                    FedPropsValues.STORK_AUTH_PAGE_MISS_ATTRIBUTE));
                    return;
                }
                String[] idLDAPS = PrefsPropsUtil.getStringArray(companyId, "ldap.server.ids", ",");
                String idLDAP;
                int idLDAPCounter = 0;
                while (user == null && idLDAPCounter < idLDAPS.length) {
                    idLDAP = idLDAPS[idLDAPCounter++];

                    String mailMap = null;
                    String userMaps[] = PrefsPropsUtil
                            .getString(companyId, PropsKeys.LDAP_USER_MAPPINGS + "." + idLDAP).split("\n");
                    int mIndex = 0;
                    while (mailMap == null && mIndex < userMaps.length) {
                        String map = userMaps[mIndex++];
                        if (map.indexOf("=") == -1 || map.split("=").length != 2) {
                            continue;
                        }
                        String[] sMap = map.split("=");
                        if (sMap[0].equals("emailAddress")) {
                            mailMap = sMap[1];
                        }
                    }

                    if (mailMap == null) {
                        _log.warn("LDAP server configured without the mail map");
                        continue;
                    }

                    LDAPUtil samlLdapUtil = new LDAPUtil(
                            PrefsPropsUtil.getString(companyId,
                                    PropsKeys.LDAP_BASE_PROVIDER_URL + "." + idLDAP),
                            PrefsPropsUtil.getString(companyId, PropsKeys.LDAP_BASE_DN + "." + idLDAP));

                    Iterator<String> ldapFilter = lstLdapFilter.iterator();

                    while (ldapFilter.hasNext() && user == null) {
                        String mail = samlLdapUtil.getUserAttribute(
                                PrefsPropsUtil.getString(companyId,
                                        PropsKeys.LDAP_IMPORT_USER_SEARCH_FILTER + "." + idLDAP),
                                ldapFilter.next(), mailMap);

                        if (mail != null) {
                            try {
                                user = UserLocalServiceUtil.getUserByEmailAddress(companyId, mail);
                            } catch (NoSuchUserException nse) {
                                _log.debug("Mail: " + mail + " found in LDAP but it is not registered");
                            }
                        }
                    }
                }

            }

            if (user == null) {
                _log.info("Impossible to find a user with the current attributes");
                actionResponse.sendRedirect(PrefsPropsUtil.getString(themeDisplay.getCompanyId(),
                        FedPropsKeys.STORK_AUTH_PAGE_MISS_USER, FedPropsValues.STORK_AUTH_PAGE_MISS_USER));
                return;
            }

            HttpSession session = PortalUtil.getHttpServletRequest(actionRequest).getSession();
            session.setAttribute(FedWebKeys.STORK_ID_LOGIN, new Long(user.getUserId()));

            //                sendRedirect(actionRequest, actionResponse, PortalUtil.getPortalURL(actionRequest) + themeDisplay.getURLSignIn());
            sendRedirect(actionRequest, actionResponse, ParamUtil.getString(actionRequest, "redirect",
                    PortalUtil.getPortalURL(actionRequest) + themeDisplay.getURLSignIn()));
        } else {
            setForward(actionRequest, "portlet.login.stork.notAuth");
        }

    } else {

        if (Validator.isNull(ParamUtil.getString(actionRequest, "citizenCountry"))) {
            SessionErrors.add(actionRequest, "missUserCountry");
            return;
        }
        STORKAuthnRequest authnRequest = new STORKAuthnRequest();

        authnRequest.setCitizenCountryCode(ParamUtil.getString(actionRequest, "citizenCountry"));

        authnRequest
                .setIssuer(PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_NAME));

        authnRequest.setDestination(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SPEPS_URL));

        authnRequest.setProviderName(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_NAME));

        authnRequest
                .setQaa(PrefsPropsUtil.getInteger(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_QAALEVEL));

        ActionResponseImpl actionResponseImpl = (ActionResponseImpl) actionResponse;
        PortletURL portletURL = actionResponseImpl.createActionURL();
        portletURL.setParameter("struts_action", "/login/stork");
        portletURL.setParameter("StorkAction", "login");
        portletURL.setParameter("saveLastPath", "0");
        portletURL.setParameter("redirect",
                ParamUtil.getString(actionRequest, "redirect", themeDisplay.getPathMain()));
        portletURL.setWindowState(WindowState.NORMAL);

        authnRequest.setAssertionConsumerServiceURL(portletURL.toString());
        _log.debug("STORK Return url: " + portletURL.toString());

        authnRequest.setSpSector(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_SECTOR));

        authnRequest.setSpInstitution(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_NAME));

        authnRequest.setSpApplication(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_APLICATION));

        authnRequest.setSpCountry(
                PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_COUNTRY));

        authnRequest.setSPID(PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SP_NAME));

        IPersonalAttributeList pAttList = new PersonalAttributeList();

        boolean eIdentifier = false;
        if (storkUserMapping != null) {

            for (String attrMap : storkUserMapping.keySet()) {
                PersonalAttribute attr = new PersonalAttribute();
                attr.setName(storkUserMapping.get(attrMap));
                if (attrMap.equals(storkMandatoryAttr) && storkUserMapping.get(attrMap).equals("eIdentifier")) {
                    attr.setIsRequired(true);
                    eIdentifier = true;
                    _log.debug("Attribute " + attrMap + " mapped in " + storkUserMapping.get(attrMap)
                            + " is required");
                } else {
                    if (attrMap.equals(storkMandatoryAttr)) {
                        attr.setIsRequired(true);
                        _log.debug("Attribute " + attrMap + " mapped in " + storkUserMapping.get(attrMap)
                                + " is required");
                    } else {
                        attr.setIsRequired(false);
                        _log.debug("Attribute " + attrMap + " mapped in " + storkUserMapping.get(attrMap)
                                + " is not required");

                    }
                }
                pAttList.add(attr);
            }
            if (!eIdentifier) {
                pAttList.add(new PersonalAttribute("eIdentifier", true, null, null));
            }
        }

        authnRequest.setPersonalAttributeList(pAttList);

        byte token[] = null;
        try {

            STORKSAMLEngine storkEngine = STORKSAMLEngine.getInstance("SP");
            token = storkEngine.generateSTORKAuthnRequest(authnRequest).getTokenSaml();

        } catch (Exception ex) {
            _log.error("Impossible to create the SAML token");
            _log.error(ex);
            setForward(actionRequest, "portlet.login.stork.error");
        }

        if (token != null) {
            actionResponse.setRenderParameter("SAMLToken", PEPSUtil.encodeSAMLToken(token));
            actionResponse.setRenderParameter("CCountry", ParamUtil.getString(actionRequest, "citizenCountry"));
            actionResponse.setRenderParameter("PEPSUrl",
                    PrefsPropsUtil.getString(themeDisplay.getCompanyId(), FedPropsKeys.STORK_SPEPS_URL));
            setForward(actionRequest, "portlet.login.stork.peps");
        }
    }
}

From source file:com.liferay.portlet.messageboards.action.BanUserAction.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 .jav  a  2s  .  c  o  m
        if (cmd.equals("ban")) {
            banUser(actionRequest);
        } else if (cmd.equals("unban")) {
            unbanUser(actionRequest);
        }

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

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

From source file:com.liferay.portlet.messageboards.action.ConfigurationActionImpl.java

License:Open Source License

protected void validateEmailMessageAdded(ActionRequest actionRequest) throws Exception {

    String emailMessageAddedSubjectPrefix = getParameter(actionRequest, "emailMessageAddedSubjectPrefix");
    String emailMessageAddedBody = getParameter(actionRequest, "emailMessageAddedBody");

    if (Validator.isNull(emailMessageAddedSubjectPrefix)) {
        SessionErrors.add(actionRequest, "emailMessageAddedSubjectPrefix");
    } else if (Validator.isNull(emailMessageAddedBody)) {
        SessionErrors.add(actionRequest, "emailMessageAddedBody");
    }//from  ww w  .  j  av  a  2s .  co m
}

From source file:com.liferay.portlet.messageboards.action.ConfigurationActionImpl.java

License:Open Source License

protected void validateEmailMessageUpdated(ActionRequest actionRequest) throws Exception {

    String emailMessageUpdatedSubjectPrefix = getParameter(actionRequest, "emailMessageUpdatedSubjectPrefix");
    String emailMessageUpdatedBody = getParameter(actionRequest, "emailMessageUpdatedBody");

    if (Validator.isNull(emailMessageUpdatedSubjectPrefix)) {
        SessionErrors.add(actionRequest, "emailMessageUpdatedSubjectPrefix");
    } else if (Validator.isNull(emailMessageUpdatedBody)) {
        SessionErrors.add(actionRequest, "emailMessageUpdatedBody");
    }// ww w . ja v  a 2s .  c  o m
}

From source file:com.liferay.portlet.messageboards.action.DeleteThreadAction.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  .ja v  a  2s  . co m
        deleteThreads(actionRequest, actionResponse);

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

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

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

From source file:com.liferay.portlet.messageboards.action.EditCategoryAction.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  w  w  .j a  v  a2  s.co m*/
        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            updateCategory(actionRequest);
        } else if (cmd.equals(Constants.DELETE)) {
            deleteCategories(actionRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE)) {
            subscribeCategory(actionRequest);
        } else if (cmd.equals(Constants.UNSUBSCRIBE)) {
            unsubscribeCategory(actionRequest);
        }

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

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

            setForward(actionRequest, "portlet.message_boards.error");
        } else if (e instanceof CaptchaMaxChallengesException || e instanceof CaptchaTextException
                || e instanceof CategoryNameException || e instanceof MailingListEmailAddressException
                || e instanceof MailingListInServerNameException || e instanceof MailingListInUserNameException
                || e instanceof MailingListOutEmailAddressException
                || e instanceof MailingListOutServerNameException
                || e instanceof MailingListOutUserNameException) {

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

From source file:com.liferay.portlet.messageboards.action.EditCategoryAction.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  va  2s  . c om*/
        ActionUtil.getCategory(renderRequest);
    } catch (Exception e) {
        if (e instanceof NoSuchCategoryException || e instanceof PrincipalException) {

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

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

    return mapping.findForward(getForward(renderRequest, "portlet.message_boards.edit_category"));
}