Example usage for com.liferay.portal.kernel.bean BeanParamUtil getInteger

List of usage examples for com.liferay.portal.kernel.bean BeanParamUtil getInteger

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.bean BeanParamUtil getInteger.

Prototype

public static int getInteger(Object bean, PortletRequest portletRequest, String param) 

Source Link

Usage

From source file:com.liferay.portlet.usersadmin.action.EditUserAction.java

License:Open Source License

protected Object[] updateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    User user = PortalUtil.getSelectedUser(actionRequest);

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

    if (deleteLogo) {
        UserServiceUtil.deletePortrait(user.getUserId());
    }//from  ww  w.  j  a v  a  2 s .  c  o  m

    Contact contact = user.getContact();

    String oldPassword = AdminUtil.getUpdateUserPassword(actionRequest, user.getUserId());
    String newPassword1 = actionRequest.getParameter("password1");
    String newPassword2 = actionRequest.getParameter("password2");
    boolean passwordReset = ParamUtil.getBoolean(actionRequest, "passwordReset");

    String reminderQueryQuestion = BeanParamUtil.getString(user, actionRequest, "reminderQueryQuestion");

    if (reminderQueryQuestion.equals(UsersAdminUtil.CUSTOM_QUESTION)) {
        reminderQueryQuestion = BeanParamUtil.getString(user, actionRequest, "reminderQueryCustomQuestion");
    }

    String reminderQueryAnswer = BeanParamUtil.getString(user, actionRequest, "reminderQueryAnswer");
    String oldScreenName = user.getScreenName();
    String screenName = BeanParamUtil.getString(user, actionRequest, "screenName");
    String oldEmailAddress = user.getEmailAddress();
    String emailAddress = BeanParamUtil.getString(user, actionRequest, "emailAddress");
    long facebookId = user.getFacebookId();
    String openId = BeanParamUtil.getString(user, actionRequest, "openId");
    String oldLanguageId = user.getLanguageId();
    String languageId = BeanParamUtil.getString(user, actionRequest, "languageId");
    String timeZoneId = BeanParamUtil.getString(user, actionRequest, "timeZoneId");
    String greeting = BeanParamUtil.getString(user, actionRequest, "greeting");
    String firstName = BeanParamUtil.getString(user, actionRequest, "firstName");
    String middleName = BeanParamUtil.getString(user, actionRequest, "middleName");
    String lastName = BeanParamUtil.getString(user, actionRequest, "lastName");
    int prefixId = BeanParamUtil.getInteger(contact, actionRequest, "prefixId");
    int suffixId = BeanParamUtil.getInteger(contact, actionRequest, "suffixId");
    boolean male = BeanParamUtil.getBoolean(user, actionRequest, "male", true);

    Calendar birthdayCal = CalendarFactoryUtil.getCalendar();

    birthdayCal.setTime(contact.getBirthday());

    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth", birthdayCal.get(Calendar.MONTH));
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay", birthdayCal.get(Calendar.DATE));
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear", birthdayCal.get(Calendar.YEAR));
    String comments = BeanParamUtil.getString(user, actionRequest, "comments");
    String smsSn = BeanParamUtil.getString(contact, actionRequest, "smsSn");
    String aimSn = BeanParamUtil.getString(contact, actionRequest, "aimSn");
    String facebookSn = BeanParamUtil.getString(contact, actionRequest, "facebookSn");
    String icqSn = BeanParamUtil.getString(contact, actionRequest, "icqSn");
    String jabberSn = BeanParamUtil.getString(contact, actionRequest, "jabberSn");
    String msnSn = BeanParamUtil.getString(contact, actionRequest, "msnSn");
    String mySpaceSn = BeanParamUtil.getString(contact, actionRequest, "mySpaceSn");
    String skypeSn = BeanParamUtil.getString(contact, actionRequest, "skypeSn");
    String twitterSn = BeanParamUtil.getString(contact, actionRequest, "twitterSn");
    String ymSn = BeanParamUtil.getString(contact, actionRequest, "ymSn");
    String jobTitle = BeanParamUtil.getString(user, actionRequest, "jobTitle");
    long[] groupIds = getLongArray(actionRequest, "groupsSearchContainerPrimaryKeys");
    long[] organizationIds = getLongArray(actionRequest, "organizationsSearchContainerPrimaryKeys");
    long[] roleIds = getLongArray(actionRequest, "rolesSearchContainerPrimaryKeys");

    List<UserGroupRole> userGroupRoles = null;

    if ((actionRequest.getParameter("groupRolesGroupIds") != null)
            || (actionRequest.getParameter("groupRolesRoleIds") != null)) {

        userGroupRoles = UsersAdminUtil.getUserGroupRoles(actionRequest);
    }

    long[] userGroupIds = getLongArray(actionRequest, "userGroupsSearchContainerPrimaryKeys");
    List<Address> addresses = UsersAdminUtil.getAddresses(actionRequest);
    List<EmailAddress> emailAddresses = UsersAdminUtil.getEmailAddresses(actionRequest);
    List<Phone> phones = UsersAdminUtil.getPhones(actionRequest);
    List<Website> websites = UsersAdminUtil.getWebsites(actionRequest);
    List<AnnouncementsDelivery> announcementsDeliveries = getAnnouncementsDeliveries(actionRequest);

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

    user = UserServiceUtil.updateUser(user.getUserId(), oldPassword, newPassword1, newPassword2, passwordReset,
            reminderQueryQuestion, reminderQueryAnswer, screenName, emailAddress, facebookId, openId,
            languageId, timeZoneId, greeting, comments, firstName, middleName, lastName, prefixId, suffixId,
            male, birthdayMonth, birthdayDay, birthdayYear, smsSn, aimSn, facebookSn, icqSn, jabberSn, msnSn,
            mySpaceSn, skypeSn, twitterSn, ymSn, jobTitle, groupIds, organizationIds, roleIds, userGroupRoles,
            userGroupIds, addresses, emailAddresses, phones, websites, announcementsDeliveries, serviceContext);

    if (oldScreenName.equals(user.getScreenName())) {
        oldScreenName = StringPool.BLANK;
    }

    if (user.getUserId() == themeDisplay.getUserId()) {

        // Reset the locale

        HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
        HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse);
        HttpSession session = request.getSession();

        session.removeAttribute(Globals.LOCALE_KEY);

        Locale locale = LocaleUtil.fromLanguageId(languageId);

        LanguageUtil.updateCookie(request, response, locale);

        // Clear cached portlet responses

        PortletSession portletSession = actionRequest.getPortletSession();

        InvokerPortletImpl.clearResponses(portletSession);

        // Password

        if (PropsValues.SESSION_STORE_PASSWORD && Validator.isNotNull(newPassword1)) {

            portletSession.setAttribute(WebKeys.USER_PASSWORD, newPassword1, PortletSession.APPLICATION_SCOPE);
        }
    }

    long publicLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "publicLayoutSetPrototypeId");
    long privateLayoutSetPrototypeId = ParamUtil.getLong(actionRequest, "privateLayoutSetPrototypeId");

    SitesUtil.applyLayoutSetPrototypes(user.getGroup(), publicLayoutSetPrototypeId, privateLayoutSetPrototypeId,
            serviceContext);

    Company company = PortalUtil.getCompany(actionRequest);

    if (company.isStrangersVerify() && !oldEmailAddress.equalsIgnoreCase(emailAddress)) {

        SessionMessages.add(actionRequest, "verificationEmailSent");
    }

    return new Object[] { user, oldScreenName, oldLanguageId };
}

