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/simple/provider/SimpleToscaProvider.java17
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java2
-rw-r--r--models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java4
3 files changed, 11 insertions, 12 deletions
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 17eae006d..d19dbf9aa 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
@@ -106,7 +106,7 @@ public class SimpleToscaProvider {
PfValidationResult result = serviceTemplateToWrite.validate(new PfValidationResult());
if (!result.isValid()) {
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, result.toString());
+ throw new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, result.toString());
}
new SimpleToscaServiceTemplateProvider().write(dao, serviceTemplateToWrite);
@@ -378,6 +378,8 @@ public class SimpleToscaProvider {
LOGGER.debug("->getPolicies: name={}, version={}", name, version);
JpaToscaServiceTemplate serviceTemplate = getServiceTemplate(dao);
+ serviceTemplate.setDataTypes(new JpaToscaDataTypes());
+ serviceTemplate.setPolicyTypes(new JpaToscaPolicyTypes());
if (!ToscaUtils.doPoliciesExist(serviceTemplate)) {
throw new PfModelRuntimeException(Response.Status.NOT_FOUND,
@@ -392,13 +394,10 @@ public class SimpleToscaProvider {
}
for (JpaToscaPolicy policy : serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().values()) {
- if (policy.getDerivedFrom() != null) {
- JpaToscaServiceTemplate referencedEntitiesServiceTemplate =
- getPolicyTypes(dao, policy.getDerivedFrom().getName(), policy.getDerivedFrom().getVersion());
+ JpaToscaServiceTemplate referencedEntitiesServiceTemplate =
+ getPolicyTypes(dao, policy.getType().getName(), policy.getType().getVersion());
- serviceTemplate =
- ToscaServiceTemplateUtils.addFragment(serviceTemplate, referencedEntitiesServiceTemplate);
- }
+ serviceTemplate = ToscaServiceTemplateUtils.addFragment(serviceTemplate, referencedEntitiesServiceTemplate);
}
LOGGER.debug("<-getPolicies: name={}, version={}, serviceTemplate={}", name, version, serviceTemplate);
@@ -502,7 +501,7 @@ public class SimpleToscaProvider {
if (policyType == null) {
String errorMessage =
"policy type " + policyTypeKey.getId() + " for policy " + policy.getId() + " does not exist";
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
+ throw new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, errorMessage);
}
}
@@ -531,7 +530,7 @@ public class SimpleToscaProvider {
// We should have one and only one returned entry
if (filterdPolicyTypeList.size() != 1) {
String errorMessage = "search for latest policy type " + policyTypeName + " returned more than one entry";
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
+ throw new PfModelRuntimeException(Response.Status.CONFLICT, errorMessage);
}
return (JpaToscaPolicyType) filterdPolicyTypeList.get(0);
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 aae45e5ce..6f21c1942 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
@@ -95,7 +95,7 @@ public class ToscaServiceTemplateUtils {
if (!result.isValid()) {
String message = result.toString();
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, message);
+ throw new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, message);
}
return compositeTemplate;
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
index cc0431946..b75273e5e 100644
--- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
+++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaUtils.java
@@ -147,7 +147,7 @@ public final class ToscaUtils {
final Function<JpaToscaServiceTemplate, String> checkerFunction) {
String message = checkerFunction.apply(serviceTemplate);
if (message != null) {
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, message);
+ throw new PfModelRuntimeException(Response.Status.NOT_FOUND, message);
}
}
@@ -263,7 +263,7 @@ public final class ToscaUtils {
}
if (!result.isValid()) {
- throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, result.toString());
+ throw new PfModelRuntimeException(Response.Status.NOT_ACCEPTABLE, result.toString());
}
entityTypes.getConceptMap().entrySet()