@Test public void testEnsureIsMemberOfIsUsedWherePossible() throws RepositoryException, IOException, AcConfigBeanValidationException { AcConfiguration acConfiguration = getAcConfigurationForFile(getConfigurationMerger(), session, "test-membergroups.yaml"); AuthorizableConfigBean groupAConfig = acConfiguration.getAuthorizablesConfig().getAuthorizableConfig("groupA"); assertEquals("groupA", groupAConfig.getAuthorizableId()); String[] members = groupAConfig.getIsMemberOf(); assertArrayEquals("check if groups have been copied over into isMemberOf field", new String[] { "groupB", "groupC", "groupD" }, members); AuthorizableConfigBean groupBConfig = acConfiguration.getAuthorizablesConfig().getAuthorizableConfig("groupB"); assertArrayEquals("ensure that members that were added to isMemberOf are removed from original members arr", new String[0], groupBConfig.getMembers()); }
void ensureIsMemberOfIsUsedWherePossible(AuthorizablesConfig mergedAuthorizablesBeansfromConfig, InstallationLogger history) { for (AuthorizableConfigBean group : mergedAuthorizablesBeansfromConfig) { if (!group.isGroup()) { continue; } final String groupName = group.getAuthorizableId(); String[] origMembersArr = group.getMembers(); if ((origMembersArr == null) || (origMembersArr.length == 0)) { continue; } final List<String> members = new ArrayList<String>(Arrays.asList(origMembersArr)); Iterator<String> membersIt = members.iterator(); while (membersIt.hasNext()) { String member = membersIt.next(); AuthorizableConfigBean groupForIsMemberOf = mergedAuthorizablesBeansfromConfig.getAuthorizableConfig(member); boolean memberContainedInConfig = groupForIsMemberOf != null; if (memberContainedInConfig) { groupForIsMemberOf.addIsMemberOf(groupName); membersIt.remove(); history.addVerboseMessage(LOG, "Group " + group.getAuthorizableId() + " is declaring member " + member + " - moving relationship to isMemberOf of authorizable " + groupForIsMemberOf.getAuthorizableId() + " (always prefer using isMemberOf over members if referenced member is availalbe in configuration)"); } } group.setMembers(members.toArray(new String[members.size()])); } }
YamlConfigurationMerger implements ConfigurationMerger { void ensureIsMemberOfIsUsedWherePossible(AuthorizablesConfig mergedAuthorizablesBeansfromConfig, InstallationLogger history) { for (AuthorizableConfigBean group : mergedAuthorizablesBeansfromConfig) { if (!group.isGroup()) { continue; } final String groupName = group.getAuthorizableId(); String[] origMembersArr = group.getMembers(); if ((origMembersArr == null) || (origMembersArr.length == 0)) { continue; } final List<String> members = new ArrayList<String>(Arrays.asList(origMembersArr)); Iterator<String> membersIt = members.iterator(); while (membersIt.hasNext()) { String member = membersIt.next(); AuthorizableConfigBean groupForIsMemberOf = mergedAuthorizablesBeansfromConfig.getAuthorizableConfig(member); boolean memberContainedInConfig = groupForIsMemberOf != null; if (memberContainedInConfig) { groupForIsMemberOf.addIsMemberOf(groupName); membersIt.remove(); history.addVerboseMessage(LOG, "Group " + group.getAuthorizableId() + " is declaring member " + member + " - moving relationship to isMemberOf of authorizable " + groupForIsMemberOf.getAuthorizableId() + " (always prefer using isMemberOf over members if referenced member is availalbe in configuration)"); } } group.setMembers(members.toArray(new String[members.size()])); } } }
YamlConfigurationMerger implements ConfigurationMerger { void ensureIsMemberOfIsUsedWherePossible(AuthorizablesConfig mergedAuthorizablesBeansfromConfig, InstallationLogger history) { for (AuthorizableConfigBean group : mergedAuthorizablesBeansfromConfig) { if (!group.isGroup()) { continue; } final String groupName = group.getAuthorizableId(); String[] origMembersArr = group.getMembers(); if ((origMembersArr == null) || (origMembersArr.length == 0)) { continue; } final List<String> members = new ArrayList<String>(Arrays.asList(origMembersArr)); Iterator<String> membersIt = members.iterator(); while (membersIt.hasNext()) { String member = membersIt.next(); AuthorizableConfigBean groupForIsMemberOf = mergedAuthorizablesBeansfromConfig.getAuthorizableConfig(member); boolean memberContainedInConfig = groupForIsMemberOf != null; if (memberContainedInConfig) { groupForIsMemberOf.addIsMemberOf(groupName); membersIt.remove(); history.addVerboseMessage(LOG, "Group " + group.getAuthorizableId() + " is declaring member " + member + " - moving relationship to isMemberOf of authorizable " + groupForIsMemberOf.getAuthorizableId() + " (always prefer using isMemberOf over members if referenced member is availalbe in configuration)"); } } group.setMembers(members.toArray(new String[members.size()])); } }  }
YamlConfigurationMerger implements ConfigurationMerger { void ensureIsMemberOfIsUsedWherePossible(AuthorizablesConfig mergedAuthorizablesBeansfromConfig, InstallationLogger history) { for (AuthorizableConfigBean group : mergedAuthorizablesBeansfromConfig) { if (!group.isGroup()) { continue; } final String groupName = group.getAuthorizableId(); String[] origMembersArr = group.getMembers(); if ((origMembersArr == null) || (origMembersArr.length == 0)) { continue; } final List<String> members = new ArrayList<String>(Arrays.asList(origMembersArr)); Iterator<String> membersIt = members.iterator(); while (membersIt.hasNext()) { String member = membersIt.next(); AuthorizableConfigBean groupForIsMemberOf = mergedAuthorizablesBeansfromConfig.getAuthorizableConfig(member); boolean memberContainedInConfig = groupForIsMemberOf != null; if (memberContainedInConfig) { groupForIsMemberOf.addIsMemberOf(groupName); membersIt.remove(); history.addVerboseMessage(LOG, "Group " + group.getAuthorizableId() + " is declaring member " + member + " - moving relationship to isMemberOf of authorizable " + groupForIsMemberOf.getAuthorizableId() + " (always prefer using isMemberOf over members if referenced member is availalbe in configuration)"); } } group.setMembers(members.toArray(new String[members.size()])); } }  @Override AcConfiguration getMergedConfigurations(
            final Map<String, String> configFileContentByFilename,
            final PersistableInstallationLogger installLog,
            final ConfigReader configReader, Session session); }
