Foren

[Liferay 6] Can not get expando attributes while not connected

xun ren, geändert vor 12 Jahren.

[Liferay 6] Can not get expando attributes while not connected

Junior Member Beiträge: 81 Beitrittsdatum: 01.04.08 Neueste Beiträge
Hello,

I've added some extra information for my organizations while I want to get in the "ServicePreAction" to show them in the front office. However I can not get them untill I haved loged in. And I noticed that the property of my "organization" in the "ServicePreAction" is null while I am not connected.

Can you tell me how to get these expando attributes corrected.

PS: I can get them without problem if I am connected.
I am using Liferay 6.0.6 Community Edition.

Thanks in advance! emoticon
thumbnail
Mika Koivisto, geändert vor 12 Jahren.

RE: [Liferay 6] Can not get expando attributes while not connected

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
Guest user has no organization so naturally it would be null when you are not logged in. You can lookup the organization by using OrganizationLocalServiceUtil and then use orgObj.getExpandoBridge().getAttribute("my-attribute")
thumbnail
Mika Koivisto, geändert vor 12 Jahren.

RE: [Liferay 6] Can not get expando attributes while not connected

Liferay Legend Beiträge: 1519 Beitrittsdatum: 07.08.06 Neueste Beiträge
You should also note that you might need to define permissions to the expando attributes so that they are viewable by guest.
xun ren, geändert vor 12 Jahren.

RE: [Liferay 6] Can not get expando attributes while not connected

Junior Member Beiträge: 81 Beitrittsdatum: 01.04.08 Neueste Beiträge
Thanks Mika,
Yeah, you are right. It's the problem of permission.
I've made it work by adding these in my AppStartAction:

//Grant view permissions to guest and user on expandoColumn otherwise expandobridge does
		//not work when we are guest or user
		Role user = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
		PermissionLocalServiceUtil.setRolePermission(user.getRoleId(), companyId, ExpandoColumn.class.getName(),
				ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), ActionKeys.VIEW);
		Role guest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);
		PermissionLocalServiceUtil.setRolePermission(guest.getRoleId(), companyId, ExpandoColumn.class.getName(),
				ResourceConstants.SCOPE_COMPANY, String.valueOf(companyId), ActionKeys.VIEW);


Thanks again.
xun ren, geändert vor 12 Jahren.

RE: [Liferay 6] Can not get expando attributes while not connected

Junior Member Beiträge: 81 Beitrittsdatum: 01.04.08 Neueste Beiträge
Hi Mika,
In fact, I tried what I said previously in Liferay 5.2.3 EE in my company and it worked fine.

But when I finally moved to my new test project based on Liferay 6.0.6 CE at my home, It doesn't work.
I still do not have the permission required to view the expando columns.

I tried this in my startupAction when I am adding a new column:
     Role user = RoleLocalServiceUtil.getRole(companyId, RoleConstants.USER);
		PermissionLocalServiceUtil.setRolePermission(user.getRoleId(), companyId, ExpandoColumn.class.getName(),
				ResourceConstants.SCOPE_COMPANY, String.valueOf(column.getColumnId()), ActionKeys.VIEW);
		Role guest = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);
		PermissionLocalServiceUtil.setRolePermission(guest.getRoleId(), companyId, ExpandoColumn.class.getName(),
				ResourceConstants.SCOPE_COMPANY, String.valueOf(column.getColumnId()), ActionKeys.VIEW);


Can you tell me how to correctly add these permissions and when should I add them? Thanks in advance.

BTY, I noticed that there is nothing in the table "resource_" after I called the setRolePermission method.

Thanks in advance!
Alexey Trotsenko, geändert vor 11 Jahren.

RE: [Liferay 6] Can not get expando attributes while not connected

New Member Beitrag: 1 Beitrittsdatum: 14.05.12 Neueste Beiträge
I have the same problem. Up