+
+ if (LATEST_VERSION.equals(version)) {
+ returnList = this.latestVersionFilter(returnList);
+ }
+
+ return returnList;
+ }
+
+ /**
+ * Filter PDP groups on PDP type.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param pdpType the PDP type to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPdpType(final PdpGroup pdpGroup, final String pdpType) {
+ if (pdpType == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ if (pdpSubGroup.getPdpType().equals(pdpType)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Filter PDP groups on policy type.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param policyTypeFilter the policy type regular expressions to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPolicyType(final PdpGroup pdpGroup, final ToscaPolicyTypeIdentifier policyTypeFiler) {
+ if (policyTypeFiler == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ for (ToscaPolicyTypeIdentifier foundPolicyType : pdpSubGroup.getSupportedPolicyTypes()) {
+ if (foundPolicyType.getName().matches(policyTypeFiler.getName())
+ && foundPolicyType.getVersion().matches(policyTypeFiler.getVersion())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Filter PDP groups on policy.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param policyFilter the policy regular expressions to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPolicy(final PdpGroup pdpGroup, final ToscaPolicyIdentifier policyFiler) {
+ if (policyFiler == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ for (ToscaPolicyIdentifier foundPolicy : pdpSubGroup.getPolicies()) {
+ if (foundPolicy.getName().matches(policyFiler.getName())
+ && foundPolicy.getVersion().matches(policyFiler.getVersion())) {
+ return true;
+ }
+ }
+ }
+
+ return false;