Example usage for com.liferay.portal.kernel.util ParamUtil getBoolean

List of usage examples for com.liferay.portal.kernel.util ParamUtil getBoolean

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ParamUtil getBoolean.

Prototype

public static boolean getBoolean(ServiceContext serviceContext, String param, boolean defaultValue) 

Source Link

Document

Returns the service context parameter value as a boolean.

Usage

From source file:com.abubusoft.liferay.linkedin.CreateAccountAction.java

License:Open Source License

protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
    HttpSession session = request.getSession();

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

    Company company = themeDisplay.getCompany();

    long creatorUserId = 0;
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    boolean autoPassword = true;
    boolean autoScreenName = false;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    boolean sendEmail = true;
    String linkedinId = ParamUtil.getString(actionRequest, "linkedinId");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String password1 = StringPool.BLANK;
    String password2 = StringPool.BLANK;
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    String openId = StringPool.BLANK;
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    Locale locale = themeDisplay.getLocale();

    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {
        autoPassword = false;//from   ww w . ja  v a  2  s  .  c om

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), autoPassword, password1,
            password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, "linkedinId", user.getUserId(), linkedinId);

    session.setAttribute(LinkedinConstants.LINKEDIN_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(LinkedinConstants.LINKEDIN_LOGIN_PENDING);

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(LiferayWindowState.POP_UP);
    portletURL.setParameter("struts_action", "/login/login_redirect");

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.abubusoft.liferay.twitter.CreateAccountAction.java

License:Open Source License

protected void addUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
    HttpSession session = request.getSession();

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

    Company company = themeDisplay.getCompany();

    long creatorUserId = 0;
    long facebookId = ParamUtil.getLong(actionRequest, "facebookId");
    boolean autoPassword = true;
    boolean autoScreenName = false;
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    boolean sendEmail = true;
    String twitterId = ParamUtil.getString(actionRequest, "twitterId");
    String emailAddress = ParamUtil.getString(actionRequest, "emailAddress");
    String screenName = ParamUtil.getString(actionRequest, "screenName");
    String firstName = ParamUtil.getString(actionRequest, "firstName");
    String lastName = ParamUtil.getString(actionRequest, "lastName");
    String middleName = ParamUtil.getString(actionRequest, "middleName");
    String password1 = StringPool.BLANK;
    String password2 = StringPool.BLANK;
    String jobTitle = ParamUtil.getString(actionRequest, "jobTitle");
    String openId = StringPool.BLANK;
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    int prefixId = ParamUtil.getInteger(actionRequest, "prefixId");
    int suffixId = ParamUtil.getInteger(actionRequest, "suffixId");
    Locale locale = themeDisplay.getLocale();

    long[] groupIds = null;
    long[] organizationIds = null;
    long[] roleIds = null;
    long[] userGroupIds = null;

    if (GetterUtil.getBoolean(PropsUtil.get(PropsKeys.LOGIN_CREATE_ACCOUNT_ALLOW_CUSTOM_PASSWORD))) {
        autoPassword = false;//  www. j  a v a2s.  co  m

        password1 = ParamUtil.getString(actionRequest, "password1");
        password2 = ParamUtil.getString(actionRequest, "password2");
    }

    ServiceContext serviceContext = new ServiceContext();

    User user = UserLocalServiceUtil.addUser(creatorUserId, company.getCompanyId(), autoPassword, password1,
            password2, autoScreenName, screenName, emailAddress, facebookId, openId, locale, firstName,
            middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle,
            groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);

    user = UserLocalServiceUtil.updateLastLogin(user.getUserId(), user.getLoginIP());

    user = UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    user = UserLocalServiceUtil.updateEmailAddressVerified(user.getUserId(), false);

    ExpandoValueLocalServiceUtil.addValue(company.getCompanyId(), User.class.getName(),
            ExpandoTableConstants.DEFAULT_TABLE_NAME, TwitterConstants.TWITTER_ID_COLUMN_NAME, user.getUserId(),
            twitterId);

    session.setAttribute(TwitterConstants.TWITTER_ID_LOGIN, new Long(user.getUserId()));

    session.removeAttribute(TwitterConstants.TWITTER_LOGIN_PENDING);

    PortletURL portletURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
            themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);

    portletURL.setWindowState(LiferayWindowState.POP_UP);
    portletURL.setParameter("struts_action", "/login/login_redirect");

    actionResponse.sendRedirect(portletURL.toString());
}

