Forums de discussion

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

xun ren, modifié il y a 12 années.

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

Junior Member Publications: 81 Date d'inscription: 01/04/08 Publications récentes
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, modifié il y a 12 années.

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

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
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, modifié il y a 12 années.

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

Liferay Legend Publications: 1519 Date d'inscription: 07/08/06 Publications récentes
You should also note that you might need to define permissions to the expando attributes so that they are viewable by guest.
xun ren, modifié il y a 12 années.

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

Junior Member Publications: 81 Date d'inscription: 01/04/08 Publications récentes
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, modifié il y a 12 années.

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

Junior Member Publications: 81 Date d'inscription: 01/04/08 Publications récentes
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, modifié il y a 11 années.

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

New Member Envoyer: 1 Date d'inscription: 14/05/12 Publications récentes
I have the same problem. Up