Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Manuel de la Peña
Automatic user creation (batch proccess)
April 1, 2011 2:57 AM
Answer

Manuel de la Peña

Rank: Regular Member

Posts: 116

Join Date: December 4, 2008

Recent Posts

Hello, i'm trying to create users to Liferay, with a nightly batch proccess.

My question: is it necessary to get the PortletRequest to add user?

User com.liferay.portal.service.UserLocalServiceUtil.addUser(long creatorUserId, long companyId, boolean autoPassword, String password1, String password2, boolean autoScreenName, String screenName, String emailAddress, String openId, Locale locale, String firstName, String middleName, String lastName, int prefixId, int suffixId, boolean male, int birthdayMonth, int birthdayDay, int birthdayYear, String jobTitle, long[] groupIds, long[] organizationIds, long[] roleIds, long[] userGroupIds, boolean sendEmail, ServiceContext serviceContext) throws PortalException, SystemException

I get the ServiceContext serviceContext from PortletRequest:
1ServiceContextFactory.getInstance(UserLocalServiceUtil.class.getName(),portletRequest)

Is there any other way to get ServiceContext?

Many thanks!
Manish Kumar Gupta
RE: Automatic user creation (batch proccess)
April 1, 2011 3:38 AM
Answer

Manish Kumar Gupta

LIFERAY STAFF

Rank: Liferay Master

Posts: 535

Join Date: May 15, 2008

Recent Posts

ServiceContext serviceContext = new ServiceContext();

serviceContext.setScopeGroupId(groupId);
Manuel de la Peña
RE: Automatic user creation (batch proccess)
April 1, 2011 4:02 AM
Answer

Manuel de la Peña

Rank: Regular Member

Posts: 116

Join Date: December 4, 2008

Recent Posts

Many thanks Manish, i'll try and post my progress!

Byes!
Hitoshi Ozawa
RE: Automatic user creation (batch proccess)
April 1, 2011 4:54 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

I've attached a sample web service batch program in the following page with source.
This is just a sample. We actually modified it for our own needs.

http://www.liferay.com/community/wiki/-/wiki/Main/Web+Service+samples
Manuel de la Peña
RE: Automatic user creation (batch proccess)
April 1, 2011 6:00 AM
Answer

Manuel de la Peña

Rank: Regular Member

Posts: 116

Join Date: December 4, 2008

Recent Posts

Manish Kumar Gupta:
ServiceContext serviceContext = new ServiceContext();

serviceContext.setScopeGroupId(groupId);


It works!!!

Many thanks manish!
Kirk Stork
RE: Automatic user creation (batch proccess)
March 14, 2013 10:59 AM
Answer

Kirk Stork

Rank: Junior Member

Posts: 29

Join Date: May 19, 2010

Recent Posts

Here's another approach.

AddLiferayUsers.groovy

Quick and dirty, but handy when doing development.