Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
To import users in Liferay Ketkee A October 12, 2011 3:33 AM
RE: To import users in Liferay Sandeep Nair October 12, 2011 3:38 AM
RE: To import users in Liferay Ketkee A October 18, 2011 3:17 AM
RE: To import users in Liferay Ravi Kumar Gupta October 18, 2011 3:32 AM
RE: To import users in Liferay Hitoshi Ozawa October 18, 2011 4:53 AM
RE: To import users in Liferay Ketkee A October 20, 2011 3:16 AM
RE: To import users in Liferay Ketkee A October 20, 2011 11:13 PM
RE: To import users in Liferay Nisarg Parikh October 20, 2011 11:31 PM
RE: To import users in Liferay Hitoshi Ozawa October 21, 2011 5:47 AM
RE: To import users in Liferay Ketkee A October 24, 2011 4:18 AM
RE: To import users in Liferay Hitoshi Ozawa October 24, 2011 4:43 AM
RE: To import users in Liferay Ketkee A October 24, 2011 5:25 AM
RE: To import users in Liferay Hitoshi Ozawa October 24, 2011 2:22 PM
RE: To import users in Liferay Ketkee A October 24, 2011 8:17 PM
RE: To import users in Liferay Francois Fournel October 25, 2011 3:18 AM
RE: To import users in Liferay Hitoshi Ozawa October 25, 2011 4:21 AM
RE: To import users in Liferay sandeep tripathi May 30, 2012 1:45 AM
RE: To import users in Liferay Nagendra Kumar Busam May 30, 2012 3:03 AM
RE: To import users in Liferay Hitoshi Ozawa May 30, 2012 3:50 PM
RE: To import users in Liferay sandeep tripathi May 31, 2012 10:23 PM
RE: To import users in Liferay sandeep tripathi June 1, 2012 3:52 AM
RE: To import users in Liferay Hitoshi Ozawa June 1, 2012 6:10 AM
RE: To import users in Liferay sandeep tripathi June 4, 2012 11:24 PM
RE: To import users in Liferay sandeep tripathi June 6, 2012 2:58 AM
RE: To import users in Liferay sandeep tripathi June 8, 2012 5:17 AM
RE: To import users in Liferay Elijah "Ellie" Mangason August 2, 2012 1:40 PM
RE: To import users in Liferay Hitoshi Ozawa August 2, 2012 2:53 PM
RE: To import users in Liferay lou cat July 11, 2013 7:18 AM
Ketkee A
To import users in Liferay
October 12, 2011 3:33 AM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

Hi,

I want to import a users in bulk in Liferay database.

when I searched, found links which asks me to import users via LDAP.

but now, I have my users in an Excel sheet. Could you please let me know if there is an API in Liferay which will allow me to pick those users from excel sheet and save in liferay database?
Sandeep Nair
RE: To import users in Liferay
October 12, 2011 3:38 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1721

Join Date: November 5, 2008

Recent Posts

There is no API available. But you can do it via coding. You just have to create a small portlet which reads rows of sheet in which details are there and insert using Liferay's API. The API method is UserLocalServiceUtil.addUser(

For reading the excel sheet you can make use of POI or JExcel.

Regards,
Sandeep
Ketkee A
RE: To import users in Liferay
October 18, 2011 3:17 AM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

Sorry for late reply.

Thank you Sandeep for your reply.

I have to ask here, that if the Excel is huge, will there be a performance issue reading it? I have used JExcel for the moment. But the excel as I get is huge. So just wanted to know about the performance by JExcel.

Please reply.

Thanks.
--Ketkee
Ravi Kumar Gupta
RE: To import users in Liferay
October 18, 2011 3:32 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1298

Join Date: June 23, 2009

Recent Posts

I guess loading the users will be one time job so performance issue may not that big.. If you think that while loading into liferay is also time and performance critical.. then break the excel using jExcel or POI and then load those small files.. in that it should not be consuming much memory and processor.

