mirror of https://github.com/apache/jclouds.git
fixes in location containment predicate.
the grouping of and's and or's was wrong, causing an NPE in cloudstack tests when investigating parents; the direction of containment (input should be descendent of location) was wrong also, i think, to judge by the description "locationEqualsOrChildOf"; code is now a loop rather than fixed investigation of 3 levels
This commit is contained in:
parent
2523d74ad1
commit
0676300841
|
@ -139,17 +139,20 @@ public class TemplateBuilderImpl implements TemplateBuilder {
|
||||||
*
|
*
|
||||||
* If the input location is null, then the data isn't location sensitive
|
* If the input location is null, then the data isn't location sensitive
|
||||||
*
|
*
|
||||||
* If the input location is a parent of the specified location, then we are ok.
|
* If the input location is a child (descendent, recursively) of the specified location, then we are ok.
|
||||||
*/
|
*/
|
||||||
final Predicate<ComputeMetadata> locationPredicate = new Predicate<ComputeMetadata>() {
|
final Predicate<ComputeMetadata> locationPredicate = new Predicate<ComputeMetadata>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ComputeMetadata input) {
|
public boolean apply(ComputeMetadata input) {
|
||||||
boolean returnVal = true;
|
if (location == null) return true;
|
||||||
if (location != null && input.getLocation() != null)
|
Location inputLocation = input.getLocation();
|
||||||
returnVal = location.equals(input.getLocation()) || location.getParent() != null
|
if (inputLocation == null) return true;
|
||||||
&& location.getParent().equals(input.getLocation()) || location.getParent().getParent() != null
|
while (inputLocation!=null) {
|
||||||
&& location.getParent().getParent().equals(input.getLocation());
|
if (location.equals(inputLocation))
|
||||||
return returnVal;
|
return true;
|
||||||
|
inputLocation = inputLocation.getParent();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue