summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2020-02-13 13:05:09 +0000
committerliamfallon <liam.fallon@est.tech>2020-02-13 13:15:29 +0000
commit3ecaccdf3041e7c29a4ca3b0ae4f18648976a668 (patch)
tree628c5c7c811db2524b09a9cf990554ab47340e66 /models-tosca/src/main
parentad1cd2013f45da5764fc9610db1f679d3c3762cb (diff)
Update models-tosca for hetter handling
More additions, updates, and fixes for TOSCA service template handling. Better handling of 404 not found on list requests. Issue-ID: POLICY-1402 Change-Id: Id73b9a3cebb5445d4f05ae83e301330ee38a6598 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-tosca/src/main')
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java1
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java5
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java5
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java9
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java2
6 files changed, 23 insertions, 8 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
index 6e60303a0..a65cdbe69 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java
@@ -423,6 +423,7 @@ public class AuthorativeToscaProvider {
*/
private <T extends ToscaEntity> List<T> handlePfModelRuntimeException(final PfModelRuntimeException pfme) {
if (Status.NOT_FOUND.equals(pfme.getErrorResponse().getResponseCode())) {
+ LOGGER.trace("request did not find any results", pfme);
return Collections.emptyList();
} else {
throw pfme;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java
index f5335fe79..09cc6c0ca 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java
@@ -93,13 +93,13 @@ public class LegacyProvider {
LOGGER.debug("->createOperationalPolicy: legacyOperationalPolicy={}", legacyOperationalPolicy);
- JpaToscaServiceTemplate incomingServiceTemplate =
+ JpaToscaServiceTemplate legacyOperationalServiceTemplate =
new LegacyOperationalPolicyMapper().toToscaServiceTemplate(legacyOperationalPolicy);
- JpaToscaServiceTemplate outgoingingServiceTemplate =
- new SimpleToscaProvider().createPolicies(dao, incomingServiceTemplate);
+
+ new SimpleToscaProvider().createPolicies(dao, legacyOperationalServiceTemplate);
LegacyOperationalPolicy createdLegacyOperationalPolicy =
- new LegacyOperationalPolicyMapper().fromToscaServiceTemplate(outgoingingServiceTemplate);
+ new LegacyOperationalPolicyMapper().fromToscaServiceTemplate(legacyOperationalServiceTemplate);
LOGGER.debug("<-createOperationalPolicy: createdLegacyOperationalPolicy={}", createdLegacyOperationalPolicy);
return createdLegacyOperationalPolicy;
@@ -223,7 +223,6 @@ public class LegacyProvider {
return updatedLegacyGuardPolicyMap;
}
-
/**
* Delete legacy guard policy.
*
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
index 2816df004..b500a8bc9 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java
@@ -261,6 +261,11 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P
public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
PfValidationResult result = super.validate(resultIn);
+ if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "key version is a null version"));
+ }
+
if (type == null || type.isNullKey()) {
result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
"type is null or a null key"));
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java
index b068beaa0..423620dd7 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java
@@ -203,6 +203,11 @@ public class JpaToscaPolicyType extends JpaToscaEntityType<ToscaPolicyType> impl
public PfValidationResult validate(@NonNull final PfValidationResult resultIn) {
PfValidationResult result = super.validate(resultIn);
+ if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) {
+ result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID,
+ "key version is a null version"));
+ }
+
if (properties != null) {
result = validateProperties(result);
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
index 9c7d6d305..17eae006d 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java
@@ -264,6 +264,9 @@ public class SimpleToscaProvider {
"policy types for " + name + ":" + version + DO_NOT_EXIST);
}
+ JpaToscaServiceTemplate dataTypeServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate);
+ dataTypeServiceTemplate.setPolicyTypes(null);
+
for (JpaToscaPolicyType policyType : serviceTemplate.getPolicyTypes().getConceptMap().values()) {
Collection<PfConceptKey> referencedDataTypeKeys = policyType.getReferencedDataTypes();
@@ -271,11 +274,13 @@ public class SimpleToscaProvider {
JpaToscaServiceTemplate dataTypeEntityTreeServiceTemplate =
getDataTypes(dao, referencedDataTypeKey.getName(), referencedDataTypeKey.getVersion());
- serviceTemplate =
- ToscaServiceTemplateUtils.addFragment(serviceTemplate, dataTypeEntityTreeServiceTemplate);
+ dataTypeServiceTemplate = ToscaServiceTemplateUtils.addFragment(dataTypeServiceTemplate,
+ dataTypeEntityTreeServiceTemplate);
}
}
+ serviceTemplate = ToscaServiceTemplateUtils.addFragment(serviceTemplate, dataTypeServiceTemplate);
+
LOGGER.debug("<-getPolicyTypes: name={}, version={}, serviceTemplate={}", name, version, serviceTemplate);
return serviceTemplate;
}
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
index 87b499b4c..aae45e5ce 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java
@@ -74,7 +74,7 @@ public class ToscaServiceTemplateUtils {
compositeTemplate.setPolicyTypes(
addFragmentEntitites(compositeTemplate.getPolicyTypes(), fragmentTemplate.getPolicyTypes(), result));
- if (originalTemplate.getTopologyTemplate() != null) {
+ if (originalTemplate.getTopologyTemplate() != null && fragmentTemplate.getTopologyTemplate() != null) {
if (originalTemplate.getTopologyTemplate()
.compareToWithoutEntities(fragmentTemplate.getTopologyTemplate()) == 0) {
compositeTemplate.getTopologyTemplate()