Hi we are trying to create a portlet that allows guest users to fill in a form give information like Organization Name, username, email and some expando fields on both the organization and user.
We are getting the following exception when posting.
1binding organization expando fields!
208:28:00,138 ERROR [ExpandoBridgeImpl:507] com.liferay.portal.security.auth.PrincipalException
3com.liferay.portal.security.auth.PrincipalException
4 at com.liferay.portlet.expando.service.permission.ExpandoColumnPermissionImpl.check(ExpandoColumnPermissionImpl.java:35)
5 at com.liferay.portlet.expando.service.permission.ExpandoColumnPermissionUtil.check(ExpandoColumnPermissionUtil.java:32)
Here is the code in question. You can see by the log entry above where in the code we get when the exception is thrown.
I suspect that the guest user(aka unauthenticated user) is posting the form that user does't have adequate permissions to bind the expando fields.
1
2public class OrganizationCreationServiceImpl implements
3 OrganizationCreationService {
4
5 private Logger logger = Logger.getLogger(this.getClass());
6 private static final int STATUS_ID = 12017;
7 private static final String ORG_ADMIN_ROLE_NAME = "Regular Superadmin";
8
9 @Override
10 public Organization createOrganization(OrgAccountForm form, RequestContext context)
11 throws PortalException, SystemException {
12 long adminId = getAdminId();
13
14 ServiceContext serviceContext;
15 try {
16
17 System.out.println("ADDING ORGANIZATION");
18 ExternalContext externalContext = context.getExternalContext();
19 PortletRequest nativeRequest = (PortletRequest) externalContext.getNativeRequest();
20 serviceContext = ServiceContextFactory.getInstance(
21 Organization.class.getName(), nativeRequest);
22
23
24 bindOrganizationExpandoFields(form, serviceContext);
25 Organization org = OrganizationLocalServiceUtil.addOrganization(adminId, 0,
26 form.getName(), OrganizationConstants.TYPE_REGULAR_ORGANIZATION,
27 false, 0, 0, STATUS_ID, "", false, serviceContext);
28 return org;
29
30 } catch (PortalException e) {
31 e.printStackTrace();
32 throw e;
33 } catch (SystemException e) {
34 e.printStackTrace();
35 throw e;
36 }
37
38 }
39
40 private void bindOrganizationExpandoFields(OrgAccountForm form, ServiceContext context){
41 System.out.println("binding organization expando fields!");
42
43 Map<String, Serializable> expandoFields = context.getExpandoBridgeAttributes();
44
45 String[] timezone_types = {form.getTimezone()};
46
47 expandoFields.put("timezone", timezone_types);
48 expandoFields.put("description", form.getDescription());
49 expandoFields.put("website", form.getWebsite());
50 expandoFields.put("phoneNumber", form.getPhoneNumber());
51 expandoFields.put("addressLine1", form.getAddressLine1());
52 expandoFields.put("addressLine2", form.getAddressLine2());
53 expandoFields.put("country", form.getCountry());
54 expandoFields.put("state", form.getState());
55 expandoFields.put("city", form.getCity());
56 expandoFields.put("postalCode", form.getPostalCode());
57 expandoFields.put("phoneArea", form.getPhoneArea());
58 expandoFields.put("email", form.getOrgEmail());
59 expandoFields.put("userLimit", form.getUserLimit());
60
61 context.setExpandoBridgeAttributes(expandoFields);
62
63 }
Please sign in to flag this as inappropriate.