Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. import com.liferay.portal.kernel.util.StringPool;
  2. import com.liferay.portal.model.User;
  3. import com.liferay.portal.service.ServiceContext;
  4. import com.liferay.portal.service.UserLocalServiceUtil;
  5. import com.liferay.portal.util.PortalInstances;
  6.  
  7. int startUserId = 100;
  8. int maxUserCount = 400;
  9.  
  10. User user = null;
  11. ServiceContext serviceContext = new ServiceContext();
  12.  
  13. long creatorUserId = 0;
  14. long companyId = PortalInstances.getDefaultCompanyId();
  15.  
  16. boolean autoPassword = false;
  17. String password1 = "perf";
  18. String password2 = "perf";
  19. boolean autoScreenName = false;
  20. String screenName = "perf";
  21. String emailAddress = "perf@liferay.com";
  22. long facebookId = 0;
  23. String openId = com.liferay.portal.kernel.util.StringPool.BLANK;
  24. Locale locale = Locale.US;
  25. String firstName = "PERF";
  26. String middleName = com.liferay.portal.kernel.util.StringPool.BLANK;
  27. String lastName = "USER";
  28. int prefixId = 0;
  29. int suffixId = 0;
  30. boolean male = true;
  31. int birthdayMonth = Calendar.JANUARY;
  32. int birthdayDay = 1;
  33. int birthdayYear = 1970;
  34. String jobTitle = StringPool.BLANK;
  35. long[] groupIds = null;
  36. long[] organizationIds = null;
  37. long[] roleIds = null;
  38. long[] userGroupIds = null;
  39. boolean sendEmail = false;
  40.  
  41. for (int ui = startUserId; ui < startUserId + maxUserCount; ++ui) {
  42. screenName = "perf"+ui;
  43. try { user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName); } catch (Exception e) {user = null;}
  44. if (user == null) {
  45. emailAddress = screenName + "@liferay.com";
  46. try {
  47. user = UserLocalServiceUtil.addUser(
  48. creatorUserId, companyId, autoPassword, password1, password2,
  49. autoScreenName, screenName, emailAddress, facebookId, openId,
  50. locale, firstName, middleName, lastName, prefixId, suffixId, male,
  51. birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds,
  52. organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);
  53. } catch(Exception e) {}
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement