diff options
Diffstat (limited to 'models-tosca/src/main')
7 files changed, 27 insertions, 52 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 4bf014644..46f920cf4 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 @@ -276,10 +276,6 @@ public class AuthorativeToscaProvider { * @return the plain list */ private <T> List<T> asConceptList(final List<Map<String, T>> listOfMaps) { - if (listOfMaps == null) { - return Collections.emptyList(); - } - List<T> returnList = new ArrayList<>(); for (Map<String, T> conceptMap : listOfMaps) { for (T concept : conceptMap.values()) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java index cc37338e4..85b5e6df8 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyGuardPolicyMapper.java @@ -139,12 +139,6 @@ public class LegacyGuardPolicyMapper propertiesMap.put("content", content); legacyGuardPolicyOutput.setProperties(propertiesMap); - if (toscaPolicy.getProperties() == null) { - String errorMessage = "property \"Content\" not defined on TOSCA policy"; - LOGGER.warn(errorMessage); - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); - } - legacyGuardPolicyOutputMap.put(toscaPolicy.getKey().getName(), legacyGuardPolicyOutput); } 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 b6c5d3bba..7caba98d8 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 @@ -106,8 +106,8 @@ public class LegacyOperationalPolicyMapper } final String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY); - if (toscaPolicy.getProperties() == null) { - String errorMessage = "property \"Content\" not defined on TOSCA policy"; + if (content == null) { + String errorMessage = "property \"content\" not defined on TOSCA policy"; LOGGER.warn(errorMessage); throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java index fad227c34..6369f7996 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraint.java @@ -53,9 +53,7 @@ public abstract class JpaToscaConstraint } @Override - public int compareTo(JpaToscaConstraint otherConstraint) { - return 0; - } + public abstract int compareTo(JpaToscaConstraint otherConstraint); /** * Create instances of constraints of various types. diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java index 9841cbe82..632f84add 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaConstraintLogical.java @@ -73,30 +73,33 @@ public class JpaToscaConstraintLogical extends JpaToscaConstraint { public ToscaConstraint toAuthorative() { ToscaConstraint toscaConstraint = new ToscaConstraint(); + if (operation == null) { + return null; + } + switch (operation) { - case EQ: { + case EQ: toscaConstraint.setEqual(compareTo); break; - } - case GT: { + + case GT: toscaConstraint.setGreaterThan(compareTo); break; - } - case GE: { + + case GE: toscaConstraint.setGreaterOrEqual(compareTo); break; - } - case LT: { + + case LT: toscaConstraint.setLessThan(compareTo); break; - } - case LE: { + + case LE: toscaConstraint.setLessOrEqual(compareTo); break; - } - default: { + + default: // Can't happen - } } return toscaConstraint; 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 671b5ccac..3bc472243 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 @@ -129,6 +129,8 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P * @param authorativeConcept the authorative concept to copy from */ public JpaToscaPolicy(final ToscaPolicy authorativeConcept) { + super(new PfConceptKey()); + type = new PfConceptKey(); this.fromAuthorative(authorativeConcept); } @@ -215,7 +217,7 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P PfValidationResult result = super.validate(resultIn); if (type == null || type.isNullKey()) { - result.addValidationMessage(new PfValidationMessage(type, this.getClass(), ValidationResult.INVALID, + result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, "type is null or a null key")); } else { result = type.validate(result); @@ -238,7 +240,7 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P * @param result The result of validations up to now * @return the validation result */ - private PfValidationResult validateProperties(@NonNull final PfValidationResult resultIn) { + private PfValidationResult validateProperties(final PfValidationResult resultIn) { PfValidationResult result = resultIn; for (Entry<String, String> propertyEntry : properties.entrySet()) { 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 a207c4267..ef8ac05ec 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 @@ -24,14 +24,11 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import javax.ws.rs.core.Response; - import lombok.NonNull; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelException; -import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.dao.PfDao; import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicies; import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicy; @@ -40,8 +37,6 @@ import org.onap.policy.models.tosca.simple.concepts.JpaToscaPolicyTypes; import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate; import org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate; import org.onap.policy.models.tosca.utils.ToscaUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * This class provides the provision of information on TOSCA concepts in the database to callers. @@ -49,8 +44,6 @@ import org.slf4j.LoggerFactory; * @author Liam Fallon (liam.fallon@est.tech) */ public class SimpleToscaProvider { - private static final Logger LOGGER = LoggerFactory.getLogger(SimpleToscaProvider.class); - /** * Get policy types. * @@ -69,14 +62,9 @@ public class SimpleToscaProvider { // Add the policy type to the TOSCA service template List<JpaToscaPolicyType> jpaPolicyTypeList = dao.getFiltered(JpaToscaPolicyType.class, name, version); - if (jpaPolicyTypeList != null) { - serviceTemplate.getPolicyTypes().getConceptMap().putAll(asConceptMap(jpaPolicyTypeList)); - return serviceTemplate; - } else { - String errorMessage = "policy type not found: " + name + ":" + version; - LOGGER.warn(errorMessage); - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); - } + serviceTemplate.getPolicyTypes().getConceptMap().putAll(asConceptMap(jpaPolicyTypeList)); + + return serviceTemplate; } /** @@ -178,14 +166,8 @@ public class SimpleToscaProvider { // Add the policy type to the TOSCA service template List<JpaToscaPolicy> jpaPolicyList = dao.getFiltered(JpaToscaPolicy.class, name, version); - if (jpaPolicyList != null) { - serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().putAll(asConceptMap(jpaPolicyList)); - return serviceTemplate; - } else { - String errorMessage = "policy not found: " + name + ":" + version; - LOGGER.warn(errorMessage); - throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); - } + serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().putAll(asConceptMap(jpaPolicyList)); + return serviceTemplate; } /** |