From source file:com.amf.registration.portlet.RegistrationPortlet.java

License:Open Source License

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

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

    String username = ParamUtil.getString(actionRequest, "username");
    String firstName = ParamUtil.getString(actionRequest, "first_name");
    String lastName = ParamUtil.getString(actionRequest, "last_name");
    String emailAddress = ParamUtil.getString(actionRequest, "email_address");
    boolean male = ParamUtil.getBoolean(actionRequest, "male", true);
    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth");
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay");
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear");
    String password1 = ParamUtil.getString(actionRequest, "password1");
    String password2 = ParamUtil.getString(actionRequest, "password2");

    String homePhone = ParamUtil.getString(actionRequest, "home_phone");
    String mobilePhone = ParamUtil.getString(actionRequest, "mobile_phone");

    String address = ParamUtil.getString(actionRequest, "address");
    String address2 = ParamUtil.getString(actionRequest, "address2");
    String city = ParamUtil.getString(actionRequest, "city");
    long stateId = ParamUtil.getLong(actionRequest, "state");
    String zip = ParamUtil.getString(actionRequest, "zip");

    String securityQuestion = ParamUtil.getString(actionRequest, "security_question");
    String securityAnswer = ParamUtil.getString(actionRequest, "security_answer");

    boolean acceptedTou = ParamUtil.getBoolean(actionRequest, "accepted_tou");

    Country country = CountryServiceUtil.getCountryByName(CountryConstants.UNITED_STATES);

    List<ListType> addressTypes = ListTypeServiceUtil.getListTypes(ListTypeConstants.CONTACT_ADDRESS);

    int typeId = 0;

    for (ListType addressType : addressTypes) {
        if (addressType.getName().equals("personal")) {
            typeId = addressType.getListTypeId();

            break;
        }/* www . j av  a 2  s  .c o  m*/
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest);

    validate(firstName, lastName, emailAddress, username, birthdayMonth, birthdayDay, birthdayYear, password1,
            password2, homePhone, mobilePhone, address, address2, city, zip, securityQuestion, securityAnswer,
            acceptedTou);

    User user = UserLocalServiceUtil.addUser(0, themeDisplay.getCompanyId(), false, password1, password2, false,
            username, emailAddress, 0, null, LocaleUtil.getDefault(), firstName, null, lastName, 0, 0, male,
            birthdayMonth, birthdayDay, birthdayYear, null, null, null, null, null, false, serviceContext);

    UserLocalServiceUtil.updatePasswordReset(user.getUserId(), false);

    UserLocalServiceUtil.updateReminderQuery(user.getUserId(), securityQuestion, securityAnswer);

    UserLocalServiceUtil.updateAgreedToTermsOfUse(user.getUserId(), acceptedTou);

    List<ListType> phoneTypes = ListTypeServiceUtil.getListTypes(ListTypeConstants.CONTACT_PHONE);

    for (ListType phoneType : phoneTypes) {
        if (phoneType.getName().equals("personal") && Validator.isNotNull(homePhone)) {

            PhoneLocalServiceUtil.addPhone(user.getUserId(), Contact.class.getName(), user.getContactId(),
                    homePhone, null, phoneType.getListTypeId(), false);
        } else if (phoneType.getName().equals("mobile-phone") && Validator.isNotNull(mobilePhone)) {

            PhoneLocalServiceUtil.addPhone(user.getUserId(), Contact.class.getName(), user.getContactId(),
                    mobilePhone, null, phoneType.getListTypeId(), false);
        }
    }

    AddressLocalServiceUtil.addAddress(user.getUserId(), Contact.class.getName(), user.getContactId(), address,
            address2, StringPool.BLANK, city, zip, stateId, country.getCountryId(), typeId, false, true);

    EventMonitorLocalServiceUtil.addEvent(user.getCompanyId(), user.getUserId(), user.getScreenName(),
            EventTypeConstants.REGISTRATION, IpConstants.DEFAULT);
}

