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

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

Introduction

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

Prototype

public static String getString(Object bean, PortletRequest portletRequest, String param) 

Source Link

Usage

From source file:com.liferay.contacts.contactscenter.portlet.ContactsCenterPortlet.java

License:Open Source License

protected void updateProfile(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();//from w w  w  .  j  ava2s.c om

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

    if (deleteLogo) {
        UserServiceUtil.deletePortrait(user.getUserId());
    }

    String comments = BeanParamUtil.getString(user, actionRequest, "comments");
    String emailAddress = BeanParamUtil.getString(user, actionRequest, "emailAddress");
    String firstName = BeanParamUtil.getString(user, actionRequest, "firstName");
    String jobTitle = BeanParamUtil.getString(user, actionRequest, "jobTitle");
    String lastName = BeanParamUtil.getString(user, actionRequest, "lastName");
    String middleName = BeanParamUtil.getString(user, actionRequest, "middleName");
    String screenName = BeanParamUtil.getString(user, actionRequest, "screenName");

    Contact contact = user.getContact();

    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 smsSn = BeanParamUtil.getString(contact, actionRequest, "smsSn");
    String twitterSn = BeanParamUtil.getString(contact, actionRequest, "twitterSn");
    String ymSn = BeanParamUtil.getString(contact, actionRequest, "ymSn");

    Calendar cal = CalendarFactoryUtil.getCalendar();

    cal.setTime(user.getBirthday());

    int birthdayDay = cal.get(Calendar.DATE);
    int birthdayMonth = cal.get(Calendar.MONTH);
    int birthdayYear = cal.get(Calendar.YEAR);

    List<AnnouncementsDelivery> announcementsDeliveries = AnnouncementsDeliveryLocalServiceUtil
            .getUserDeliveries(user.getUserId());

    UserServiceUtil.updateUser(user.getUserId(), user.getPasswordUnencrypted(), user.getPasswordUnencrypted(),
            user.getPasswordUnencrypted(), user.getPasswordReset(), user.getReminderQueryQuestion(),
            user.getReminderQueryAnswer(), screenName, emailAddress, user.getFacebookId(), user.getOpenId(),
            user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(), comments, firstName, middleName,
            lastName, contact.getPrefixId(), contact.getSuffixId(), user.isMale(), birthdayMonth, birthdayDay,
            birthdayYear, smsSn, aimSn, facebookSn, icqSn, jabberSn, msnSn, mySpaceSn, skypeSn, twitterSn, ymSn,
            jobTitle, user.getGroupIds(), user.getOrganizationIds(), user.getRoleIds(), null,
            user.getUserGroupIds(), user.getAddresses(), null, user.getPhones(), user.getWebsites(),
            announcementsDeliveries, new ServiceContext());
}

From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java

License:Open Source License

protected void updateProfile(ActionRequest actionRequest) throws Exception {
    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();//www . ja va2  s  .  com

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

    byte[] portraitBytes = null;

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

    if (!deleteLogo && (fileEntryId > 0)) {
        FileEntry fileEntry = dlAppLocalService.getFileEntry(fileEntryId);

        try (InputStream inputStream = fileEntry.getContentStream()) {
            portraitBytes = FileUtil.getBytes(inputStream);
        }
    }

    String comments = BeanParamUtil.getString(user, actionRequest, "comments");
    String emailAddress = BeanParamUtil.getString(user, actionRequest, "emailAddress");
    String firstName = BeanParamUtil.getString(user, actionRequest, "firstName");
    String jobTitle = BeanParamUtil.getString(user, actionRequest, "jobTitle");
    String lastName = BeanParamUtil.getString(user, actionRequest, "lastName");
    String middleName = BeanParamUtil.getString(user, actionRequest, "middleName");
    String screenName = BeanParamUtil.getString(user, actionRequest, "screenName");

    Contact contact = user.getContact();

    String facebookSn = BeanParamUtil.getString(contact, actionRequest, "facebookSn");
    String jabberSn = BeanParamUtil.getString(contact, actionRequest, "jabberSn");
    String skypeSn = BeanParamUtil.getString(contact, actionRequest, "skypeSn");
    String smsSn = BeanParamUtil.getString(contact, actionRequest, "smsSn");
    String twitterSn = BeanParamUtil.getString(contact, actionRequest, "twitterSn");

    Calendar cal = CalendarFactoryUtil.getCalendar();

    cal.setTime(user.getBirthday());

    int birthdayDay = cal.get(Calendar.DATE);
    int birthdayMonth = cal.get(Calendar.MONTH);
    int birthdayYear = cal.get(Calendar.YEAR);

    List<AnnouncementsDelivery> announcementsDeliveries = announcementsDeliveryLocalService
            .getUserDeliveries(user.getUserId());

    userService.updateUser(user.getUserId(), user.getPasswordUnencrypted(), user.getPasswordUnencrypted(),
            user.getPasswordUnencrypted(), user.getPasswordReset(), user.getReminderQueryQuestion(),
            user.getReminderQueryAnswer(), screenName, emailAddress, user.getFacebookId(), user.getOpenId(),
            !deleteLogo, portraitBytes, user.getLanguageId(), user.getTimeZoneId(), user.getGreeting(),
            comments, firstName, middleName, lastName, contact.getPrefixId(), contact.getSuffixId(),
            user.isMale(), birthdayMonth, birthdayDay, birthdayYear, smsSn, facebookSn, jabberSn, skypeSn,
            twitterSn, jobTitle, user.getGroupIds(), user.getOrganizationIds(), user.getRoleIds(), null,
            user.getUserGroupIds(), user.getAddresses(), null, user.getPhones(), user.getWebsites(),
            announcementsDeliveries, new ServiceContext());
}

