Fórumok
Allowing Guests to set expando Attributes
Dave Weitzel, módosítva 11 év-val korábban
Allowing Guests to set expando Attributes
Regular Member Bejegyzések: 208 Csatlakozás dátuma: 2009.11.18. Legújabb bejegyzések
Hi,
continuing my trials and tribulations on coding a user applying to join a web site (surely a use case for training?) I cracked the login issue:
https://www.liferay.com/community/forums/-/message_boards/message/23076064
but now have hit a problem with Expando fields.
The application form has new fields for the user profile (member-type etc).
I can manually set these to always be updated by guest users and things work well but that would leave things open.
So I tried using this method to set the attribute as RW by guest:
However I am now getting an error because I am calling this as a guest still (setting them read write first before adding user and logging said user in).
Am I right in thinking this is what is happening (trying as guest to set permissions on these attributes) and if so can anyone think of how this can be done?
Thanks
continuing my trials and tribulations on coding a user applying to join a web site (surely a use case for training?) I cracked the login issue:
https://www.liferay.com/community/forums/-/message_boards/message/23076064
but now have hit a problem with Expando fields.
The application form has new fields for the user profile (member-type etc).
I can manually set these to always be updated by guest users and things work well but that would leave things open.
So I tried using this method to set the attribute as RW by guest:
public static void setGuestPermissionOnExpandoColumn(long groupId, long companyId, String attr){
try{
Role guestRole = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);
String[] actionsRW = new String[] { ActionKeys.VIEW, ActionKeys.UPDATE };
ExpandoBridge expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge( companyId, User.class.getName());
ExpandoColumn column = ExpandoColumnLocalServiceUtil.getColumn(
companyId, expandoBridge.getClassName(),
ExpandoTableConstants.DEFAULT_TABLE_NAME,
attr);
_log.info("set expando name = " + ExpandoColumn.class.getName() + " Columnid= " +
String.valueOf(column.getColumnId()) + " roleid= " + guestRole.getRoleId());
ResourcePermissionServiceUtil.setIndividualResourcePermissions(groupId, companyId,
ExpandoColumn.class.getName(), String.valueOf(column.getColumnId()),
guestRole.getRoleId(), actionsRW);
}catch (Exception e){
e.printStackTrace();
}
}
However I am now getting an error because I am calling this as a guest still (setting them read write first before adding user and logging said user in).
20:53:15,025 INFO [http-bio-8080-exec-21][ActionUtil:343] set expando name = com.liferay.portlet.expando.model.ExpandoColumn Columnid= 15201 roleid= 10161
com.liferay.portal.security.auth.PrincipalException
at com.liferay.portal.service.impl.PermissionServiceImpl.checkPermission(PermissionServiceImpl.java:700)
at com.liferay.portal.service.impl.PermissionServiceImpl.checkPermission(PermissionServiceImpl.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.security.pacl.PACLAdvice.invoke(PACLAdvice.java:133)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
at $Proxy57.checkPermission(Unknown Source)
at com.liferay.portal.service.impl.ResourcePermissionServiceImpl.setIndividualResourcePermissions(ResourcePermissionServiceImpl.java:192)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:122)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:57)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.security.pacl.PACLAdvice.invoke(PACLAdvice.java:133)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:118)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
at $Proxy85.setIndividualResourcePermissions(Unknown Source)
at com.liferay.portal.service.ResourcePermissionServiceUtil.setIndividualResourcePermissions(ResourcePermissionServiceUtil.java:204)
at com.plaza.membership.ActionUtil.setGuestPermissionOnExpandoColumn(ActionUtil.java:345)
at com.plaza.membership.ActionUtil.setGuestPermissionOnExpandoColumns(ActionUtil.java:330)
at com.plaza.membership.ActionUtil.addUser(ActionUtil.java:169)
at com.plaza.membership.UserPortlet.join(UserPortlet.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Am I right in thinking this is what is happening (trying as guest to set permissions on these attributes) and if so can anyone think of how this can be done?
Thanks