From source file:com.evozon.evoportal.myaccount.builder.RequestAccountModelHolderBuilder.java

public AccountModelHolderBuilder buildDetailsModel() {
    DetailsModel detailsModel = new DetailsModel();

    detailsModel.setScreenName(ParamUtil.get(request, "screenName", StringPool.BLANK));
    detailsModel.setEmailAddress(ParamUtil.get(request, "emailAddress", StringPool.BLANK));
    detailsModel.setFirstName(ParamUtil.get(request, "firstName", StringPool.BLANK));
    detailsModel.setLastName(ParamUtil.get(request, "lastName", StringPool.BLANK));
    detailsModel.setMale(ParamUtil.getBoolean(request, "male", Boolean.FALSE));
    detailsModel.setBuilding(ParamUtil.get(request, "ExpandoAttribute--Building--", StringPool.BLANK));
    detailsModel.setJobTitle(ParamUtil.get(request, "jobTitle", StringPool.BLANK));
    detailsModel.setFunctieCIM(ParamUtil.get(request, "ExpandoAttribute--Functie CIM--", StringPool.BLANK));
    detailsModel.setCnp(ParamUtil.get(request, "userCNP", StringPool.BLANK));
    detailsModel.setLicensePlate(ParamUtil.get(request, "ExpandoAttribute--License Plate--", StringPool.BLANK));
    detailsModel.setBirthdayDate(getDateFromRequest("birthday"));
    detailsModel.setBirthdayHidden(ParamUtil.getBoolean(request, "hideBirthday", Boolean.FALSE));
    detailsModel.setSkype(ParamUtil.get(request, "skypeSn", StringPool.BLANK));
    detailsModel.setPhoneNumber(ParamUtil.get(request, "phoneNumber", StringPool.BLANK));
    detailsModel.setPhoneNumberHidden(ParamUtil.getBoolean(request, "hidePhones", Boolean.FALSE));
    detailsModel.setMarried(ParamUtil.getBoolean(request, "ExpandoAttribute--Married--", Boolean.FALSE));
    detailsModel.setStudent(ParamUtil.getBoolean(request, "isStudent", Boolean.FALSE));
    detailsModel.setUniversity(ParamUtil.get(request, "ExpandoAttribute--University--", StringPool.BLANK));
    detailsModel.setFaculty(ParamUtil.get(request, "ExpandoAttribute--Faculty--", StringPool.BLANK));
    detailsModel.setDiplomaTitle(//from ww w.  j a v a 2s .c  o  m
            ParamUtil.get(request, "ExpandoAttribute--Diploma title (In progress)--", StringPool.BLANK));
    detailsModel.setAdditionalEmailAddress(ParamUtil.get(request, "additionalEmailAddress", StringPool.BLANK));

    this.accountModelHolder.setDetailsModel(detailsModel);
    return this;
}

From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java

