You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2016/07/20 17:20:12 UTC

[05/11] brooklyn-server git commit: Fix for keeping location from more references

Fix for keeping location from more references


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/34afc03d
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/34afc03d
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/34afc03d

Branch: refs/heads/master
Commit: 34afc03d6bd7f750c2c3b358e65d9d99c23c3230
Parents: 9e6dfc4
Author: Ivana Yovcheva <iv...@gmail.com>
Authored: Tue Jul 19 21:30:26 2016 +0300
Committer: Ivana Yovcheva <iv...@gmail.com>
Committed: Tue Jul 19 21:30:26 2016 +0300

----------------------------------------------------------------------
 .../DeleteOrphanedLocationsTransformer.java     | 35 +++++++-------------
 1 file changed, 12 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/34afc03d/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java
index 1c9cd9e..9f87984 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/transformer/impl/DeleteOrphanedLocationsTransformer.java
@@ -146,25 +146,28 @@ public class DeleteOrphanedLocationsTransformer extends CompoundTransformer impl
     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(searchLocationsToKeep(input.getEntities(), "/entity"));
+        allReferencedLocations.addAll(searchLocationsToKeep(input.getPolicies(), "/policy"));
+        allReferencedLocations.addAll(searchLocationsToKeep(input.getEnrichers(), "/enricher"));
+        allReferencedLocations.addAll(searchLocationsToKeep(input.getFeeds(), "/feed"));
         allReferencedLocations.addAll(searchLocationsToKeepInLocations(input.getLocations(), allReferencedLocations));
 
         return allReferencedLocations;
     }
 
-    private Set<String> searchLocationsToKeepInEntities(Map<String, String> entities) {
+    private Set<String> searchLocationsToKeep(Map<String, String> entities, String searchInTypePrefix) {
         Set<String> result = MutableSet.of();
 
         for(Map.Entry entity: entities.entrySet()) {
 
             String prefix = "/entity";
             String location = "/locations/string";
-            String locationProxy = "/attributes/softwareservice.provisioningLocation/locationProxy";
+            String locationProxy = "/attributes//locationProxy";
+            String locationInConfig = "/config//locationProxy";
 
-            result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) entity.getValue(), prefix+location, XPathConstants.NODESET)));
-            result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) entity.getValue(), prefix+locationProxy, XPathConstants.NODESET)));
+            result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) entity.getValue(), searchInTypePrefix+location, XPathConstants.NODESET)));
+            result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) entity.getValue(), searchInTypePrefix+locationProxy, XPathConstants.NODESET)));
+            result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) entity.getValue(), searchInTypePrefix+locationInConfig, XPathConstants.NODESET)));
         }
 
         return result;
@@ -177,14 +180,12 @@ public class DeleteOrphanedLocationsTransformer extends CompoundTransformer impl
         String locationId = "/id";
         String locationChildren = "/children/string";
         String locationParentDirectTag = "/parent";
-        String locationParent = "/locationConfig/jcloudsParent/locationProxy";
-        String locationProxy = "/locationConfig/vmInstanceIds/map/entry/locationProxy";
+        String locationProxy = "/locationConfig//locationProxy";
 
         for (Map.Entry location: locations.entrySet()) {
-            if (alreadyReferencedLocations.contains(location)) {
+            if (alreadyReferencedLocations.contains(location.getKey())) {
                 result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) location.getValue(), prefix+locationId, XPathConstants.NODESET)));
                 result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) location.getValue(), prefix+locationChildren, XPathConstants.NODESET)));
-                result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) location.getValue(), prefix+locationParent, XPathConstants.NODESET)));
                 result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) location.getValue(), prefix+locationParentDirectTag, XPathConstants.NODESET)));
                 result.addAll(getAllNodesFromXpath((DTMNodeList) XmlUtil.xpath((String) location.getValue(), prefix+locationProxy, XPathConstants.NODESET)));
             }
@@ -193,18 +194,6 @@ public class DeleteOrphanedLocationsTransformer extends CompoundTransformer impl
         return result;
     }
 
-    private Set<String> searchLocationsToKeepInPolicies(Map<String, String> policies) {
-        Set<String> result = MutableSet.of();
-
-        return result;
-    }
-
-    private Set<String> searchLocationsToKeepInEnrichers(Map<String, String> enrichers) {
-        Set<String> result = MutableSet.of();
-
-        return result;
-    }
-
     private Set<String> getAllNodesFromXpath(DTMNodeList nodeList) {
         Set<String> result = MutableSet.of();