protected void updateLDAPUser(User ldapUser, Contact ldapContact, User user) throws PortalException, SystemException { Contact contact = user.getContact(); ldapContact.setAimSn(GetterUtil.getString(contact.getAimSn())); ldapContact.setFacebookSn(GetterUtil.getString(contact.getFacebookSn())); ldapContact.setIcqSn(GetterUtil.getString(contact.getIcqSn())); ldapContact.setJabberSn(GetterUtil.getString(contact.getJabberSn())); ldapContact.setMale(GetterUtil.getBoolean(contact.getMale())); ldapContact.setMsnSn(GetterUtil.getString(contact.getMsnSn())); ldapContact.setMySpaceSn(GetterUtil.getString(contact.getMySpaceSn())); ldapContact.setPrefixId(GetterUtil.getInteger(contact.getPrefixId())); ldapContact.setSkypeSn(GetterUtil.getString(contact.getSkypeSn())); ldapContact.setSmsSn(GetterUtil.getString(contact.getSmsSn())); ldapContact.setSuffixId(GetterUtil.getInteger(contact.getSuffixId())); ldapContact.setTwitterSn(GetterUtil.getString(contact.getTwitterSn())); ldapContact.setYmSn(GetterUtil.getString(contact.getYmSn())); ldapUser.setComments(GetterUtil.getString(user.getComments())); ldapUser.setGreeting(GetterUtil.getString(user.getGreeting())); ldapUser.setJobTitle(GetterUtil.getString(user.getJobTitle())); ldapUser.setLanguageId(GetterUtil.getString(user.getLanguageId())); ldapUser.setMiddleName(GetterUtil.getString(user.getMiddleName())); ldapUser.setOpenId(GetterUtil.getString(user.getOpenId())); ldapUser.setTimeZoneId(GetterUtil.getString(user.getTimeZoneId())); }
protected User addUser() throws Exception { long pk = nextLong(); User user = _persistence.create(pk); user.setUuid(randomString()); user.setCompanyId(nextLong()); user.setCreateDate(nextDate()); user.setModifiedDate(nextDate()); user.setDefaultUser(randomBoolean()); user.setContactId(nextLong()); user.setPassword(randomString()); user.setPasswordEncrypted(randomBoolean()); user.setPasswordReset(randomBoolean()); user.setPasswordModifiedDate(nextDate()); user.setDigest(randomString()); user.setReminderQueryQuestion(randomString()); user.setReminderQueryAnswer(randomString()); user.setGraceLoginCount(nextInt()); user.setScreenName(randomString()); user.setEmailAddress(randomString()); user.setFacebookId(nextLong()); user.setOpenId(randomString()); user.setPortraitId(nextLong()); user.setLanguageId(randomString()); user.setTimeZoneId(randomString()); user.setGreeting(randomString()); user.setComments(randomString()); user.setFirstName(randomString()); user.setMiddleName(randomString()); user.setLastName(randomString()); user.setJobTitle(randomString()); user.setLoginDate(nextDate()); user.setLoginIP(randomString()); user.setLastLoginDate(nextDate()); user.setLastLoginIP(randomString()); user.setLastFailedLoginDate(nextDate()); user.setFailedLoginAttempts(nextInt()); user.setLockout(randomBoolean()); user.setLockoutDate(nextDate()); user.setAgreedToTermsOfUse(randomBoolean()); user.setStatus(nextInt()); _persistence.update(user, false); return user; }
/** * Converts the soap model instance into a normal model instance. * * @param soapModel the soap model instance to convert * @return the normal model instance */ public static User toModel(UserSoap soapModel) { User model = new UserImpl(); model.setUuid(soapModel.getUuid()); model.setUserId(soapModel.getUserId()); model.setCompanyId(soapModel.getCompanyId()); model.setCreateDate(soapModel.getCreateDate()); model.setModifiedDate(soapModel.getModifiedDate()); model.setDefaultUser(soapModel.getDefaultUser()); model.setContactId(soapModel.getContactId()); model.setPassword(soapModel.getPassword()); model.setPasswordEncrypted(soapModel.getPasswordEncrypted()); model.setPasswordReset(soapModel.getPasswordReset()); model.setPasswordModifiedDate(soapModel.getPasswordModifiedDate()); model.setDigest(soapModel.getDigest()); model.setReminderQueryQuestion(soapModel.getReminderQueryQuestion()); model.setReminderQueryAnswer(soapModel.getReminderQueryAnswer()); model.setGraceLoginCount(soapModel.getGraceLoginCount()); model.setScreenName(soapModel.getScreenName()); model.setEmailAddress(soapModel.getEmailAddress()); model.setFacebookId(soapModel.getFacebookId()); model.setOpenId(soapModel.getOpenId()); model.setPortraitId(soapModel.getPortraitId()); model.setLanguageId(soapModel.getLanguageId()); model.setTimeZoneId(soapModel.getTimeZoneId()); model.setGreeting(soapModel.getGreeting()); model.setComments(soapModel.getComments()); model.setFirstName(soapModel.getFirstName()); model.setMiddleName(soapModel.getMiddleName()); model.setLastName(soapModel.getLastName()); model.setJobTitle(soapModel.getJobTitle()); model.setLoginDate(soapModel.getLoginDate()); model.setLoginIP(soapModel.getLoginIP()); model.setLastLoginDate(soapModel.getLastLoginDate()); model.setLastLoginIP(soapModel.getLastLoginIP()); model.setLastFailedLoginDate(soapModel.getLastFailedLoginDate()); model.setFailedLoginAttempts(soapModel.getFailedLoginAttempts()); model.setLockout(soapModel.getLockout()); model.setLockoutDate(soapModel.getLockoutDate()); model.setAgreedToTermsOfUse(soapModel.getAgreedToTermsOfUse()); model.setEmailAddressVerified(soapModel.getEmailAddressVerified()); model.setStatus(soapModel.getStatus()); return model; }
public void testUpdateExisting() throws Exception { long pk = nextLong(); User newUser = _persistence.create(pk); newUser.setUuid(randomString()); newUser.setCompanyId(nextLong()); newUser.setCreateDate(nextDate()); newUser.setModifiedDate(nextDate()); newUser.setDefaultUser(randomBoolean()); newUser.setContactId(nextLong()); newUser.setPassword(randomString()); newUser.setPasswordEncrypted(randomBoolean()); newUser.setPasswordReset(randomBoolean()); newUser.setPasswordModifiedDate(nextDate()); newUser.setDigest(randomString()); newUser.setReminderQueryQuestion(randomString()); newUser.setReminderQueryAnswer(randomString()); newUser.setGraceLoginCount(nextInt()); newUser.setScreenName(randomString()); newUser.setEmailAddress(randomString()); newUser.setFacebookId(nextLong()); newUser.setOpenId(randomString()); newUser.setPortraitId(nextLong()); newUser.setLanguageId(randomString()); newUser.setTimeZoneId(randomString()); newUser.setGreeting(randomString()); newUser.setComments(randomString()); newUser.setFirstName(randomString()); newUser.setMiddleName(randomString()); newUser.setLastName(randomString()); newUser.setJobTitle(randomString()); newUser.setLoginDate(nextDate()); newUser.setLoginIP(randomString()); newUser.setLastLoginDate(nextDate()); newUser.setLastLoginIP(randomString()); newUser.setLastFailedLoginDate(nextDate()); newUser.setFailedLoginAttempts(nextInt()); newUser.setLockout(randomBoolean()); newUser.setLockoutDate(nextDate()); newUser.setAgreedToTermsOfUse(randomBoolean()); newUser.setStatus(nextInt()); _persistence.update(newUser, false); User existingUser = _persistence.findByPrimaryKey(newUser.getPrimaryKey()); assertEquals(existingUser.getUuid(), newUser.getUuid()); assertEquals(existingUser.getUserId(), newUser.getUserId()); assertEquals(existingUser.getCompanyId(), newUser.getCompanyId()); assertEquals( Time.getShortTimestamp(existingUser.getCreateDate()), Time.getShortTimestamp(newUser.getCreateDate())); assertEquals( Time.getShortTimestamp(existingUser.getModifiedDate()), Time.getShortTimestamp(newUser.getModifiedDate())); assertEquals(existingUser.getDefaultUser(), newUser.getDefaultUser()); assertEquals(existingUser.getContactId(), newUser.getContactId()); assertEquals(existingUser.getPassword(), newUser.getPassword()); assertEquals(existingUser.getPasswordEncrypted(), newUser.getPasswordEncrypted()); assertEquals(existingUser.getPasswordReset(), newUser.getPasswordReset()); assertEquals( Time.getShortTimestamp(existingUser.getPasswordModifiedDate()), Time.getShortTimestamp(newUser.getPasswordModifiedDate())); assertEquals(existingUser.getDigest(), newUser.getDigest()); assertEquals(existingUser.getReminderQueryQuestion(), newUser.getReminderQueryQuestion()); assertEquals(existingUser.getReminderQueryAnswer(), newUser.getReminderQueryAnswer()); assertEquals(existingUser.getGraceLoginCount(), newUser.getGraceLoginCount()); assertEquals(existingUser.getScreenName(), newUser.getScreenName()); assertEquals(existingUser.getEmailAddress(), newUser.getEmailAddress()); assertEquals(existingUser.getFacebookId(), newUser.getFacebookId()); assertEquals(existingUser.getOpenId(), newUser.getOpenId()); assertEquals(existingUser.getPortraitId(), newUser.getPortraitId()); assertEquals(existingUser.getLanguageId(), newUser.getLanguageId()); assertEquals(existingUser.getTimeZoneId(), newUser.getTimeZoneId()); assertEquals(existingUser.getGreeting(), newUser.getGreeting()); assertEquals(existingUser.getComments(), newUser.getComments()); assertEquals(existingUser.getFirstName(), newUser.getFirstName()); assertEquals(existingUser.getMiddleName(), newUser.getMiddleName()); assertEquals(existingUser.getLastName(), newUser.getLastName()); assertEquals(existingUser.getJobTitle(), newUser.getJobTitle()); assertEquals( Time.getShortTimestamp(existingUser.getLoginDate()), Time.getShortTimestamp(newUser.getLoginDate())); assertEquals(existingUser.getLoginIP(), newUser.getLoginIP()); assertEquals( Time.getShortTimestamp(existingUser.getLastLoginDate()), Time.getShortTimestamp(newUser.getLastLoginDate())); assertEquals(existingUser.getLastLoginIP(), newUser.getLastLoginIP()); assertEquals( Time.getShortTimestamp(existingUser.getLastFailedLoginDate()), Time.getShortTimestamp(newUser.getLastFailedLoginDate())); assertEquals(existingUser.getFailedLoginAttempts(), newUser.getFailedLoginAttempts()); assertEquals(existingUser.getLockout(), newUser.getLockout()); assertEquals( Time.getShortTimestamp(existingUser.getLockoutDate()), Time.getShortTimestamp(newUser.getLockoutDate())); assertEquals(existingUser.getAgreedToTermsOfUse(), newUser.getAgreedToTermsOfUse()); assertEquals(existingUser.getStatus(), newUser.getStatus()); }
private void insertOldUser(long companyId, long creatorUserId, String line) { String parts[] = line.split(StringPool.COMMA); boolean autoPassword = false; String password = parts[2]; boolean autoScreenName = true; String screenName = StringPool.BLANK; String emailAddress = parts[1]; long facebookId = 0l; String openId = StringPool.BLANK; String firstName = parts[3]; String middleName = StringPool.BLANK; String lastName = StringPool.BLANK; int prefixId = 0; int suffixId = 0; boolean male = parts[6].equalsIgnoreCase("1"); int birthdayMonth = 1; int birthdayDay = 1; int birthdayYear = 2000; String jobTitle = StringPool.BLANK; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = false; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy hh:mm"); try { User user = UserLocalServiceUtil.addUser( creatorUserId, companyId, autoPassword, password, password, autoScreenName, screenName, emailAddress, facebookId, openId, Locale.US, firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); String createDate = parts[0]; if (Validator.isNotNull(createDate)) { try { user.setCreateDate(dateFormat.parse(createDate)); } catch (ParseException e) { e.printStackTrace(); } } String lastLoginDate = parts[5]; if (Validator.isNotNull(lastLoginDate)) { try { user.setLastLoginDate(dateFormat.parse(lastLoginDate)); } catch (ParseException e) { e.printStackTrace(); } } user.setLastName(parts[2]); user.setPasswordReset(false); user.setOpenId("no-invitation-check"); user.setJobTitle("mail-not-sent"); user = UserLocalServiceUtil.updateUser(user); _log.debug("User successfully created ==> " + user); String mobile = parts[4]; if (Validator.isNotNull(mobile) && mobile.startsWith("091")) { String[] tokens = mobile.split(StringPool.DASH); if (tokens.length == 2 && tokens[1].length() == 10) { BridgeLocalServiceUtil.addPhone( user.getUserId(), User.class.getName(), user.getUserId(), tokens[1], "91", true); } } } catch (PortalException e) { _log.error(e.getMessage()); } catch (SystemException e) { _log.error(e.getMessage()); } }