YamlConfigurationMerger implements ConfigurationMerger { void ensureIsMemberOfIsUsedWherePossible(AuthorizablesConfig mergedAuthorizablesBeansfromConfig, InstallationLogger history) { for (AuthorizableConfigBean group : mergedAuthorizablesBeansfromConfig) { if (!group.isGroup()) { continue; } final String groupName = group.getAuthorizableId(); String[] origMembersArr = group.getMembers(); if ((origMembersArr == null) || (origMembersArr.length == 0)) { continue; } final List<String> members = new ArrayList<String>(Arrays.asList(origMembersArr)); Iterator<String> membersIt = members.iterator(); while (membersIt.hasNext()) { String member = membersIt.next(); AuthorizableConfigBean groupForIsMemberOf = mergedAuthorizablesBeansfromConfig.getAuthorizableConfig(member); boolean memberContainedInConfig = groupForIsMemberOf != null; if (memberContainedInConfig) { groupForIsMemberOf.addIsMemberOf(groupName); membersIt.remove(); history.addVerboseMessage(LOG, "Group " + group.getAuthorizableId() + " is declaring member " + member + " - moving relationship to isMemberOf of authorizable " + groupForIsMemberOf.getAuthorizableId() + " (always prefer using isMemberOf over members if referenced member is availalbe in configuration)"); } } group.setMembers(members.toArray(new String[members.size()])); } }  @Override AcConfiguration getMergedConfigurations(
            final Map<String, String> configFileContentByFilename,
            final PersistableInstallationLogger installLog,
            final ConfigReader configReader, Session session);  }