brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage-tmp <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #264: [DO NOT MERGE] Dangling references cleane...
Date Mon, 18 Jul 2016 14:11:18 GMT
Github user aledsage-tmp commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/264#discussion_r71153473
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java
---
    @@ -94,6 +126,86 @@ public boolean containsAny(Collection<?> container, Iterable<?>
contenders) {
             }
             return result;
         }
    +
    +    public Map<String, String> findLocationsToKeep(BrooklynMementoRawData input)
{
    +        Map<String, String> locationsToKeep = MutableMap.of();
    +        Set<String> allReferencedLocations = findAllReferencedLocations(input);
    +
    +        for (Map.Entry location: input.getLocations().entrySet()) {
    +            if (allReferencedLocations.contains(location.getKey())) {
    +                locationsToKeep.put((String) location.getKey(), (String) location.getValue());
    +            }
    +        }
    +        return locationsToKeep;
    +    }
    +
    +    public Set<String> findAllReferencedLocations(BrooklynMementoRawData input)
{
    +        Set<String> allReferencedLocations = MutableSet.of();
    +
    +        allReferencedLocations.addAll(searchLocationsToKeepInEntities(input.getEntities()));
    +        allReferencedLocations.addAll(searchLocationsToKeepInPolicies(input.getPolicies()));
    +        allReferencedLocations.addAll(searchLocationsToKeepInEnrichers(input.getEnrichers()));
    +        allReferencedLocations.addAll(searchLocationsToKeepInLocations(input.getLocations(),
allReferencedLocations));
    +
    +        return allReferencedLocations;
    +    }
    +
    +    private Set<String> searchLocationsToKeepInEntities(Map<String, String>
entities) {
    +        Set<String> result = MutableSet.of();
    +
    +        for(Map.Entry entity: entities.entrySet()) {
    +
    +            String locationProxyPrefix = "<locationProxy>";
    +            String locationProxySuffix = "</locationProxy>";
    +            String locationPrefix = "<locations>\n" +
    --- End diff --
    
    Perhaps use xpath for this. See XmlUtils.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message