private static List<EvoAddressModel> getAddressesFromRequest(ActionRequest actionRequest) {
    List<EvoAddressModel> addresses = new ArrayList<EvoAddressModel>();

    String primaryIndexAddress = ParamUtil.getString(actionRequest, "addressPrimary", "0");

    String addressesIndexes = ParamUtil.getString(actionRequest, ADDRESSES_INDEXES);
    String[] indexes = addressesIndexes.split(StringPool.COMMA);

    for (String idx : indexes) {
        EvoAddressModel addressModel = new EvoAddressModel();

        String streetName = ParamUtil.getString(actionRequest, "addressStreet1_" + idx, StringPool.BLANK);
        String streetNo = ParamUtil.getString(actionRequest, "addressStreet2_" + idx, StringPool.BLANK);
        String city = ParamUtil.getString(actionRequest, "addressCity" + idx, StringPool.BLANK);

        if (streetName.isEmpty() && streetNo.isEmpty() && city.isEmpty()) {
            continue;
        }/*  w ww. j ava  2s  . co m*/

        String zip = ParamUtil.getString(actionRequest, "addressZip" + idx);
        long regionId = ParamUtil.getLong(actionRequest, "addressRegionId" + idx, 0L);
        long typeId = ParamUtil.getLong(actionRequest, "addressTypeId" + idx, 0L);
        boolean mailing = ParamUtil.getBoolean(actionRequest, "addressMailing" + idx, false);

        addressModel.setStreetName(streetName);
        addressModel.setStreetNumber(streetNo);
        addressModel.setPostalCode(zip);
        addressModel.setRegion(regionId);
        addressModel.setType(typeId);
        addressModel.setCity(city);
        addressModel.setMailing(mailing);
        addressModel.setPrimary(primaryIndexAddress.equals(idx));

        try {
            int countryId = ParamUtil.getInteger(actionRequest, "addressCountryId" + idx);
            if (countryId != 0) {
                Country country = CountryUtil.fetchByPrimaryKey(countryId);
                addressModel.setCountryCode(country.getA2());
            }
        } catch (SystemException e) {
            logger.error("Error fetching address model from request: " + e.getMessage(), e);
        }
        addresses.add(addressModel);
    }

    return addresses;
}

From source file:com.evozon.evoportal.my_account.util.MyAccountRequestUtil.java

public static DetailsModel getDetailsModelFromRequest(ActionRequest actionRequest) {
    DetailsModel detailsModel = new DetailsModel();

    detailsModel.setScreenName(ParamUtil.get(actionRequest, "screenName", StringPool.BLANK));
    detailsModel.setEmailAddress(ParamUtil.get(actionRequest, "emailAddress", StringPool.BLANK));
    detailsModel.setFirstName(ParamUtil.get(actionRequest, "firstName", StringPool.BLANK));
    detailsModel.setLastName(ParamUtil.get(actionRequest, "lastName", StringPool.BLANK));
    detailsModel.setMale(ParamUtil.getBoolean(actionRequest, "male", Boolean.FALSE));
    detailsModel.setBuilding(ParamUtil.get(actionRequest, "ExpandoAttribute--Building--", StringPool.BLANK));
    detailsModel.setJobTitle(ParamUtil.get(actionRequest, "jobTitle", StringPool.BLANK));
    detailsModel/*  ww  w . j av a  2  s. c  om*/
            .setFunctieCIM(ParamUtil.get(actionRequest, "ExpandoAttribute--Functie CIM--", StringPool.BLANK));
    detailsModel.setCnp(ParamUtil.get(actionRequest, "userCNP", StringPool.BLANK));
    detailsModel.setLicensePlate(
            ParamUtil.get(actionRequest, "ExpandoAttribute--License Plate--", StringPool.BLANK));
    detailsModel.setBirthdayDate(getBirthdayFromRequest(actionRequest));
    detailsModel.setBirthdayHidden(ParamUtil.getBoolean(actionRequest, "hideBirthday", Boolean.FALSE));
    detailsModel.setSkype(ParamUtil.get(actionRequest, "skypeSn", StringPool.BLANK));
    detailsModel.setPhoneNumber(ParamUtil.get(actionRequest, "phoneNumber", StringPool.BLANK));
    detailsModel.setPhoneNumberHidden(ParamUtil.getBoolean(actionRequest, "hidePhones", Boolean.FALSE));
    detailsModel.setMarried(ParamUtil.getBoolean(actionRequest, "ExpandoAttribute--Married--", Boolean.FALSE));
    detailsModel.setStudent(ParamUtil.getBoolean(actionRequest, "isStudent", Boolean.FALSE));
    detailsModel
            .setUniversity(ParamUtil.get(actionRequest, "ExpandoAttribute--University--", StringPool.BLANK));
    detailsModel.setFaculty(ParamUtil.get(actionRequest, "ExpandoAttribute--Faculty--", StringPool.BLANK));
    detailsModel.setDiplomaTitle(
            ParamUtil.get(actionRequest, "ExpandoAttribute--Diploma title (In progress)--", StringPool.BLANK));
    detailsModel.setAdditionalEmailAddress(
            ParamUtil.get(actionRequest, "additionalEmailAddress", StringPool.BLANK));
    detailsModel.setOfficialName(ParamUtil.getString(actionRequest,
            MyAccountConstants.EXPANDO_OFFICIAL_NAME_ATTRIBUTE, StringPool.BLANK));

    return detailsModel;
}

