aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org/openecomp/sdc/be/tosca
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/main/java/org/openecomp/sdc/be/tosca')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java51
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java72
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/exception/ToscaConversionException.java27
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAttribute.java38
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaProperty.java2
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaSchemaDefinition.java (renamed from catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/EntrySchema.java)24
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OutputConverter.java7
9 files changed, 169 insertions, 64 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
index 085c075add..a0f8d8b44f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/AttributeConverter.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.tosca;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonReader;
import java.io.StringReader;
@@ -32,7 +33,10 @@ import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.model.tosca.converters.DataTypePropertyConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter;
+import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
import org.openecomp.sdc.be.tosca.model.ToscaAttribute;
+import org.openecomp.sdc.be.tosca.model.ToscaSchemaDefinition;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.tosca.datatypes.ToscaFunctions;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -61,15 +65,16 @@ public class AttributeConverter {
}
/**
- * Converts and {@link AttributeDefinition} to a {@link ToscaAttribute}.
+ * Converts an {@link AttributeDefinition} to a {@link ToscaAttribute}.
*
* @param attributeDefinition the attribute definition to be converted
* @return the {@link ToscaAttribute} instance based on the the given {@link AttributeDefinition} instance
*/
- public ToscaAttribute convert(final AttributeDefinition attributeDefinition) {
+ public ToscaAttribute convert(final AttributeDefinition attributeDefinition) throws ToscaConversionException {
final ToscaAttribute toscaAttribute = new ToscaAttribute();
LOGGER.trace("Converting attribute '{}' from type '{}' with default value '{}'",
attributeDefinition.getName(), attributeDefinition.getType(), attributeDefinition.getDefaultValue());
+ toscaAttribute.setEntrySchema(convert(attributeDefinition.getEntry_schema()));
toscaAttribute.setType(attributeDefinition.getType());
toscaAttribute.setDescription(attributeDefinition.getDescription());
toscaAttribute.setStatus(attributeDefinition.getStatus());
@@ -87,8 +92,19 @@ public class AttributeConverter {
return toscaAttribute;
}
+ private ToscaSchemaDefinition convert(final EntrySchema entrySchema) {
+ if (entrySchema == null) {
+ return null;
+ }
+
+ final ToscaSchemaDefinition toscaSchemaDefinition = new ToscaSchemaDefinition();
+ toscaSchemaDefinition.setType(entrySchema.getType());
+ toscaSchemaDefinition.setDescription(entrySchema.getDescription());
+ return toscaSchemaDefinition;
+ }
+
private Object convertToToscaObject(final String name, final String attributeType, String value,
- final EntrySchema schemaDefinition, final boolean preserveEmptyValue) {
+ final EntrySchema schemaDefinition, final boolean preserveEmptyValue) throws ToscaConversionException {
final String innerType = schemaDefinition == null ? attributeType : schemaDefinition.getType();
LOGGER.trace("Converting attribute '{}' of type '{}', value '{}', innerType '{}'",
name, attributeType, value, innerType);
@@ -114,12 +130,10 @@ public class AttributeConverter {
isScalar = ToscaPropertyType.getTypeIfScalar(predefinedType.getType()) != null;
}
final JsonElement valueAsJson = parseToJson(value);
- if (valueAsJson.isJsonObject()) {
- final JsonObject jsonObj = valueAsJson.getAsJsonObject();
- if (jsonObj.entrySet().size() == 1 && jsonObj.has(ToscaFunctions.GET_ATTRIBUTE.getFunctionName())) {
- return ToscaMapValueConverter.getInstance().handleComplexJsonValue(valueAsJson);
- }
+ if (isValueGetAttribute(valueAsJson)) {
+ return ToscaMapValueConverter.getInstance().handleComplexJsonValue(valueAsJson.getAsJsonObject());
}
+
//if it has a converter
if (predefinedType != null && predefinedType.getValueConverter() != null) {
LOGGER.trace("It's well defined type. convert it");
@@ -134,9 +148,16 @@ public class AttributeConverter {
return toscaMapValueConverter.convertDataTypeToToscaObject(
innerType, dataTypes, null, false, valueAsJson, preserveEmptyValue);
+ } catch (final JsonParseException e) {
+ final String errorMsg = "Failed to parse json value";
+ LOGGER.error(EcompLoggerErrorCode.SCHEMA_ERROR, "Attribute Converter",
+ errorMsg, e);
+ throw new ToscaConversionException(errorMsg, e);
} catch (final Exception e) {
- LOGGER.debug("convertToToscaValue failed to parse json value :", e);
- return null;
+ final String errorMsg = "Unexpected error occurred while converting attribute value to TOSCA";
+ LOGGER.error(EcompLoggerErrorCode.UNKNOWN_ERROR, "Attribute Converter",
+ errorMsg, e);
+ throw new ToscaConversionException(errorMsg, e);
}
}
@@ -148,8 +169,16 @@ public class AttributeConverter {
return new JsonParser().parse(jsonReader);
}
+ private boolean isValueGetAttribute(final JsonElement valueAsJson) {
+ if (!valueAsJson.isJsonObject()) {
+ return false;
+ }
+ final JsonObject jsonObj = valueAsJson.getAsJsonObject();
+ return jsonObj.entrySet().size() == 1 && jsonObj.has(ToscaFunctions.GET_ATTRIBUTE.getFunctionName());
+ }
+
private String getTypeDefaultValue(final String attributeType) {
return DataTypePropertyConverter.getInstance().getDataTypePropertiesDefaultValuesRec(attributeType, dataTypes);
}
-} \ No newline at end of file
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
index 4c4f19bb87..59b859dae2 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java
@@ -44,7 +44,7 @@ import org.openecomp.sdc.be.model.tosca.converters.DataTypePropertyConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaMapValueConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaValueBaseConverter;
import org.openecomp.sdc.be.model.tosca.converters.ToscaValueConverter;
-import org.openecomp.sdc.be.tosca.model.EntrySchema;
+import org.openecomp.sdc.be.tosca.model.ToscaSchemaDefinition;
import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
import org.openecomp.sdc.be.tosca.model.ToscaProperty;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -86,10 +86,10 @@ public class PropertyConvertor {
log.trace("try to convert property {} from type {} with default value [{}]", property.getName(), property.getType(), property.getDefaultValue());
SchemaDefinition schema = property.getSchema();
if (schema != null && schema.getProperty() != null && schema.getProperty().getType() != null && !schema.getProperty().getType().isEmpty()) {
- EntrySchema eschema = new EntrySchema();
- eschema.setType(schema.getProperty().getType());
- eschema.setDescription(schema.getProperty().getDescription());
- prop.setEntry_schema(eschema);
+ final ToscaSchemaDefinition toscaSchemaDefinition = new ToscaSchemaDefinition();
+ toscaSchemaDefinition.setType(schema.getProperty().getType());
+ toscaSchemaDefinition.setDescription(schema.getProperty().getDescription());
+ prop.setEntry_schema(toscaSchemaDefinition);
}
String defaultValue = property.getDefaultValue();
if(Objects.isNull(defaultValue)) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 0459b5d1c6..1f0270fee9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -28,9 +28,7 @@ import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_ATTRIBUTE;
import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_INPUT;
import static org.openecomp.sdc.tosca.datatypes.ToscaFunctions.GET_PROPERTY;
-import com.fasterxml.jackson.databind.ObjectMapper;
import fj.data.Either;
-import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -102,9 +100,11 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.tosca.PropertyConvertor.PropertyType;
import org.openecomp.sdc.be.tosca.builder.ToscaRelationshipBuilder;
+import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
import org.openecomp.sdc.be.tosca.model.CapabilityFilter;
import org.openecomp.sdc.be.tosca.model.NodeFilter;
import org.openecomp.sdc.be.tosca.model.SubstitutionMapping;
+import org.openecomp.sdc.be.tosca.model.ToscaAttribute;
import org.openecomp.sdc.be.tosca.model.ToscaCapability;
import org.openecomp.sdc.be.tosca.model.ToscaDataType;
import org.openecomp.sdc.be.tosca.model.ToscaGroupTemplate;
@@ -122,6 +122,7 @@ import org.openecomp.sdc.be.tosca.model.ToscaTopolgyTemplate;
import org.openecomp.sdc.be.tosca.utils.ForwardingPathToscaUtil;
import org.openecomp.sdc.be.tosca.utils.InputConverter;
import org.openecomp.sdc.be.tosca.utils.OutputConverter;
+import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.yaml.snakeyaml.DumperOptions;
@@ -324,7 +325,15 @@ public class ToscaExportHandler {
topologyTemplate.setInputs(inputs);
}
- final Map<String, ToscaProperty> outputs = outputConverter.convert(component.getOutputs(), dataTypes);
+ final Map<String, ToscaProperty> outputs;
+ try {
+ outputs = outputConverter.convert(component.getOutputs(), dataTypes);
+ } catch (final ToscaConversionException e) {
+ log.error(EcompLoggerErrorCode.SCHEMA_ERROR, ToscaExportHandler.class.getName(),
+ "Could not parse component '{}' outputs. Component unique id '{}'.",
+ new Object[]{component.getName(), component.getUniqueId(), e});
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
if (!outputs.isEmpty()) {
topologyTemplate.setOutputs(outputs);
}
@@ -748,6 +757,18 @@ public class ToscaExportHandler {
.addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
addInputsToProperties(dataTypes, inputDef, mergedProperties);
+ final Map<String, ToscaAttribute> toscaAttributeMap;
+ try {
+ toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
+ } catch (final ToscaConversionException e) {
+ log.error(EcompLoggerErrorCode.SCHEMA_ERROR, ToscaExportHandler.class.getName(),
+ "Could not parse component '{}' attributes. Component unique id '{}'.",
+ new Object[]{component.getName(), component.getUniqueId(), e});
+ return Either.right(ToscaError.GENERAL_ERROR);
+ }
+ if (!toscaAttributeMap.isEmpty()) {
+ toscaNodeType.setAttributes(toscaAttributeMap);
+ }
if (CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
Map<String, ToscaProperty> convertedProperties = properties.stream()
@@ -790,6 +811,19 @@ public class ToscaExportHandler {
return convertReqCapAndTypeName(componentsCache, component, toscaNode, nodeTypes, toscaNodeType, dataTypes);
}
+ private Map<String, ToscaAttribute> convertToToscaAttributes(final List<AttributeDefinition> attributeList,
+ final Map<String, DataTypeDefinition> dataTypes) throws ToscaConversionException {
+ if (CollectionUtils.isEmpty(attributeList)) {
+ return Collections.emptyMap();
+ }
+ final AttributeConverter attributeConverter = new AttributeConverter(dataTypes);
+ final Map<String, ToscaAttribute> toscaAttributeMap = new HashMap<>();
+ for (final AttributeDefinition attributeDefinition : attributeList) {
+ toscaAttributeMap.put(attributeDefinition.getName(), attributeConverter.convert(attributeDefinition));
+ }
+ return toscaAttributeMap;
+ }
+
private Either<ToscaTemplate, ToscaError> convertReqCapAndTypeName(Map<String, Component> componentsCache,
Component component, ToscaTemplate toscaNode,
Map<String, ToscaNodeType> nodeTypes,
@@ -1050,31 +1084,9 @@ public class ToscaExportHandler {
: NATIVE_ROOT;
toscaNodeType.setDerived_from(derivedFrom);
}
- if (component instanceof Resource) {
- final List<AttributeDefinition> attributes = ((Resource) component).getAttributes();
- if (CollectionUtils.isNotEmpty(attributes)) {
- final Map<String, Object> attributeDataDefinitionMap = new HashMap<>();
- attributes.forEach(attributeDataDefinition ->
- buildAttributeData(attributeDataDefinition, attributeDataDefinitionMap));
-
- toscaNodeType.setAttributes(attributeDataDefinitionMap);
- }
- }
return toscaNodeType;
}
- private void buildAttributeData(final AttributeDefinition originalAttributeDefinition,
- final Map<String, Object> attributeDataDefinitionMap) {
-
- attributeDataDefinitionMap.put(originalAttributeDefinition.getName(),
- new ObjectMapper().convertValue(new org.onap.sdc.tosca.datatypes.model.AttributeDefinition(
- originalAttributeDefinition.getType(),
- originalAttributeDefinition.getDescription(),
- originalAttributeDefinition.get_default(),
- originalAttributeDefinition.getStatus(),
- originalAttributeDefinition.getEntry_schema()), Object.class));
- }
-
private Either<Map<String, Object>, ToscaError> createProxyInterfaceTypes(Component container) {
Map<String, Object> proxyInterfaceTypes = new HashMap<>();
@@ -1679,12 +1691,22 @@ public class ToscaExportHandler {
CustomRepresenter() {
super();
this.representers.put(ToscaPropertyAssignment.class, new RepresentToscaPropertyAssignment());
+ this.representers.put(ToscaAttribute.class, new RepresentToscaAttribute());
// null representer is exceptional and it is stored as an instance
// variable.
this.nullRepresenter = new RepresentNull();
}
+ private class RepresentToscaAttribute implements Represent {
+
+ @Override
+ public Node representData(Object data) {
+ final ToscaAttribute toscaAttribute = (ToscaAttribute) data;
+ return represent(toscaAttribute.asToscaMap());
+ }
+ }
+
private class RepresentToscaPropertyAssignment implements Represent {
public Node representData(Object data) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/exception/ToscaConversionException.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/exception/ToscaConversionException.java
new file mode 100644
index 0000000000..2d37a35a96
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/exception/ToscaConversionException.java
@@ -0,0 +1,27 @@
+/*
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.be.tosca.exception;
+
+public class ToscaConversionException extends Exception {
+
+ public ToscaConversionException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAttribute.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAttribute.java
index 891347d191..ea56e60a17 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAttribute.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaAttribute.java
@@ -19,9 +19,12 @@
package org.openecomp.sdc.be.tosca.model;
+import java.util.LinkedHashMap;
+import java.util.Map;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
/**
* Represents a TOSCA Attribute Definition (see TOSCA 1.3, Section 3.6.12 Attribute definition)
@@ -42,6 +45,12 @@ public class ToscaAttribute {
private String description;
@Getter
@Setter
+ private ToscaSchemaDefinition keySchema;
+ @Getter
+ @Setter
+ private ToscaSchemaDefinition entrySchema;
+ @Getter
+ @Setter
private String status;
public Object getDefault() {
@@ -52,4 +61,33 @@ public class ToscaAttribute {
this.defaultValue = defaultValue;
}
+ /**
+ * Converts this object to Map, ignoring null fields. The entries of the map are based on the TOSCA Attribute Definition.
+ *
+ * @return a Map representing the TOSCA Attribute Definition.
+ */
+ public Map<String, Object> asToscaMap() {
+ final Map<String, Object> toscaAttributeAsMap = new LinkedHashMap<>();
+ if (getType() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.TYPE.getElementName(), getType());
+ }
+ if (getDescription() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.DESCRIPTION.getElementName(), getDescription());
+ }
+ if (getKeySchema() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.KEY_SCHEMA.getElementName(), getKeySchema());
+ }
+ if (getEntrySchema() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.ENTRY_SCHEMA.getElementName(), getEntrySchema());
+ }
+ if (getDefault() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.DEFAULT.getElementName(), getDefault());
+ }
+ if (getStatus() != null) {
+ toscaAttributeAsMap.put(ToscaTagNamesEnum.STATUS.getElementName(), getStatus());
+ }
+
+ return toscaAttributeAsMap;
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
index 856c430f65..c43486fab8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java
@@ -40,6 +40,6 @@ public class ToscaNodeType {
private Map<String, ToscaCapability> capabilities;
private List<Map<String, ToscaRequirement>> requirements;
- private Map<String, Object> attributes;
+ private Map<String, ToscaAttribute> attributes;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaProperty.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaProperty.java
index 7ebb2cb00d..fb5c544511 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaProperty.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaProperty.java
@@ -44,7 +44,7 @@ public class ToscaProperty {
private Boolean required;
@Getter
@Setter
- private EntrySchema entry_schema;
+ private ToscaSchemaDefinition entry_schema;
@Getter
@Setter
private List<ToscaPropertyConstraint> constraints;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/EntrySchema.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaSchemaDefinition.java
index f1a7dcb9e5..d02e9da6bd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/EntrySchema.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaSchemaDefinition.java
@@ -20,24 +20,12 @@
package org.openecomp.sdc.be.tosca.model;
-public class EntrySchema {
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class ToscaSchemaDefinition {
private String type;
private String description;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OutputConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OutputConverter.java
index 85400a747a..1e7fc81a3b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OutputConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/OutputConverter.java
@@ -27,6 +27,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.OutputDefinition;
import org.openecomp.sdc.be.tosca.AttributeConverter;
+import org.openecomp.sdc.be.tosca.exception.ToscaConversionException;
import org.openecomp.sdc.be.tosca.model.ToscaAttribute;
import org.openecomp.sdc.be.tosca.model.ToscaOutput;
import org.openecomp.sdc.be.tosca.model.ToscaProperty;
@@ -45,17 +46,17 @@ public class OutputConverter {
}
public Map<String, ToscaProperty> convert(final List<OutputDefinition> outputDefinitionList,
- final Map<String, DataTypeDefinition> dataTypes) {
+ final Map<String, DataTypeDefinition> dataTypes) throws ToscaConversionException {
final AttributeConverter attributeConverter = this.attributeConverterProvider.getObject(dataTypes);
final Map<String, ToscaProperty> outputMap = new HashMap<>();
if (CollectionUtils.isEmpty(outputDefinitionList)) {
return Collections.emptyMap();
}
- outputDefinitionList.forEach(outputDefinition -> {
+ for (final OutputDefinition outputDefinition : outputDefinitionList) {
final ToscaAttribute toscaAttribute = attributeConverter.convert(outputDefinition);
final ToscaProperty toscaProperty = new ToscaOutput(toscaAttribute);
outputMap.put(outputDefinition.getName(), toscaProperty);
- });
+ }
return outputMap;
}
}