@Override public Set<String> getAdditionalDefaultGroups() { final Set<String> additionalGroups = getAdditionalDefaultGroupIds(); try { final Map<String, Role> idToRole = roleService.loadAllIdMap(); return Sets.newHashSet( Collections2.transform(additionalGroups, Roles.roleIdToNameFunction(idToRole))); } catch (NotFoundException e) { LOG.error("Unable to load role mapping"); return Collections.emptySet(); } }
@Override public String getDefaultGroup() { final String defaultGroupId = getDefaultGroupId(); if (defaultGroupId.equals(roleService.getReaderRoleObjectId())) { return "Reader"; } try { final Map<String, Role> idToRole = roleService.loadAllIdMap(); return idToRole.get(defaultGroupId).getName(); } catch (Exception e) { LOG.error("Unable to load role mapping"); return "Reader"; } }
@Nonnull @SuppressWarnings("unchecked") @Override public Map<String, String> getGroupMapping() { final Map<String, String> groupMapping = (Map<String, String>) fields.get(GROUP_MAPPING); if (groupMapping == null || groupMapping.isEmpty()) { return Collections.emptyMap(); } else { // we store role ids, but the outside world uses role names to identify them try { final Map<String, Role> idToRole = roleService.loadAllIdMap(); return Maps.newHashMap( Maps.transformValues(groupMapping, Roles.roleIdToNameFunction(idToRole))); } catch (NotFoundException e) { LOG.error("Unable to load role mapping"); return Collections.emptyMap(); } } }