Fórum

How to get UserID in BasePortletDataHandler.importData()?

Gwowen Fu, modificado 11 Anos atrás.

How to get UserID in BasePortletDataHandler.importData()?

Expert Postagens: 315 Data de Entrada: 27/12/10 Postagens Recentes
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 11 Anos atrás.

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

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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 11 Anos atrás.

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

Expert Postagens: 315 Data de Entrada: 27/12/10 Postagens Recentes
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 11 Anos atrás.

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

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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 11 Anos atrás.

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

Expert Postagens: 315 Data de Entrada: 27/12/10 Postagens Recentes
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.