Fórum

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

xun ren, modificado 12 Anos atrás.

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

Junior Member Postagens: 81 Data de Entrada: 01/04/08 Postagens Recentes
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 12 Anos atrás.

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

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
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 12 Anos atrás.

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

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
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 12 Anos atrás.

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

Junior Member Postagens: 81 Data de Entrada: 01/04/08 Postagens Recentes
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 12 Anos atrás.

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

Junior Member Postagens: 81 Data de Entrada: 01/04/08 Postagens Recentes
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 11 Anos atrás.

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

New Member Mensagem: 1 Data de Entrada: 14/05/12 Postagens Recentes
I have the same problem. Up