aspose file tools*
The moose likes Portals and Portlets and the fly likes import users in liferay with some exando fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "import users in liferay with some exando fields" Watch "import users in liferay with some exando fields" New topic
Author

import users in liferay with some exando fields

Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
Today I would like to solve the migration of my old non-liferay user database into Liferay 6.1.
I have all the required fields, plus I know that I need 3 more expando fields.

I have seen codes which can programatically create users, but I don't know how to add those 3 expando fields too when the users are just created.
Jonas X. Yuan
author
Ranch Hand

Joined: May 18, 2008
Posts: 108
Hi Tibi,

Do you use LDAP server integration?

Yes, the custom fields (expando) could be used in the LDAP user info mapping.

Thanks

Jonas Yuan


Books: Liferay Portal 6.1 Systems Development
Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
Unfortunately I am not using LDAP. I have here a simple database table based authentication, once implemented with spring security.

Let's describe my integration between my old stuffs and the liferay.
Initially I had a database where there is a User table and some foreign keys refers to that User table.
I didn't merged my old tables into liferay database, instead I kept as it is. But I created the most simple integration of the users, such as in my old (code to be migrated in portal env) where the authenticated user is used to lookup the user table, there I introduced a mapping, by first asking from the liferay's themeDisplay the logged in User (if any) and then with that id, I am looking that I have already cloned the user data or not, into the old users table. If not, then I am creating that record, reading also the 3 expando fields form liferay which is necessary to match all the field's requirement in my old users table.

I'm not convinced about this approach, maybe later on I'll introduce a hook, by implementing the user service from liferay.
(My current first aproach also handles user details changes also, but it's a bit too late when it is executed. It's fine for the logged in user itself, but if some administrative tasks uses the old users table, theoretically it may get caught in an inconsistent state, not reflecting the latest changes of the user once executed in liferay. In practice, this is happening if the user immediately logged out after changing its details.)
Amro Ali
Greenhorn

Joined: Feb 29, 2012
Posts: 25
Take a look at this blog for details on using expando. I know it's written in velocity, but velocity leverages java objects and methods.

If you require more detailed examples in java just reply again to the post and I'll post some.
Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
Amro Ali wrote:Take a look at this blog for details on using expando. I know it's written in velocity, but velocity leverages java objects and methods.

If you require more detailed examples in java just reply again to the post and I'll post some.


Thanks for the link. It will be the today's task :-)
Tibi Kiss
Ranch Hand

Joined: Jun 11, 2009
Posts: 47
In fact user import is extremly easy.



I also get into problems with password migration. Looks like my old passwords are md5 with salted hash. Unfortunately Liferay does not support this kind of digest.
If I could hook (or with ext env) the com.liferay.portal.security.pwd.PwdEncryptor, or com.liferay.portal.security.pwd.PwdAuthenticator it would be one way to migrate.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: import users in liferay with some exando fields