Foros de discusión

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

xun ren, modificado hace 12 años.

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

Junior Member Mensajes: 81 Fecha de incorporación: 1/04/08 Mensajes recientes
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, modificado hace 12 años.

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

Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
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, modificado hace 12 años.

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

Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
You should also note that you might need to define permissions to the expando attributes so that they are viewable by guest.
xun ren, modificado hace 12 años.

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

Junior Member Mensajes: 81 Fecha de incorporación: 1/04/08 Mensajes recientes
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, modificado hace 12 años.

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

Junior Member Mensajes: 81 Fecha de incorporación: 1/04/08 Mensajes recientes
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, modificado hace 11 años.

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

New Member Mensaje: 1 Fecha de incorporación: 14/05/12 Mensajes recientes
I have the same problem. Up