diff options
author | Jim Hahn <jrh3@att.com> | 2019-11-21 14:59:52 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-11-21 15:09:15 -0500 |
commit | e9a04a92d419bc936fa231397a58e72f4d1c14c6 (patch) | |
tree | a01299ca4cddaa759e73889a01efb41299f0231b /models-pdp/src/main/java/org/onap | |
parent | 37bd15efd41962e237575ea0c26728e5040abbe1 (diff) |
Allow wild cards in supported type filter
PAP was rejecting deployment of policies whose supported type
contained a wild card. This was due to the fact that it was
querying the Pdp Groups using a filter on the supported type,
which did not take wild cards into consideration. Updated the
filtering.
Change-Id: I50b3202a00ac85ff09a9861d8bbe1efb6dd49ae3
Issue-ID: POLICY-1636
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src/main/java/org/onap')
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java index d67f2d4cb..7faf19748 100644 --- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java +++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -121,7 +122,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { if (matchPolicyTypesExactly && areListsIdentical(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { return true; } else if (!matchPolicyTypesExactly - && findSingleElement(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { + && findSupportedPolicyType(pdpSubGroup.getSupportedPolicyTypes(), typeFilter)) { return true; } } @@ -131,6 +132,32 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> { } /** + * Find a single supported type. + * + * @param supportedPolicyTypes supported types + * @param typeFilter the list of types, one of which we wish to find supported by + * the list we are searching + * @return true if one element of the elements to find is supported by an element on + * the list we searched + */ + private boolean findSupportedPolicyType(List<ToscaPolicyTypeIdentifier> supportedPolicyTypes, + List<ToscaPolicyTypeIdentifier> typeFilter) { + for (ToscaPolicyTypeIdentifier supportedPolicyType : supportedPolicyTypes) { + String supName = supportedPolicyType.getName(); + if (supName.endsWith(".*")) { + String substr = supName.substring(0, supName.length() - 1); + if (typeFilter.stream().anyMatch(type -> type.getName().startsWith(substr))) { + return true; + } + } else if (typeFilter.contains(supportedPolicyType)) { + return true; + } + } + + return false; + } + + /** * Filter PDP groups on policy. * * @param pdpGroup the PDP group to check |