List of usage examples for com.liferay.portal.kernel.service UserServiceUtil addUser
public static com.liferay.portal.kernel.model.User addUser(long companyId, boolean autoPassword, String password1, String password2, boolean autoScreenName, String screenName, String emailAddress, long facebookId, String openId, java.util.Locale locale, String firstName, String middleName, String lastName, long prefixId, long suffixId, boolean male, int birthdayMonth, int birthdayDay, int birthdayYear, String jobTitle, long[] groupIds, long[] organizationIds, long[] roleIds, long[] userGroupIds, boolean sendEmail, ServiceContext serviceContext) throws com.liferay.portal.kernel.exception.PortalException
From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java
License:Open Source License
protected User addUser(ActionRequest actionRequest, ActionResponse actionResponse, String password) throws SystemException, PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); boolean autoPassword = false; String password1 = null;/*from w ww. j av a2 s .com*/ String password2 = null; boolean autoScreenName = !authType.equals(CompanyConstants.AUTH_TYPE_SN); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = 0; String openId = StringPool.BLANK; String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = StringPool.BLANK; String lastName = ParamUtil.getString(actionRequest, "lastName"); int prefixId = 0; int suffixId = 0; boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = 1; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = StringPool.BLANK; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); password1 = password; password2 = password; User user = UserServiceUtil.addUser(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); long userId = user.getUserId(); user = UserLocalServiceUtil.updatePasswordReset(userId, false); PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(userId); passwordPolicy.setChangeRequired(false); PasswordPolicyLocalServiceUtil.updatePasswordPolicy(passwordPolicy); if (_USERS_REMINDER_QUERIES_ENABLED) { user = UserLocalServiceUtil.updateReminderQuery(userId, StringPool.DASH, UUID.randomUUID().toString()); } user = UserLocalServiceUtil.updateAgreedToTermsOfUse(userId, true); return user; }