Example usage for com.liferay.portal.util PropsValues COMPANY_SECURITY_STRANGERS_URL

List of usage examples for com.liferay.portal.util PropsValues COMPANY_SECURITY_STRANGERS_URL

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues COMPANY_SECURITY_STRANGERS_URL.

Prototype

String COMPANY_SECURITY_STRANGERS_URL

To view the source code for com.liferay.portal.util PropsValues COMPANY_SECURITY_STRANGERS_URL.

Click Source Link

Usage

From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java

License:Open Source License

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

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

    Company company = themeDisplay.getCompany();

    if (!company.isStrangers()) {
        throw new PrincipalException.MustBeEnabled(company.getCompanyId(),
                PropsKeys.COMPANY_SECURITY_STRANGERS);
    }/*from w  w  w .j  a  v  a 2 s . co  m*/

    actionRequest = _wrapActionRequest(actionRequest);

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

    try {
        if (cmd.equals(Constants.ADD)) {
            CaptchaConfiguration captchaConfiguration = getCaptchaConfiguration();

            if (captchaConfiguration.createAccountCaptchaEnabled()) {
                CaptchaUtil.check(actionRequest);
            }

            addUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.RESET)) {
            resetUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.UPDATE)) {
            updateIncompleteUser(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof UserEmailAddressException.MustNotBeDuplicate
                || e instanceof UserScreenNameException.MustNotBeDuplicate) {

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

            User user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress);

            if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) {

                SessionErrors.add(actionRequest, e.getClass(), e);
            } else {
                actionResponse.setRenderParameter("mvcPath", "/update_account.jsp");
            }
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof CaptchaConfigurationException
                || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException
                || e instanceof ContactBirthdayException || e instanceof ContactNameException
                || e instanceof DuplicateOpenIdException || e instanceof EmailAddressException
                || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException
                || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException
                || e instanceof NoSuchRegionException || e instanceof OrganizationParentException
                || e instanceof PhoneNumberException || e instanceof RequiredFieldException
                || e instanceof RequiredUserException || e instanceof TermsOfUseException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserPasswordException || e instanceof UserScreenNameException
                || e instanceof UserSmsException || e instanceof WebsiteURLException) {

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

    if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) {
        return;
    }

    try {
        Layout layout = _layoutLocalService.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false,
                PropsValues.COMPANY_SECURITY_STRANGERS_URL);

        String redirect = _portal.getLayoutURL(layout, themeDisplay);

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (NoSuchLayoutException nsle) {

        // LPS-52675

        if (_log.isDebugEnabled()) {
            _log.debug(nsle, nsle);
        }
    }
}

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

    try {//from  w ww . j a va 2 s.  co m
        if (cmd.equals(Constants.ADD)) {
            if (PropsValues.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT) {
                CaptchaUtil.check(actionRequest);
            }

            addUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.RESET)) {
            resetUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.UPDATE)) {
            updateIncompleteUser(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof DuplicateUserEmailAddressException || e instanceof DuplicateUserScreenNameException) {

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

            try {
                User user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(),
                        emailAddress);

                if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) {

                    SessionErrors.add(actionRequest, e.getClass().getName(), e);
                } else {
                    setForward(actionRequest, "portlet.login.update_account");
                }
            } catch (NoSuchUserException nsue) {
                SessionErrors.add(actionRequest, e.getClass().getName(), e);
            }
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof CaptchaMaxChallengesException
                || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException
                || e instanceof ContactFirstNameException || e instanceof ContactFullNameException
                || e instanceof ContactLastNameException || e instanceof EmailAddressException
                || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException
                || e instanceof NoSuchOrganizationException || e instanceof NoSuchRegionException
                || e instanceof OrganizationParentException || e instanceof PhoneNumberException
                || e instanceof RequiredFieldException || e instanceof RequiredUserException
                || e instanceof ReservedUserEmailAddressException
                || e instanceof ReservedUserScreenNameException || e instanceof TermsOfUseException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserPasswordException || e instanceof UserScreenNameException
                || e instanceof UserSmsException || e instanceof WebsiteURLException) {

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

    if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) {
        return;
    }

    try {
        Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false,
                PropsValues.COMPANY_SECURITY_STRANGERS_URL);

        String redirect = PortalUtil.getLayoutURL(layout, themeDisplay);

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (NoSuchLayoutException nsle) {
    }
}

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

    Company company = themeDisplay.getCompany();

    if (!company.isStrangers()) {
        throw new PrincipalException();
    }//www . j a  v  a 2  s  .c  om

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

    try {
        if (cmd.equals(Constants.ADD)) {
            if (PropsValues.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT) {
                CaptchaUtil.check(actionRequest);
            }

            addUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.RESET)) {
            resetUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.UPDATE)) {
            updateIncompleteUser(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof DuplicateUserEmailAddressException || e instanceof DuplicateUserScreenNameException) {

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

            try {
                User user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(),
                        emailAddress);

                if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) {

                    SessionErrors.add(actionRequest, e.getClass(), e);
                } else {
                    setForward(actionRequest, "portlet.login.update_account");
                }
            } catch (NoSuchUserException nsue) {
                SessionErrors.add(actionRequest, e.getClass(), e);
            }
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof CaptchaMaxChallengesException
                || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException
                || e instanceof ContactFirstNameException || e instanceof ContactFullNameException
                || e instanceof ContactLastNameException || e instanceof EmailAddressException
                || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException
                || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException
                || e instanceof NoSuchRegionException || e instanceof OrganizationParentException
                || e instanceof PhoneNumberException || e instanceof RequiredFieldException
                || e instanceof RequiredUserException || e instanceof ReservedUserEmailAddressException
                || e instanceof ReservedUserScreenNameException || e instanceof TermsOfUseException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserPasswordException || e instanceof UserScreenNameException
                || e instanceof UserSmsException || e instanceof WebsiteURLException) {

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

    if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) {
        return;
    }

    try {
        Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false,
                PropsValues.COMPANY_SECURITY_STRANGERS_URL);

        String redirect = PortalUtil.getLayoutURL(layout, themeDisplay);

        sendRedirect(actionRequest, actionResponse, redirect);
    } catch (NoSuchLayoutException nsle) {
    }
}

