Fórumok

To import users in Liferay

Ketkee A, módosítva 12 év-val korábban

To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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?
thumbnail
Sandeep Nair, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 1744 Csatlakozás dátuma: 2008.11.06. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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
thumbnail
Ravi Kumar Gupta, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 1302 Csatlakozás dátuma: 2009.06.24. Legújabb bejegyzések
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
thumbnail
Hitoshi Ozawa, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Expert Bejegyzések: 262 Csatlakozás dátuma: 2009.12.31. Legújabb bejegyzések
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
thumbnail
Hitoshi Ozawa, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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
thumbnail
Hitoshi Ozawa, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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
thumbnail
Hitoshi Ozawa, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 78 Csatlakozás dátuma: 2011.03.10. Legújabb bejegyzések
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
thumbnail
Francois Fournel, módosítva 12 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 99 Csatlakozás dátuma: 2010.04.15. Legújabb bejegyzések
Have a look at the sample code By Manish Kumar Gupta here :

http://www.liferay.com/community/forums/-/message_boards/message/2625709
thumbnail
Hitoshi Ozawa, módosítva 12 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
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 .
thumbnail
Nagendra Kumar Busam, módosítva 11 év-val korábban

RE: To import users in Liferay

Liferay Master Bejegyzések: 678 Csatlakozás dátuma: 2009.07.07. Legújabb bejegyzések
what is the liferay version you are using? Might be method signature might have changed - check it out
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
Hi

sorry for the late reply i am using Liferay Community Edition 6.0.5 CE
sandeep tripathi, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
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
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
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
sandeep tripathi, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
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, módosítva 11 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 100 Csatlakozás dátuma: 2011.10.19. Legújabb bejegyzések
finally was able to import user in liferay .

thanks
thumbnail
Elijah Mangason, módosítva 11 év-val korábban

RE: To import users in Liferay

Junior Member Bejegyzések: 65 Csatlakozás dátuma: 2012.05.14. Legújabb bejegyzések
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?
thumbnail
Hitoshi Ozawa, módosítva 11 év-val korábban

RE: To import users in Liferay

Liferay Legend Bejegyzések: 7942 Csatlakozás dátuma: 2010.03.24. Legújabb bejegyzések
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.
thumbnail
lou cat, módosítva 10 év-val korábban

RE: To import users in Liferay

Regular Member Bejegyzések: 196 Csatlakozás dátuma: 2012.01.26. Legújabb bejegyzések
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...