From 0f7c0e57f391e1c9e25c174ffb0b7bda370b713e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 22 Oct 2019 21:56:25 -0700 Subject: changes in decoder as per new infra APIs Change-Id: Ie2ebfa16bc6b08dc54d60ef276f52e9ea2c91b1f Issue-ID: POLICY-1869 Signed-off-by: Liang Ding --- .../pdpx/PolicyDecoderCsarPdpxLifecycleApi.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'plugins/reception-plugins/src/main/java/org/onap') diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java index eadca94d..8cfc6857 100644 --- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java +++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpxLifecycleApi.java @@ -23,7 +23,9 @@ package org.onap.policy.distribution.reception.decoding.pdpx; import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.coder.StandardCoder; @@ -31,7 +33,12 @@ import org.onap.policy.distribution.model.Csar; import org.onap.policy.distribution.model.PolicyInput; import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; +import org.onap.policy.models.tosca.authorative.concepts.ToscaEntityKey; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory; import org.onap.sdc.toscaparser.api.NodeTemplate; @@ -47,6 +54,14 @@ public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder decode(final Csar csar) throws PolicyDecodingException { final List entities = new ArrayList<>(); @@ -61,7 +76,22 @@ public class PolicyDecoderCsarPdpxLifecycleApi implements PolicyDecoder props = new LinkedHashMap<>(); + props.put(TOSCA_POLICY_SCOPE, content.getScope()); + props.put(TOSCA_POLICY_SERVICES, content.getServices()); + props.put(TOSCA_POLICY_RESOURCES, content.getResources()); + props.put(TOSCA_POLICY_IDENTITY, content.getIdentity()); + props.put(TOSCA_POLICY_FLAVORFEATURES, content.getFlavorFeatures()); + ToscaPolicy policy = new ToscaPolicy(); + policy.setProperties(props); + Map map = new LinkedHashMap<>(); + String type = content.getPolicyType(); + map.put(type, policy); + List> policies = new ArrayList<>(); + policies.add(map); + ToscaTopologyTemplate topologyTemplate = new ToscaTopologyTemplate(); + topologyTemplate.setPolicies(policies); + entity.setToscaTopologyTemplate(topologyTemplate); entities.add(entity); } } -- cgit 1.2.3-korg