Foros de discusión

How to get UserID in BasePortletDataHandler.importData()?

Gwowen Fu, modificado hace 11 años.

How to get UserID in BasePortletDataHandler.importData()?

Expert Mensajes: 315 Fecha de incorporación: 27/12/10 Mensajes recientes
Hi,

Based on the Sample-lar-portlet project, I have a class extending BasePortletDataHandler to add UserGroup when exportData() is called during Import.

I am calling UserGroupLocalServiceUtil.addUserGroup(userId, companyId, name, description) to add a user group but it requires a userId.

How could I get the current user's user id inside importData?
public String exportData(PortletDataContext context, String portletId, PortletPreferences preferences) throws PortletDataException;

I see context.getUserIdStrategy() can return UserIdStrategy which can return userId by providing userUuid;
How could I get the UUID?

Is there ant way I can get user ID?

Thanks!
Gwowen
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to get UserID in BasePortletDataHandler.importData()?

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Don't you have these concepts kinda reversed?

On export, you'd be exporting the user group information so you'd have the user id available.

On import, here's where you'd call the UserGroupLocalServiceUtil.addUserGroup() method because you're importing a user group and the import has the user id to use...
Gwowen Fu, modificado hace 11 años.

RE: How to get UserID in BasePortletDataHandler.importData()?

Expert Mensajes: 315 Fecha de incorporación: 27/12/10 Mensajes recientes
David H Nebinger:

On export, you'd be exporting the user group information so you'd have the user id available.

There is no user id when I exporting UserGroup. UserGroup table doesn't have user id. It only has "userGroupId", "companyId", "parentUserGroupId", "name", "description", "addedByLDAPImport".

I don't understand why user id is needed for inserting UserGroup. Is there any other table involved?

Thanks!
Gwowen
thumbnail
David H Nebinger, modificado hace 11 años.

RE: How to get UserID in BasePortletDataHandler.importData()? (Respuesta)

Liferay Legend Mensajes: 14915 Fecha de incorporación: 2/09/06 Mensajes recientes
Sure, adding a user group at least involves adding a group, adding resources, adding permissions, ...

Check out the logic in the source for com.liferay.portal.service.impl.UserGroupLocalServiceImpl to trace through everything that happens...
Gwowen Fu, modificado hace 11 años.

RE: How to get UserID in BasePortletDataHandler.importData()?

Expert Mensajes: 315 Fecha de incorporación: 27/12/10 Mensajes recientes
David H Nebinger:
Sure, adding a user group at least involves adding a group, adding resources, adding permissions, ...

Check out the logic in the source for com.liferay.portal.service.impl.UserGroupLocalServiceImpl to trace through everything that happens...


Thanks, I found the answer there.