/*-
* ============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.
// 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);
final Map<String, String> 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());
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
}
- final String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY);
- if (toscaPolicy.getProperties() == null) {
- String errorMessage = "property \"Content\" not defined on TOSCA policy";
+ String content = toscaPolicy.getProperties().get(CONTENT_PROPERTY);
+
+ if (content == null) {
+ String errorMessage = "property \"content\" not defined on TOSCA policy";
LOGGER.warn(errorMessage);
throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, errorMessage);
}
legacyOperationalPolicy.setContent(content);
+ String controllerName = toscaPolicy.getProperties().get(CONTROLLER_PROPERTY);
+ if (controllerName != null) {
+ legacyOperationalPolicy.setControllerName(controllerName);
+ }
+
return legacyOperationalPolicy;
}
}