/** * Gets the configuration for a profile, along with the configuration * for any profiles it includes (and for any profiles they include, recursively). * * @param name the name of the profile * @return */ public Map<String, ProfileElement> getProfiles(String name) { Map<String, ProfileElement> result = new HashMap<String, ProfileElement>(); synchronized (profiles) { getProfiles(result, name); } return result; }
private void getProfiles(Map<String, ProfileElement> profiles, String name) { if (profiles.containsKey(name)) return; ProfileElement pe = getProfile(name); if (pe == null) { throw new IllegalArgumentException("Profile " + name + " is unknown"); } profiles.put(name, pe); for (String included : pe.getIncludedProfiles()) { getProfiles(profiles, included); } }
@Override public List<String> getAffectedServers(DomainModel domainModel, HostModel hostModel) throws UpdateFailedException { if (getServerModelUpdate() == null) { return Collections.emptyList(); } else { List<String> result = new ArrayList<String>(); // Relevant profiles keyed by the name of those that include them Map<String, Set<String>> includedProfilesByRoot = new HashMap<String, Set<String>>(); for (String server : hostModel.getActiveServerNames()) { String serverGroupName = hostModel.getServer(server).getServerGroup(); String sgProfileName = domainModel.getServerGroup(serverGroupName).getProfileName(); if (!includedProfilesByRoot.containsKey(sgProfileName)) { // Find all the profiles related to this server group's profile includedProfilesByRoot.put(sgProfileName, domainModel.getProfiles(sgProfileName).keySet()); } if (includedProfilesByRoot.get(sgProfileName).contains(profileName)) { result.add(server); } } return result; } } }