HTH
Hitoshi Ozawa
RE: To import users in Liferay
October 18, 2011 4:53 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I've made a sample code to upload csv file using web service. This is just a sample code and written to make it easier to read.
I really don't recommend it for production.
http://www.liferay.com/community/wiki/-/wiki/Main/Web+Service+samples

I've only recently developed a portlet to add, delete, modify, and export user data to csv. I'm using supercsv as in the above example.
Ketkee A
RE: To import users in Liferay
October 20, 2011 3:16 AM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

I would like to know which API to use for inserting user.

I see two methods:

UserLocalServiceUtil.addUser() -- takes in individual parameters, a very long list
UserLocalServiceUtil.addUser() -- takes in User object

The data that I obtained from Excel sheet is only ScreenName, LastName, FirstName, Email Address, PWD and Organization. So going by the first method, rest all fields will be empty. is it okay to insert a user with so many fields empty?

Also, along with the user_ table, what all other tables need to be updated?

Please let me know.
Ketkee A
RE: To import users in Liferay
October 20, 2011 11:13 PM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

Could anybody please guide me for the specific API to be used for inserting users into Liferay?

Need to know all tables which may be affected and which require entried to be done apart from user_ table.

Please reply soon.

Thanks.
Nisarg Parikh
RE: To import users in Liferay
October 20, 2011 11:31 PM
Answer

Nisarg Parikh

Rank: Expert

Posts: 262

Join Date: December 30, 2009

Recent Posts

Hi Ketkee,

I have used Hitoshi's Web Service API for importing users. It works fine. I have modified it for multiple users.
If you use this API then you don't have to worry about the other tables as Liferay API will take care of it.

Hope that might help you.

-Nisarg
Hitoshi Ozawa
RE: To import users in Liferay
October 21, 2011 5:47 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I've developed a portlet version and will make it public if my company will permit it. Unfortunately, I haven't internationalized it yet.
I've made the mapping of csv file fields to User class variable into a separate class to make it easier to change the mappings.

The local user method actually modifies several database tables including contact and user roles and user organizations, etc.
You really don't need to specify every fields to add an user.
Ketkee A
RE: To import users in Liferay
October 24, 2011 4:18 AM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

People,

Could you please tell me what defines the uniqueness of a Liferay User? I mean which attribute?

is there a single attribute which is unique for the User or multiple attributes?

I was using Liferay API search method to find if a user exists, and put andsearch as true. Please advise on this.

Thanks.
--Ketkee
Hitoshi Ozawa
RE: To import users in Liferay
October 24, 2011 4:43 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

If you look at the database table users_ or at service.xml file, you can find which fields are unique.
Off the top of my head, userId, screen name and email address are unique.
Ketkee A
RE: To import users in Liferay
October 24, 2011 5:25 AM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

Does that mean that EITHER "Screen Name" OR "Email address" can be picked up to identify teh user as unique?

or both of them as a combination is unique?

--Ketkee
Hitoshi Ozawa
RE: To import users in Liferay
October 24, 2011 2:22 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Have you looked at the methods in UserLocalServiceUtil?
Check if a method is returning a User object or a List. It seems it's companyId + screenName that's unique.
(companyId can be thought of as Liferay instance.)

e.g.
public static com.liferay.portal.model.User getUserByContactId(
long contactId)

public static com.liferay.portal.model.User getUserByEmailAddress(
long companyId, java.lang.String emailAddress)

public static com.liferay.portal.model.User getUserByFacebookId(
long companyId, long facebookId)

public static com.liferay.portal.model.User getUserById(long companyId,
long userId)

public static com.liferay.portal.model.User getUserByScreenName(
long companyId, java.lang.String screenName)
Ketkee A
RE: To import users in Liferay
October 24, 2011 8:17 PM
Answer

Ketkee A

Rank: Junior Member

Posts: 78

Join Date: March 10, 2011

