List of usage examples for com.liferay.portal.kernel.service UserLocalServiceUtil addUser
public static com.liferay.portal.kernel.model.User addUser(long creatorUserId, 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:it.sysdata.base.service.impl.UserHelperLocalServiceImpl.java
License:Open Source License
public User addUserEmail(String emailAddress, String password, String firstName, String lastName, ServiceContext serviceContext) throws PortalException, SystemException { HttpServletRequest httpServletRequest = serviceContext.getRequest(); Locale locale = PortalUtil.getLocale(httpServletRequest); String userAgent = httpServletRequest.getHeader("User-Agent"); _validateUser(emailAddress, password, serviceContext); long companyId = serviceContext.getCompanyId(); long[] groupIds = new long[1]; long[] roleIds = null; long[] userGroupIds = null; long[] organizationIds = null; if (Validator.isNotNull(PortletPropsValues.API_NEWUSER_USERGROUP_MEMBER)) { UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(companyId, PortletPropsValues.API_NEWUSER_USERGROUP_MEMBER); userGroupIds = new long[] { userGroup.getUserGroupId() }; }//from w w w .ja v a 2s.co m if (Validator.isNotNull(PortletPropsValues.API_NEWUSER_GROUPNAME_MEMBER)) { Group group = GroupLocalServiceUtil.getGroup(companyId, PortletPropsValues.API_NEWUSER_GROUPNAME_MEMBER); if (group.getGroupId() > 0) { groupIds[0] = group.getGroupId(); } else { groupIds = null; } } // Role role = RoleLocalServiceUtil.getRole(companyId, "roleName"); // if (role.getRoleId() > 0) { // roleIds[0] = role.getRoleId(); // } // else { // roleIds = null; // } User user = UserLocalServiceUtil.addUser(0, companyId, false, password, password, true, null, emailAddress, 0, null, locale, firstName, null, lastName, 0, 0, true, 1, 1, 1970, null, groupIds, organizationIds, roleIds, userGroupIds, PortletPropsValues.API_NEWUSER_SENDEMAIL, serviceContext); _log.info( String.format("addUserEmail %s, %s, %s > %s", emailAddress, password, userAgent, user.getUserId())); return user; }