private void exportRolesAndPermissions( PortletDataContext context, String portletId, PortletPreferences preferences, long communityId) throws ReadOnlyException, PortalException, SystemException { PortletConfig portletConfig = configurationService.getPortletConfig(portletId, communityId).getPortletConfig(); if (portletConfig.getRoles() != null) { List<RoleConfig> roleList = collectPortletRoles(portletConfig.getRoles().getRole()); String[] roleNames = new String[roleList.size()]; int idx = 0; for (RoleConfig role : roleList) { long primkey = configurationService.readRoleResourceIdPrimKey(portletId, communityId, role.getName()); roleNames[idx++] = role.getName(); preferences.setValue(ROLE_PREF_PREFIX + String.valueOf(primkey), role.getName()); context.addPermissions(PortletRole.RESOURCE_KEY, primkey); } preferences.setValues(ROLE_NAMES_PREF, roleNames); } }