Recent Posts

Hitoshi,

Thank you for your reply.

I checked the methods of UserLocalServiceUtil class and I was looking for searchcount and search methods. These methods return and int count (count of users) and an User object respectively.

The methods are:
UserLocalServiceUtil.search(companyId, firstName, middleName, lastName, screenName, emailAddress, active, params, andSearch, start, end, sort)

UserLocalServiceUtil.searchCount(companyId, firstName, middleName, lastName, screenName, emailAddress, active, params, andSearch)

I thought that the search or the searchCount methods would give me results which would help me identify whether the user I am going to insert exists already in Liferay database or not.

But as mentioned by you, would getUserBy* methods be more appropriate?

Please let me know.

Thanks.
--Ketkee
Francois Fournel
RE: To import users in Liferay
October 25, 2011 3:18 AM
Answer

Francois Fournel

Rank: Junior Member

Posts: 99

Join Date: April 15, 2010

Recent Posts

Have a look at the sample code By Manish Kumar Gupta here :

http://www.liferay.com/community/forums/-/message_boards/message/2625709
Hitoshi Ozawa
RE: To import users in Liferay
October 25, 2011 4:21 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I'm assuming most of the users in the csv files do not already exist in the database, so I'm just doing an add
and catching and looking for duplicate errors. On duplicates, I'm just doing an update.
sandeep tripathi
RE: To import users in Liferay
May 30, 2012 1:45 AM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

Hi Hitoshi ,

i had try to import user in liferay using the liferay-wstools_20110119 that u had shared , i was able to create organisation ,but was not able to create user in liferay i had modified the code of importing user but it give a error unauthorized and user is not created.

i had attach by code which i had modify .
Attachments: UserInfo.java (7.3k), UsersImport.java (3.9k), users1.csv (0.3k)
Nagendra Kumar Busam
RE: To import users in Liferay
May 30, 2012 3:03 AM
Answer

Nagendra Kumar Busam

Rank: Liferay Master

Posts: 653

Join Date: July 7, 2009

Recent Posts

what is the liferay version you are using? Might be method signature might have changed - check it out
Hitoshi Ozawa
RE: To import users in Liferay
May 30, 2012 3:50 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

If you're using with Liferay 6.1.0, please get the latest version:liferay-wstools_6.1.0GA1_20120523.zip


http://www.liferay.com/community/wiki?p_p_id=36&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_36_struts_action=%2Fwiki%2Fview_page_attachments&p_r_p_185834411_nodeName=Main&p_r_p_185834411_title=Web+Service+samples
sandeep tripathi
RE: To import users in Liferay
May 31, 2012 10:23 PM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

Hi

sorry for the late reply i am using Liferay Community Edition 6.0.5 CE
sandeep tripathi
RE: To import users in Liferay
June 1, 2012 3:52 AM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

hi
unauthorized error is solved the ws-setting was wrong i corrected it now there is not data format issue ,
now i am getting java.rmi.RemoteException when i use adduser method signature as

UserSoap usoap= soap.addUser(userInfo.getCompanyId(), userInfo.getAutoPassword(),userInfo.getPassword(),userInfo.getPassword(), userInfo.getAutoScreenName(), userInfo.getScreenName(),userInfo.getEmailAddress(),userInfo.getFacebookId(),userInfo.getOpenId(),userInfo.getLocale(),userInfo.getFirstName(),userInfo.getMiddleName(),userInfo.getLastName(),userInfo.getPrefixId(),userInfo.getSuffixId(),userInfo.getMale(),userInfo.getBirthdayMonth(),userInfo.getBirthdayDay(),userInfo.getBirthdayYear(), userInfo.getJobTitle(),userInfo.getGroupIds(),userInfo.getOrganizationIds(),userInfo.getRoleIds(),userInfo.getUserGroupIds(),userInfo.getSendEmail(),null,null,null,null,null,serviceContext);

