Foren

How to get UserID in BasePortletDataHandler.importData()?

Gwowen Fu, geändert vor 11 Jahren.

How to get UserID in BasePortletDataHandler.importData()?

Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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, geändert vor 11 Jahren.

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

Expert Beiträge: 315 Beitrittsdatum: 27.12.10 Neueste Beiträge
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.