From source file:it.innova.livingLabs.hook.action.MyCreateAccountAction.java

License:Open Source License

@Override
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    //TODO Auto-generated method stub
    System.out.println("inside the process actionwhile creating the account>>>");
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    Company company = themeDisplay.getCompany();

    if (!company.isStrangers()) {
        throw new PrincipalException();
    }/*from  w  w  w.j  a  v  a 2s. c  om*/

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

    try {
        if (cmd.equals(Constants.ADD)) {
            if (PropsValues.CAPTCHA_CHECK_PORTAL_CREATE_ACCOUNT) {
                CaptchaUtil.check(actionRequest);
            }

            addUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.RESET)) {
            resetUser(actionRequest, actionResponse);
        } else if (cmd.equals(Constants.UPDATE)) {
            updateIncompleteUser(actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof DuplicateUserEmailAddressException || e instanceof DuplicateUserScreenNameException) {

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

            try {
                User user = UserLocalServiceUtil.getUserByEmailAddress(themeDisplay.getCompanyId(),
                        emailAddress);

                if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) {

                    SessionErrors.add(actionRequest, e.getClass(), e);
                } else {
                    //setForward(actionRequest, "portlet.login.update_account");
                }
            } catch (NoSuchUserException nsue) {
                SessionErrors.add(actionRequest, e.getClass(), e);
            }
        } else if (e instanceof AddressCityException || e instanceof AddressStreetException
                || e instanceof AddressZipException || e instanceof CaptchaMaxChallengesException
                || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException
                || e instanceof ContactFirstNameException || e instanceof ContactFullNameException
                || e instanceof ContactLastNameException || e instanceof EmailAddressException
                || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException
                || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException
                || e instanceof NoSuchRegionException || e instanceof OrganizationParentException
                || e instanceof PhoneNumberException || e instanceof RequiredFieldException
                || e instanceof RequiredUserException || e instanceof ReservedUserEmailAddressException
                || e instanceof ReservedUserScreenNameException || e instanceof TermsOfUseException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserPasswordException || e instanceof UserScreenNameException
                || e instanceof UserSmsException || e instanceof WebsiteURLException) {

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

    if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) {
        return;
    }

    try {
        Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false,
                PropsValues.COMPANY_SECURITY_STRANGERS_URL);

        String redirect = PortalUtil.getLayoutURL(layout, themeDisplay);

        //sendRedirect(actionRequest, actionResponse, redirect);
    } catch (NoSuchLayoutException nsle) {
    }
}