and get java.rmi.RemoteException could not exceute jdbc batch update when i use adduser method signature as


UserSoap usoap= soap.addUser(userInfo.getCompanyId(), userInfo.getAutoPassword(),userInfo.getPassword(),userInfo.getPassword(), userInfo.getAutoScreenName(), userInfo.getScreenName(),userInfo.getEmailAddress(),userInfo.getFacebookId(),userInfo.getOpenId(),userInfo.getLocale(),userInfo.getFirstName(),userInfo.getMiddleName(),userInfo.getLastName(),userInfo.getPrefixId(),userInfo.getSuffixId(),userInfo.getMale(),userInfo.getBirthdayMonth(),userInfo.getBirthdayDay(),userInfo.getBirthdayYear(),userInfo.getJobTitle(),userInfo.getGroupIds(),userInfo.getOrganizationIds(),userInfo.getRoleIds(),userInfo.getUserGroupIds(),userInfo.getSendEmail(),serviceContext);

can any one help me out what is correct adduser method signature use for liferay6.0.5 ce?

Regards
Sandeep
Hitoshi Ozawa
RE: To import users in Liferay
June 1, 2012 6:10 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

sorry for the late reply i am using Liferay Community Edition 6.0.5 CE


Then the previous version able as an attachment to the wiki page should work because I've developed it as an example to my 6.0.5 user.
sandeep tripathi
RE: To import users in Liferay
June 4, 2012 11:24 PM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

hi
still not able to find what the problem is can anyone please help me out with it.
i had attach my code i am getting
java.rmi.RemoteException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

regards
Sandeep
Attachments: UserInfo.java (7.6k), UsersImport.java (4.0k), users1.csv (0.1k)
sandeep tripathi
RE: To import users in Liferay
June 6, 2012 2:58 AM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

Hi Hitoshi,

i had downloaded the web service sample once again but it is still showing me the same error while importing user in liferay.
jdbc batch update exception 'incorrect string value for greeting column ' can u say on which file you had made changes because
code of userimport.java is same that i had modified . is there is any other file which u had change

i had also check the the method of userlocalserviceimpl where it set the value of greeting at the time of user creation
String greeting = LanguageUtil.format(locale, "welcome-x", (new StringBuilder(" ")).append(fullName).toString(), false);


pls help!!
sandeep tripathi
RE: To import users in Liferay
June 8, 2012 5:17 AM
Answer

sandeep tripathi

Rank: Regular Member

Posts: 100

Join Date: October 19, 2011

Recent Posts

finally was able to import user in liferay .

thanks
Elijah "Ellie" Mangason
RE: To import users in Liferay
August 2, 2012 1:40 PM
Answer

Elijah "Ellie" Mangason

Rank: Junior Member

Posts: 67

Join Date: May 14, 2012

Recent Posts

I'm using the bulk import procedure that Hitoshi wrote to add users to the portal, and it works great. However, the users imported this way are not showing up in the portal's GUI even though they are clearly present in the database. I've also programmatically created teams and assigned some of the imported users to the teams - neither teams nor users are visible when logged into the portal as administrator. Is anyone else seeing this behaviour? Does anyone know why it's happening, and/or how to correct it?
Hitoshi Ozawa
RE: To import users in Liferay
August 2, 2012 2:53 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Users are not showing up because of the change in specs in liferay 6.1. The "status" is not set to active by default. You'll have to user.setStatus(0); after adding a user.
lou cat
RE: To import users in Liferay
July 11, 2013 7:18 AM
Answer

lou cat

Rank: Regular Member

Posts: 196

Join Date: January 26, 2012

Recent Posts

And was the first version supposed to work in LR6.0.6?

I got many errors, was a bit difficult to understand what was going wrong, so I'm using your code to create a whole portlet...
but still I have many problems related to null field values for the User and duplicateEmailAddresException even if the email is not duplicated emoticon

I've opened another thread if you feel like having a look...