From source file:com.liferay.dynamic.data.mapping.data.provider.web.internal.display.context.DDMDataProviderDisplayContext.java

License:Open Source License

public String getDataProviderInstanceDDMFormHTML() throws PortalException {
    DDMDataProviderInstance ddmDataProviderInstance = fetchDataProviderInstance();

    String type = BeanParamUtil.getString(ddmDataProviderInstance, _renderRequest, "type");

    DDMDataProvider ddmDataProvider = _ddmDataProviderTracker.getDDMDataProvider(type);

    Class<?> clazz = ddmDataProvider.getSettings();

    DDMForm ddmForm = DDMFormFactory.create(clazz);

    DDMFormRenderingContext ddmFormRenderingContext = createDDMFormRenderingContext();

    if (_ddmDataProviderInstance != null) {
        DDMFormValues ddmFormValues = _ddmFormValuesJSONDeserializer.deserialize(ddmForm,
                _ddmDataProviderInstance.getDefinition());

        Set<String> passwordDDMFormFieldNames = DDMDataProviderPortletUtil.getDDMFormFieldNamesByType(ddmForm,
                "password");

        obfuscateDDMFormFieldValues(passwordDDMFormFieldNames, ddmFormValues.getDDMFormFieldValues());

        ddmFormRenderingContext.setDDMFormValues(ddmFormValues);
    }//from  w  w w .j a  va 2s  .c o m

    DDMFormLayout ddmFormLayout = DDMFormLayoutFactory.create(clazz);

    ddmFormLayout.setPaginationMode(DDMFormLayout.SINGLE_PAGE_MODE);

    return _ddmFormRenderer.render(ddmForm, ddmFormLayout, ddmFormRenderingContext);
}

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 www. j  ava 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.EditDisplaySettingsMVCActionCommand.java

License:Open Source License

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

    User user = _portal.getSelectedUser(actionRequest);

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

    user.setTimeZoneId(timeZoneId);//from w w w.j  a va  2  s .  c o  m
    user.setGreeting(greeting);

    _userLocalService.updateUser(user);
}

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());
    }/* w  ww.j av a  2s .  c  o m*/

    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 };
}

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

License:Open Source License

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

    try {//from   ww  w.  j  ava 2s .  com
        User user = _portal.getSelectedUser(actionRequest);

        String newPassword1 = actionRequest.getParameter("password1");
        String newPassword2 = actionRequest.getParameter("password2");

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

        PasswordPolicy passwordPolicy = user.getPasswordPolicy();

        if ((user.getLastLoginDate() == null) && ((passwordPolicy == null)
                || (passwordPolicy.isChangeable() && passwordPolicy.isChangeRequired()))) {

            passwordReset = true;
        }

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

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

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

        if (Validator.isNotNull(newPassword1) || Validator.isNotNull(newPassword2)) {

            _userLocalService.updatePassword(user.getUserId(), newPassword1, newPassword2, passwordReset);
        }

        _userLocalService.updatePasswordReset(user.getUserId(), passwordReset);

        if (Validator.isNotNull(reminderQueryQuestion) && Validator.isNotNull(reminderQueryAnswer)) {

            _userLocalService.updateReminderQuery(user.getUserId(), reminderQueryQuestion, reminderQueryAnswer);
        }

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

        if ((user.getUserId() == themeDisplay.getUserId()) && PropsValues.SESSION_STORE_PASSWORD
                && Validator.isNotNull(newPassword1)) {

            PortletSession portletSession = actionRequest.getPortletSession();

            portletSession.setAttribute(WebKeys.USER_PASSWORD, newPassword1, PortletSession.APPLICATION_SCOPE);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchUserException || e instanceof PrincipalException) {

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

            actionResponse.setRenderParameter("mvcPath", "/error.jsp");
        } else if (e instanceof UserPasswordException) {
            SessionErrors.add(actionRequest, e.getClass(), e);

            String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect"));

            if (Validator.isNotNull(redirect)) {
                sendRedirect(actionRequest, actionResponse, redirect);
            }
        } else {
            throw e;
        }
    }
}