X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=models-tosca%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fmodels%2Ftosca%2Flegacy%2Fmapping%2FLegacyOperationalPolicyMapper.java;h=881a5fadd6268e2574055166e161d2cef62c50fc;hb=2bda454c5a0036a8fa5af120a90a0c1f94e76b31;hp=7caba98d815d8791d758a0bc597589e513b13d70;hpb=0f268c6715615c578222d77a806c81e6e7fdaadd;p=policy%2Fmodels.git 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 7caba98d8..881a5fadd 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 @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,6 +48,7 @@ public class LegacyOperationalPolicyMapper // Property name for the operational policy content private static final String CONTENT_PROPERTY = "content"; + private static final String CONTROLLER_PROPERTY = "controllerName"; private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicyMapper.class); @@ -69,9 +71,12 @@ public class LegacyOperationalPolicyMapper final Map propertyMap = new HashMap<>(); toscaPolicy.setProperties(propertyMap); toscaPolicy.getProperties().put(CONTENT_PROPERTY, legacyOperationalPolicy.getContent()); + if (legacyOperationalPolicy.getControllerName() != null) { + toscaPolicy.getProperties().put(CONTROLLER_PROPERTY, legacyOperationalPolicy.getControllerName()); + } final JpaToscaServiceTemplate serviceTemplate = new JpaToscaServiceTemplate(); - serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0"); + serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_1_0"); serviceTemplate.setTopologyTemplate(new JpaToscaTopologyTemplate()); @@ -105,7 +110,8 @@ public class LegacyOperationalPolicyMapper throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage); } - final String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY); + String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY); + if (content == null) { String errorMessage = "property \"content\" not defined on TOSCA policy"; LOGGER.warn(errorMessage); @@ -114,6 +120,11 @@ public class LegacyOperationalPolicyMapper legacyOperationalPolicy.setContent(content); + String controllerName = toscaPolicy.getProperties().get(CONTROLLER_PROPERTY); + if (controllerName != null) { + legacyOperationalPolicy.setControllerName(controllerName); + } + return legacyOperationalPolicy; } }