From source file:com.liferay.users.admin.web.internal.portlet.action.EditUserMVCActionCommand.java

License:Open Source License

protected Object[] updateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    User user = portal.getSelectedUser(actionRequest);

    Contact contact = user.getContact();

    String oldPassword = AdminUtil.getUpdateUserPassword(actionRequest, user.getUserId());

    String oldScreenName = user.getScreenName();
    String screenName = BeanParamUtil.getString(user, actionRequest, "screenName");
    String oldEmailAddress = user.getEmailAddress();
    String emailAddress = BeanParamUtil.getString(user, actionRequest, "emailAddress");
    long facebookId = user.getFacebookId();

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

    byte[] portraitBytes = null;

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

    if (fileEntryId > 0) {
        FileEntry fileEntry = _dlAppLocalService.getFileEntry(fileEntryId);

        portraitBytes = FileUtil.getBytes(fileEntry.getContentStream());
    }/*from   w w  w. j av a  2s  . c  om*/

    String languageId = BeanParamUtil.getString(user, actionRequest, "languageId");
    String firstName = BeanParamUtil.getString(user, actionRequest, "firstName");
    String middleName = BeanParamUtil.getString(user, actionRequest, "middleName");
    String lastName = BeanParamUtil.getString(user, actionRequest, "lastName");
    long prefixId = BeanParamUtil.getInteger(contact, actionRequest, "prefixId");
    long suffixId = BeanParamUtil.getInteger(contact, actionRequest, "suffixId");
    boolean male = BeanParamUtil.getBoolean(user, actionRequest, "male", true);

    Calendar birthdayCal = CalendarFactoryUtil.getCalendar();

    birthdayCal.setTime(contact.getBirthday());

    int birthdayMonth = ParamUtil.getInteger(actionRequest, "birthdayMonth", birthdayCal.get(Calendar.MONTH));
    int birthdayDay = ParamUtil.getInteger(actionRequest, "birthdayDay", birthdayCal.get(Calendar.DATE));
    int birthdayYear = ParamUtil.getInteger(actionRequest, "birthdayYear", birthdayCal.get(Calendar.YEAR));

    String comments = BeanParamUtil.getString(user, actionRequest, "comments");
    String jobTitle = BeanParamUtil.getString(user, actionRequest, "jobTitle");

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

    user = _userService.updateUser(user.getUserId(), oldPassword, null, null, user.getPasswordReset(), null,
            null, screenName, emailAddress, facebookId, user.getOpenId(), !deleteLogo, portraitBytes,
            languageId, user.getTimeZoneId(), user.getGreeting(), comments, firstName, middleName, lastName,
            prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, null, null, null, null, null,
            jobTitle, null, null, null, null, null, null, null, null, null, null, serviceContext);

    if (oldScreenName.equals(user.getScreenName())) {
        oldScreenName = StringPool.BLANK;
    }

    boolean updateLanguageId = false;

    if (user.getUserId() == themeDisplay.getUserId()) {

        // Reset the locale

        HttpServletRequest request = portal
                .getOriginalServletRequest(portal.getHttpServletRequest(actionRequest));
        HttpServletResponse response = portal.getHttpServletResponse(actionResponse);
        HttpSession session = request.getSession();

        session.removeAttribute(Globals.LOCALE_KEY);

        Locale locale = LocaleUtil.fromLanguageId(languageId);

        LanguageUtil.updateCookie(request, response, locale);

        // Clear cached portlet responses

        PortletSession portletSession = actionRequest.getPortletSession();

        InvokerPortletImpl.clearResponses(portletSession);

        updateLanguageId = true;
    }

    Company company = portal.getCompany(actionRequest);

    if (company.isStrangersVerify() && !StringUtil.equalsIgnoreCase(oldEmailAddress, emailAddress)) {

        SessionMessages.add(actionRequest, "verificationEmailSent");
    }

    return new Object[] { user, oldScreenName, updateLanguageId };
}