From source file:com.liferay.asset.browser.web.internal.display.context.AssetBrowserDisplayContext.java

License:Open Source License

public Boolean getListable() {
    Boolean listable = null;// www .ja  v a2 s.co m

    String listableValue = ParamUtil.getString(_request, "listable", null);

    if (Validator.isNotNull(listableValue)) {
        listable = ParamUtil.getBoolean(_request, "listable", true);
    }

    return listable;
}

From source file:com.liferay.calendar.search.CalendarResourceDisplayTerms.java

License:Open Source License

public CalendarResourceDisplayTerms(PortletRequest portletRequest) {
    super(portletRequest);

    active = ParamUtil.getBoolean(portletRequest, ACTIVE, true);
    code = ParamUtil.getString(portletRequest, CODE);
    description = ParamUtil.getString(portletRequest, DESCRIPTION);
    name = ParamUtil.getString(portletRequest, NAME);
    scope = ParamUtil.getLong(portletRequest, SCOPE);
}

From source file:com.liferay.calendar.service.impl.CalendarBookingLocalServiceImpl.java

License:Open Source License

protected void sendNotification(CalendarBooking calendarBooking,
        NotificationTemplateType notificationTemplateType, ServiceContext serviceContext) {

    boolean sendNotification = ParamUtil.getBoolean(serviceContext, "sendNotification", true);

    if (!sendNotification) {
        return;/*from w  w w  . java  2 s .c  o m*/
    }

    try {
        NotificationType notificationType = NotificationType
                .parse(PortletPropsValues.CALENDAR_NOTIFICATION_DEFAULT_TYPE);

        NotificationUtil.notifyCalendarBookingRecipients(calendarBooking, notificationType,
                notificationTemplateType);
    } catch (Exception e) {
        if (_log.isWarnEnabled()) {
            _log.warn(e, e);
        }
    }
}

From source file:com.liferay.comment.taglib.internal.struts.EditDiscussionStrutsAction.java

License:Open Source License

@Override
public String execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    AuthTokenUtil.checkCSRFToken(request, EditDiscussionStrutsAction.class.getName());

    String namespace = ParamUtil.getString(request, "namespace");

    HttpServletRequest namespacedRequest = new NamespaceServletRequest(request, StringPool.BLANK, namespace);

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

    try {/* w  ww . j  a v  a2 s . c o  m*/
        String redirect = _portal.escapeRedirect(ParamUtil.getString(request, "redirect"));

        if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
            long commentId = updateComment(namespacedRequest);

            boolean ajax = ParamUtil.getBoolean(request, "ajax", true);

            if (ajax) {
                String randomNamespace = ParamUtil.getString(namespacedRequest, "randomNamespace");

                JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

                jsonObject.put("commentId", commentId);
                jsonObject.put("randomNamespace", randomNamespace);

                writeJSON(namespacedRequest, response, jsonObject);

                return null;
            }
        } else if (cmd.equals(Constants.DELETE)) {
            deleteComment(namespacedRequest);
        } else if (cmd.equals(Constants.SUBSCRIBE_TO_COMMENTS)) {
            subscribeToComments(namespacedRequest, true);
        } else if (cmd.equals(Constants.UNSUBSCRIBE_FROM_COMMENTS)) {
            subscribeToComments(namespacedRequest, false);
        }

        if (Validator.isNotNull(redirect)) {
            response.sendRedirect(redirect);
        }
    } catch (DiscussionMaxCommentsException | MessageBodyException | NoSuchMessageException | PrincipalException
            | RequiredMessageException e) {

        JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

        jsonObject.putException(e);

        writeJSON(namespacedRequest, response, jsonObject);
    }

    return null;
}