summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java5
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java8
3 files changed, 14 insertions, 8 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
index b4d1b3ee3..102b1fe2e 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java
@@ -57,10 +57,11 @@ public class ToscaPolicyFilter implements PfObjectFilter<ToscaPolicy> {
// @formatter:off
List<ToscaPolicy> returnList = originalList.stream()
- .filter(p -> filterOnRegexp(p.getName(), name))
- .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version))
- .filter(p -> filterOnRegexp(p.getType(), type))
- .filter(p -> filterOnRegexp(p.getTypeVersion(), typeVersion))
+ .filter(p -> filterString(p.getName(), name))
+ .filter(p -> (version != null && LATEST_VERSION.equals(version))
+ || filterString(p.getVersion(), version))
+ .filter(p -> filterString(p.getType(), type))
+ .filter(p -> filterString(p.getTypeVersion(), typeVersion))
.collect(Collectors.toList());
// @formatter:off
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java
index 041179513..7d6fbacee 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java
@@ -51,8 +51,9 @@ public class ToscaPolicyTypeFilter implements PfObjectFilter<ToscaPolicyType> {
// @formatter:off
List<ToscaPolicyType> returnList = originalList.stream()
- .filter(p -> filterOnRegexp(p.getName(), name))
- .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version))
+ .filter(p -> filterString(p.getName(), name))
+ .filter(p -> (version != null && LATEST_VERSION.equals(version))
+ || filterString(p.getVersion(), version))
.collect(Collectors.toList());
// @formatter:off
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
index 4ddcd60cc..b6c5d3bba 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java
@@ -44,6 +44,10 @@ import org.slf4j.LoggerFactory;
*/
public class LegacyOperationalPolicyMapper
implements JpaToscaServiceTemplateMapper<LegacyOperationalPolicy, LegacyOperationalPolicy> {
+
+ // Property name for the operational policy content
+ private static final String CONTENT_PROPERTY = "content";
+
private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicyMapper.class);
private static final PfConceptKey LEGACY_OPERATIONAL_TYPE =
@@ -64,7 +68,7 @@ public class LegacyOperationalPolicyMapper
final Map<String, String> propertyMap = new HashMap<>();
toscaPolicy.setProperties(propertyMap);
- toscaPolicy.getProperties().put("Content", legacyOperationalPolicy.getContent());
+ toscaPolicy.getProperties().put(CONTENT_PROPERTY, legacyOperationalPolicy.getContent());
final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate();
serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0");
@@ -101,7 +105,7 @@ public class LegacyOperationalPolicyMapper
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
}
- final String content = toscaPolicy.getProperties().get("Content");
+ final String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY);
if (toscaPolicy.getProperties() == null) {
String errorMessage = "property \"Content\" not defined on TOSCA policy";
LOGGER.warn(errorMessage);