aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java/org
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2020-07-06 17:08:08 +0100
committerChristophe Closset <christophe.closset@intl.att.com>2020-09-02 06:59:38 +0000
commit1ec3dde2067e0181faa8e5098219c93126638aef (patch)
treef09dced5babfa16da8653c5bb464172f5d4ac9c3 /catalog-be/src/main/java/org
parent930ed2515529bd7ff054b083816587b6d46f56b5 (diff)
Support for defining attributes on a node_type
This commit aims to add support of attributes on node_type. It is first of several commits to cover all support. It includes: - new classes: AttributeDefinition ComponentInstanceAttribute IAttributeInputCommon IAttributeInputCommon AttributeDataDefinition MapAttributesDataDefinition - support of 'Import of VFC with attributes' - TCs fix for changed code Next commit(s) will cover: - support of "Onboarding packages with attributes" - support of "Download TOSCA Artifacts - Tosca Model" - support of "Import onboarded VSP" Change-Id: I0167abc58e8aeef3d631833cc323e466f8e71492 Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3200
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java47
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java19
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java32
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java98
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java123
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java535
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java30
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeType.java70
10 files changed, 522 insertions, 450 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index c0f08b0bb3..ef82eba0a4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -23,9 +23,10 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.DataTypeDefinition;
-import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ArtifactsOperations;
import org.openecomp.sdc.be.model.jsonjanusgraph.operations.InterfaceOperation;
@@ -59,7 +60,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
private static final String UPDATE_ATTRIBUTE = "UpdateAttribute";
private static final String DELETE_ATTRIBUTE = "DeleteAttribute";
- private static final Logger log = Logger.getLogger(AttributeBusinessLogic.class.getName());
+ private static final Logger log = Logger.getLogger(AttributeBusinessLogic.class);
private static final String FAILED_TO_LOCK_COMPONENT_ERROR = "Failed to lock component {}. Error - {}";
@Autowired
@@ -82,8 +83,8 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return AttributeDefinition if created successfully Or ResponseFormat
*/
- public Either<PropertyDefinition, ResponseFormat> createAttribute(String resourceId, PropertyDefinition newAttributeDef, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ public Either<AttributeDataDefinition, ResponseFormat> createAttribute(String resourceId, AttributeDataDefinition newAttributeDef, String userId) {
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
validateUserExists(userId);
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
@@ -112,17 +113,17 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate property default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newAttributeDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- handleDefaultValue(newAttributeDef, eitherAllDataTypes);
+ handleDefaultValue((AttributeDefinition)newAttributeDef, eitherAllDataTypes);
// add the new attribute to resource on graph
// need to get StorageOpaerationStatus and convert to ActionStatus from
// componentsUtils
- Either<PropertyDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
+ Either<AttributeDataDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
if (either.isRight()) {
result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()), resource.getName()));
return result;
@@ -137,7 +138,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
- private boolean isAttributeExist(List<PropertyDefinition> attributes, String resourceUid, String propertyName) {
+ private boolean isAttributeExist(List<AttributeDataDefinition> attributes, String resourceUid, String propertyName) {
boolean isExist = false;
if (attributes != null) {
isExist = attributes.stream().anyMatch(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getParentUniqueId(), resourceUid));
@@ -152,7 +153,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDataDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
validateUserExists(userId);
@@ -163,15 +164,14 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
Resource resource = status.left().value();
- List<PropertyDefinition> attributes = resource.getAttributes();
+ List<AttributeDataDefinition> attributes = resource.getAttributes();
if (attributes == null) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
} else {
// verify attribute exist in resource
- Optional<PropertyDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
- return optionalAtt.<Either<PropertyDefinition, ResponseFormat>>map(Either::left).orElseGet(() -> Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
+ Optional<AttributeDataDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && resourceId.equals(att.getParentUniqueId())).findAny();
+ return optionalAtt.<Either<AttributeDataDefinition, ResponseFormat>>map(Either::left).orElseGet(() -> Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, "")));
}
-
}
/**
@@ -183,8 +183,8 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, PropertyDefinition newAttDef, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ public Either<AttributeDataDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, AttributeDataDefinition newAttDef, String userId) {
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
if (lockResult != StorageOperationStatus.OK) {
@@ -206,27 +206,26 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<PropertyDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
return Either.right(eitherAttribute.right().value());
}
Map<String, DataTypeDefinition> eitherAllDataTypes = getAllDataTypes(applicationDataTypeCache);
// validate attribute default values
- Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newAttDef, eitherAllDataTypes);
+ Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue((AttributeDefinition)newAttDef, eitherAllDataTypes);
if (defaultValuesValidation.isRight()) {
return Either.right(defaultValuesValidation.right().value());
}
- // add the new property to resource on graph
- StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty(newAttDef, eitherAllDataTypes);
+ // add the new property to resource on graph
+ StorageOperationStatus validateAndUpdateAttribute = propertyOperation.validateAndUpdateProperty((AttributeDefinition)newAttDef, eitherAllDataTypes);
if (validateAndUpdateAttribute != StorageOperationStatus.OK) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, validateAndUpdateAttribute);
result = Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(validateAndUpdateAttribute), resource.getName()));
}
-
- Either<PropertyDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
+ Either<AttributeDataDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
if (eitherAttUpdate.isRight()) {
log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, eitherAttUpdate.right().value());
@@ -251,9 +250,9 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
* @param userId
* @return
*/
- public Either<PropertyDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
+ public Either<AttributeDataDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
- Either<PropertyDefinition, ResponseFormat> result = null;
+ Either<AttributeDataDefinition, ResponseFormat> result = null;
validateUserExists(userId);
@@ -278,7 +277,7 @@ public class AttributeBusinessLogic extends BaseBusinessLogic {
}
// verify attribute exist in resource
- Either<PropertyDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
if (eitherAttributeExist.isRight()) {
return Either.right(eitherAttributeExist.right().value());
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index 4ac3815a2b..ba1500c9be 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -49,6 +49,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.utils.MapUtil;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
@@ -58,6 +59,7 @@ import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.facade.operations.CatalogOperation;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapReqDef;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
@@ -879,7 +881,7 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
clonedComponent.setDerivedFromGenericVersion(currentGenericVersion);
}
- private <T extends PropertyDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
+ private <T extends ToscaDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
Map<String, T> currentMap = ToscaDataDefinition.listToMapByName(currentList);
Map<String, T> upgradedMap = ToscaDataDefinition.listToMapByName(upgradedList);
return ToscaDataDefinition.mergeDataMaps(upgradedMap, currentMap, true);
@@ -888,15 +890,16 @@ public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
private boolean shouldUpgradeNodeType(Component componentToCheckOut, Resource latestGeneric){
List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();
- Either<Map<String, PropertyDefinition>, String> validMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
- if (validMerge.isRight()) {
- log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+ Either<Map<String, PropertyDefinition>, String> validPropertiesMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
+ if (validPropertiesMerge.isRight()) {
+ log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validPropertiesMerge.right().value());
return false;
}
- List<PropertyDefinition> genericTypeAttributes = latestGeneric.getAttributes();
- validMerge = validateNoConflictingProperties(genericTypeAttributes, ((Resource)componentToCheckOut).getAttributes());
- if (validMerge.isRight()) {
- log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+ List<AttributeDataDefinition> genericTypeAttributes = latestGeneric.getAttributes();
+ final Either<Map<String, AttributeDataDefinition>, String> validAttributesMerge = validateNoConflictingProperties(
+ genericTypeAttributes, ((Resource) componentToCheckOut).getAttributes());
+ if (validAttributesMerge.isRight()) {
+ log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validAttributesMerge.right().value());
return false;
}
return true;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index b0c9b308ab..e616ff87d3 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -82,6 +82,7 @@ import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceInput;
import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
@@ -133,7 +134,7 @@ import org.springframework.beans.factory.annotation.Autowired;
@org.springframework.stereotype.Component
public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
- private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class.getName());
+ private static final Logger log = Logger.getLogger(ComponentInstanceBusinessLogic.class);
private static final String VF_MODULE = "org.openecomp.groups.VfModule";
private static final String TRY_TO_CREATE_ENTRY_ON_GRAPH = "Try to create entry on graph";
private static final String CLOUD_SPECIFIC_FIXED_KEY_WORD = "cloudtech";
@@ -2885,14 +2886,14 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
log.info("start to copy component instance with attributes");
- List<ComponentInstanceProperty> sourceAttributeList = null;
+ List<ComponentInstanceAttribute> sourceAttributeList = null;
if (sourceComponent.getComponentInstancesAttributes() != null
&& sourceComponent.getComponentInstancesAttributes().get(sourceComponentInstanceId) != null) {
sourceAttributeList = sourceComponent.getComponentInstancesAttributes().get(sourceComponentInstanceId);
log.info("sourceAttributes {}");
}
- List<ComponentInstanceProperty> destAttributeList = null;
+ List<ComponentInstanceAttribute> destAttributeList = null;
if (destComponent.getComponentInstancesAttributes() != null
&& destComponent.getComponentInstancesAttributes().get(destComponentInstanceId) != null) {
destAttributeList = destComponent.getComponentInstancesAttributes().get(destComponentInstanceId);
@@ -2901,18 +2902,18 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
if (null != sourceAttributeList && null != destAttributeList) {
log.info("set attribute");
- for (ComponentInstanceProperty sourceAttribute : sourceAttributeList) {
+ for (ComponentInstanceAttribute sourceAttribute : sourceAttributeList) {
String sourceAttributeName = sourceAttribute.getName();
- for (ComponentInstanceProperty destAttribute : destAttributeList) {
+ for (ComponentInstanceAttribute destAttribute : destAttributeList) {
if (sourceAttributeName.equals(destAttribute.getName())) {
- if (sourceAttribute.getValue() != null && !sourceAttribute.getValue().isEmpty()) {
+// if (sourceAttribute.getValue() != null && !sourceAttribute.getValue().isEmpty()) {
log.debug("Start to copy the attribute exists {}", sourceAttributeName);
sourceAttribute.setUniqueId(
UniqueIdBuilder.buildResourceInstanceUniuqeId(
"attribute" , destComponentInstanceId.split("\\.")[1] , sourceAttributeName));
- Either<ComponentInstanceProperty, ResponseFormat> updateAttributeValueEither =
+ Either<ComponentInstanceAttribute, ResponseFormat> updateAttributeValueEither =
createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum.SERVICE,
destComponent.getUniqueId(), destComponentInstanceId, sourceAttribute,
userId);
@@ -2923,7 +2924,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
"Failed to paste component instance to the canvas, attribute copy"));
}
break;
- }
+// }
}
}
}
@@ -2932,13 +2933,13 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
return Either.left(COPY_COMPONENT_INSTANCE_OK);
}
- private Either<ComponentInstanceProperty, ResponseFormat> createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum componentTypeEnum,
+ private Either<ComponentInstanceAttribute, ResponseFormat> createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum componentTypeEnum,
String componentId,
String resourceInstanceId,
- ComponentInstanceProperty attribute,
+ ComponentInstanceAttribute attribute,
String userId) {
- Either<ComponentInstanceProperty, ResponseFormat> resultOp = null;
+ Either<ComponentInstanceAttribute, ResponseFormat> resultOp = null;
validateUserExists(userId);
@@ -2989,10 +2990,8 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
}
- List<ComponentInstanceProperty> instanceAttributes = containerComponent.
- getComponentInstancesAttributes().get(resourceInstanceId);
- Optional<ComponentInstanceProperty> instanceAttribute =
- instanceAttributes.stream().filter(p -> p.getUniqueId().equals(attribute.getUniqueId())).findAny();
+ List<ComponentInstanceAttribute> instanceAttributes = containerComponent.getComponentInstancesAttributes().get(resourceInstanceId);
+ Optional<ComponentInstanceAttribute> instanceAttribute = instanceAttributes.stream().filter(p -> p.getUniqueId().equals(attribute.getUniqueId())).findAny();
StorageOperationStatus status;
if (instanceAttribute.isPresent()) {
@@ -3024,9 +3023,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
}
resultOp = Either.left(attribute);
return resultOp;
-
-
-
}
private Either<String, ResponseFormat> updateComponentInstanceProperty(String containerComponentId,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index cc6b359098..01698fa662 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -27,15 +27,19 @@ import com.google.gson.reflect.TypeToken;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.tinkerpop.gremlin.structure.T;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.Annotation;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.AnnotationTypeDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.HeatParameterDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -86,7 +90,7 @@ public final class ImportUtils {
private static final CustomResolver customResolver = new CustomResolver();
private static final Yaml strictYamlLoader = new YamlLoader().getStrictYamlLoader();
- protected static ComponentsUtils componentsUtils;
+ private static ComponentsUtils componentsUtils;
private static final Logger log = Logger.getLogger(ImportUtils.class);
@@ -95,7 +99,7 @@ public final class ImportUtils {
@Autowired
public static void setComponentsUtils(ComponentsUtils componentsUtils) {
- ImportUtils.componentsUtils = componentsUtils;
+ componentsUtils = componentsUtils;
}
private static class CustomResolver extends Resolver {
@@ -112,7 +116,6 @@ public final class ImportUtils {
}
}
-
private static void buildMap(Map<String, Object> output, Map<String, Object> map) {
for (Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
@@ -186,9 +189,9 @@ public final class ImportUtils {
@SuppressWarnings("unchecked")
private static void handleElementNameNotFound(String elementName, Object elementValue, ToscaElementTypeEnum elementType, List<Object> returnedList) {
if (elementValue instanceof Map) {
- ImportUtils.findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
+ findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
} else if (elementValue instanceof List) {
- ImportUtils.findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
+ findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
}
}
@@ -209,13 +212,13 @@ public final class ImportUtils {
if (elementType == ToscaElementTypeEnum.MAP || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
- ImportUtils.findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
+ findToscaElements((Map<String, Object>) elementValue, elementName, elementType, returnedList);
} else if (elementValue instanceof List) {
if (elementType == ToscaElementTypeEnum.LIST || elementType == ToscaElementTypeEnum.ALL) {
returnedList.add(elementValue);
}
- ImportUtils.findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
+ findAllToscaElementsInList((List<Object>) elementValue, elementName, elementType, returnedList);
}
// For Integer, Double etc...
@@ -230,7 +233,7 @@ public final class ImportUtils {
public static Either<Object, ResultStatusEnum> findToscaElement(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementName, ToscaElementTypeEnum elementType) {
List<Object> foundElements = new ArrayList<>();
- ImportUtils.findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
+ findToscaElements(toscaJson, elementName.getElementName(), elementType, foundElements);
if (!isEmpty(foundElements)) {
return Either.left(foundElements.get(0));
}
@@ -398,24 +401,21 @@ public final class ImportUtils {
return propertyDef;
}
-
private static void setJsonStringField(Map<String, Object> propertyValue, ToscaTagNamesEnum elementName, String type, Consumer<String> setter) {
- Either<Object, ResultStatusEnum> eitherValue = ImportUtils.findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL);
+ Either<Object, ResultStatusEnum> eitherValue = findToscaElement(propertyValue, elementName, ToscaElementTypeEnum.ALL);
if (eitherValue.isLeft()) {
String propertyJsonStringValue = getPropertyJsonStringValue(eitherValue.left().value(), type);
setter.accept(propertyJsonStringValue);
}
}
-
-
public static Annotation createModuleAnnotation(Map<String, Object> annotationMap, AnnotationTypeOperations annotationTypeOperations) {
String parsedAnnotationType = findFirstToscaStringElement(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE).left().value();
AnnotationTypeDefinition annotationTypeObject = annotationTypeOperations.getLatestType(parsedAnnotationType);
if (annotationTypeObject != null) {
Annotation annotation = new Annotation();
- ImportUtils.setField(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE, annotation::setType);
- ImportUtils.setField(annotationMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, annotation::setDescription);
+ setField(annotationMap, TypeUtils.ToscaTagNamesEnum.TYPE, annotation::setType);
+ setField(annotationMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, annotation::setDescription);
Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = getProperties(annotationMap);
modifyPropertiesKeysToProperForm(properties, annotation);
return annotation;
@@ -454,26 +454,25 @@ public final class ImportUtils {
public static InputDefinition createModuleInput(Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations) {
InputDefinition inputDef = new InputDefinition();
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType);
- ImportUtils.setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req)));
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, inputDef::setDescription);
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.TYPE, inputDef::setType);
+ setFieldBoolean(inputValue, ToscaTagNamesEnum.REQUIRED, req -> inputDef.setRequired(Boolean.parseBoolean(req)));
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, inputDef::setDescription);
setJsonStringField(inputValue, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, inputDef.getType(), inputDef::setDefaultValue);
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass)));
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus);
- ImportUtils.setField(inputValue, TypeUtils.ToscaTagNamesEnum.LABEL, inputDef::setLabel);
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.HIDDEN, hidden -> inputDef.setHidden(Boolean.parseBoolean(hidden)));
- ImportUtils.setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IMMUTABLE, immutable -> inputDef.setImmutable(Boolean.parseBoolean(immutable)));
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> inputDef.setPassword(Boolean.parseBoolean(pass)));
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.STATUS, inputDef::setStatus);
+ setField(inputValue, TypeUtils.ToscaTagNamesEnum.LABEL, inputDef::setLabel);
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.HIDDEN, hidden -> inputDef.setHidden(Boolean.parseBoolean(hidden)));
+ setFieldBoolean(inputValue, TypeUtils.ToscaTagNamesEnum.IMMUTABLE, immutable -> inputDef.setImmutable(Boolean.parseBoolean(immutable)));
- ImportUtils.setScheme(inputValue, inputDef);
- ImportUtils.setPropertyConstraints(inputValue, inputDef);
+ setScheme(inputValue, inputDef);
+ setPropertyConstraints(inputValue, inputDef);
return parseAnnotationsAndAddItToInput(inputDef, inputValue, annotationTypeOperations);
}
-
public static InputDefinition parseAnnotationsAndAddItToInput(InputDefinition inputDef, Map<String, Object> inputValue, AnnotationTypeOperations annotationTypeOperations){
Function<String, Annotation> elementGenByName = ImportUtils::createAnnotation;
Function<Map<String, Object>, Annotation> func = annotation -> createModuleAnnotation(annotation, annotationTypeOperations);
@@ -489,30 +488,29 @@ public final class ImportUtils {
return inputDef;
}
+ public static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) {
- public static PropertyDefinition createModuleAttribute(Map<String, Object> attributeMap) {
-
- PropertyDefinition attributeDef = new PropertyDefinition();
+ AttributeDefinition attributeDef = new AttributeDefinition();
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.TYPE, attributeDef::setType);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.DESCRIPTION, attributeDef::setDescription);
setField(attributeMap, TypeUtils.ToscaTagNamesEnum.STATUS, attributeDef::setStatus);
- setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::setDefaultValue);
- setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.VALUE, attributeDef.getType(), attributeDef::setValue);
+ setJsonStringField(attributeMap, TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE, attributeDef.getType(), attributeDef::set_default);
setScheme(attributeMap, attributeDef);
return attributeDef;
}
- private static void setScheme(Map<String, Object> propertyValue, PropertyDefinition propertyDefinition) {
+ private static void setScheme(Map<String, Object> propertyValue,
+ ToscaDataDefinition toscaDataDefinition) {
Either<Object, ResultStatusEnum> schemaElementRes = findSchemaElement(propertyValue);
if (schemaElementRes.isLeft()) {
SchemaDefinition schemaDef = getSchema(schemaElementRes.left().value());
- propertyDefinition.setSchema(schemaDef);
+ toscaDataDefinition.setSchema(schemaDef);
}
}
- private static Either<Object,ResultStatusEnum> findSchemaElement(Map<String, Object> propertyValue) {
+ private static Either<Object, ResultStatusEnum> findSchemaElement(Map<String, Object> propertyValue) {
return findToscaElement(propertyValue, TypeUtils.ToscaTagNamesEnum.ENTRY_SCHEMA, ToscaElementTypeEnum.ALL);
}
@@ -546,8 +544,8 @@ public final class ImportUtils {
}
-
- public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getProperties(Map<String, Object> toscaJson) {
+ public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getProperties(
+ Map<String, Object> toscaJson) {
Function<String, PropertyDefinition> elementGenByName = ImportUtils::createProperties;
Function<Map<String, Object>, PropertyDefinition> func = ImportUtils::createModuleProperty;
@@ -555,25 +553,31 @@ public final class ImportUtils {
}
- public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(Map<String, Object> toscaJson, AnnotationTypeOperations annotationTypeOperations) {
+ public static Either<Map<String, InputDefinition>, ResultStatusEnum> getInputs(Map<String, Object> toscaJson,
+ AnnotationTypeOperations annotationTypeOperations) {
Function<String, InputDefinition> elementGenByName = ImportUtils::createInputs;
- Function<Map<String, Object>, InputDefinition> func = object -> createModuleInput(object, annotationTypeOperations);
+ Function<Map<String, Object>, InputDefinition> func = object -> createModuleInput(object,
+ annotationTypeOperations);
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS, elementGenByName, func);
}
- public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getAttributes(Map<String, Object> toscaJson) {
- Function<String, PropertyDefinition> elementGenByName = ImportUtils::createAttribute;
- Function<Map<String, Object>, PropertyDefinition> func = ImportUtils::createModuleAttribute;
+ public static Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> getAttributes(
+ Map<String, Object> toscaJson) {
+ Function<String, AttributeDataDefinition> elementGenByName = ImportUtils::createAttribute;
+ Function<Map<String, Object>, AttributeDataDefinition> func = ImportUtils::createModuleAttribute;
return getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.ATTRIBUTES, elementGenByName, func);
}
- public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementTagName, Function<String, T> elementGenByName,
+ public static <T> Either<Map<String, T>, ResultStatusEnum> getElements(Map<String, Object> toscaJson,
+ TypeUtils.ToscaTagNamesEnum elementTagName,
+ Function<String, T> elementGenByName,
Function<Map<String, Object>, T> func) {
Either<Map<String, T>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
- Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson, elementTagName);
+ Either<Map<String, Object>, ResultStatusEnum> toscaAttributes = findFirstToscaMapElement(toscaJson,
+ elementTagName);
if (toscaAttributes.isLeft()) {
Map<String, Object> jsonAttributes = toscaAttributes.left().value();
Map<String, T> moduleAttributes = new HashMap<>();
@@ -583,7 +587,7 @@ public final class ImportUtils {
if (attributeNameValue.getValue() instanceof Map) {
@SuppressWarnings("unchecked")
T attribute = func.apply((Map<String, Object>) attributeNameValue.getValue());
- if (attribute != null){
+ if (attribute != null) {
moduleAttributes.put(String.valueOf(attributeNameValue.getKey()), attribute);
}
}
@@ -601,8 +605,8 @@ public final class ImportUtils {
}
- private static PropertyDefinition createAttribute(String name) {
- PropertyDefinition attribute = new PropertyDefinition();
+ private static AttributeDefinition createAttribute(String name) {
+ AttributeDefinition attribute = new AttributeDefinition();
attribute.setName(name);
return attribute;
@@ -615,8 +619,6 @@ public final class ImportUtils {
return property;
}
-
-
private static InputDefinition createInputs(String name) {
InputDefinition input = new InputDefinition();
@@ -630,8 +632,6 @@ public final class ImportUtils {
return annotation;
}
-
-
public static Either<List<HeatParameterDefinition>, ResultStatusEnum> getHeatParameters(Map<String, Object> heatData, String artifactType) {
Either<List<HeatParameterDefinition>, ResultStatusEnum> eitherResult = Either.right(ResultStatusEnum.ELEMENT_NOT_FOUND);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 6e3019c0c3..35a0761ff1 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -94,6 +94,7 @@ import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
@@ -109,6 +110,7 @@ import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.info.NodeTypeInfoToUpdateArtifacts;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.CapabilityRequirementRelationship;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -2617,8 +2619,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
resource.getUniqueId(), yamlName);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS,resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,"No instances found in the resource: {}, is empty, yaml template file name: {}",resource.getName(),yamlName);
BeEcompErrorManager.getInstance()
- .logInternalDataError("createResourceInstancesRelations",
- "No instances found in a resource or nn yaml template. ", ErrorSeverity.ERROR);
+ .logInternalDataError("createResourceInstancesRelations",
+ "No instances found in a resource or nn yaml template. ", ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
Map<String, List<ComponentInstanceProperty>> instProperties = new HashMap<>();
@@ -2626,17 +2628,17 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts = new HashMap<>();
Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
- Map<String, List<PropertyDefinition>> instAttributes = new HashMap<>();
+ Map<String, List<AttributeDataDefinition>> instAttributes = new HashMap<>();
List<RequirementCapabilityRelDef> relations = new ArrayList<>();
Map<String, List<ComponentInstanceInput>> instInputs = new HashMap<>();
log.debug("#createResourceInstancesRelations - Before get all datatypes. ");
- Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
+ Either<Map<String, DataTypeDefinition>, JanusGraphOperationStatus> allDataTypes = dataTypeCache.getAll();
if (allDataTypes.isRight()) {
JanusGraphOperationStatus status = allDataTypes.right()
- .value();
+ .value();
BeEcompErrorManager.getInstance()
- .logInternalFlowError("UpdatePropertyValueOnComponentInstance",
+ .logInternalFlowError("UpdatePropertyValueOnComponentInstance",
"Failed to update property value on instance. Status is " + status, ErrorSeverity.ERROR);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS,resource.getComponentMetadataForSupportLog(),
StatusCode.ERROR,"ERROR while update property value on instance. Status is: "+status);
@@ -2683,32 +2685,39 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilities,
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
- Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String, List<ComponentInstanceProperty>> instProperties, Map<String, List<ComponentInstanceInput>> instInputs, Map<String, List<PropertyDefinition>> instAttributes) {
+ Map<String, Map<String, ArtifactDefinition>> instArtifacts, Map<String,
+ List<ComponentInstanceProperty>> instProperties, Map<String,
+ List<ComponentInstanceInput>> instInputs,
+ Map<String, List<AttributeDataDefinition>> instAttributes) {
Optional<ComponentInstance> foundInstance = findInstance(oldResource, instance);
- if(foundInstance.isPresent()){
- if(MapUtils.isNotEmpty(foundInstance.get().getCapabilities())){
+ if (foundInstance.isPresent()) {
+ if (MapUtils.isNotEmpty(foundInstance.get().getCapabilities())) {
instCapabilities.put(instance, foundInstance.get().getCapabilities());
}
- if(MapUtils.isNotEmpty(foundInstance.get().getRequirements())){
+ if (MapUtils.isNotEmpty(foundInstance.get().getRequirements())) {
instRequirements.put(instance, foundInstance.get().getRequirements());
}
- if(MapUtils.isNotEmpty(foundInstance.get().getDeploymentArtifacts())){
+ if (MapUtils.isNotEmpty(foundInstance.get().getDeploymentArtifacts())) {
instDeploymentArtifacts.put(instance.getUniqueId(), foundInstance.get().getDeploymentArtifacts());
}
if(MapUtils.isNotEmpty(foundInstance.get().getArtifacts())){
instArtifacts.put(instance.getUniqueId(), foundInstance.get().getArtifacts());
}
- if(MapUtils.isNotEmpty(oldResource.getComponentInstancesProperties()) &&
- CollectionUtils.isNotEmpty(oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()))){
- instProperties.put(instance.getUniqueId(), oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()));
+ if (MapUtils.isNotEmpty(oldResource.getComponentInstancesProperties()) &&
+ CollectionUtils
+ .isNotEmpty(oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()))) {
+ instProperties.put(instance.getUniqueId(),
+ oldResource.getComponentInstancesProperties().get(foundInstance.get().getUniqueId()));
}
- if(MapUtils.isNotEmpty(oldResource.getComponentInstancesInputs()) &&
- CollectionUtils.isNotEmpty(oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()))){
- instInputs.put(instance.getUniqueId(), oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()));
+ if (MapUtils.isNotEmpty(oldResource.getComponentInstancesInputs()) &&
+ CollectionUtils
+ .isNotEmpty(oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()))) {
+ instInputs.put(instance.getUniqueId(),
+ oldResource.getComponentInstancesInputs().get(foundInstance.get().getUniqueId()));
}
if(MapUtils.isNotEmpty(oldResource.getComponentInstancesAttributes()) &&
CollectionUtils.isNotEmpty(oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()))){
- instAttributes.put(instance.getUniqueId(), oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()).stream().map(PropertyDefinition::new).collect(toList()));
+ instAttributes.put(instance.getUniqueId(), oldResource.getComponentInstancesAttributes().get(foundInstance.get().getUniqueId()).stream().map(AttributeDefinition::new).collect(toList()));
}
}
}
@@ -2735,14 +2744,15 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private void associateInstAttributeToComponentToInstances(String yamlName, Resource resource,
- Map<String, List<PropertyDefinition>> instAttributes) {
+ Map<String, List<AttributeDataDefinition>> instAttributes) {
StorageOperationStatus addArtToInst;
addArtToInst = toscaOperationFacade.associateInstAttributeToComponentToInstances(instAttributes,
- resource);
+ resource);
if (addArtToInst != StorageOperationStatus.OK && addArtToInst != StorageOperationStatus.NOT_FOUND) {
log.debug("failed to associate attributes of resource {} status is {}", resource.getUniqueId(),
- addArtToInst);
- throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(addArtToInst), yamlName);
+ addArtToInst);
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(addArtToInst),
+ yamlName);
}
}
@@ -2890,7 +2900,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements,
Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
Map<String, Map<String, ArtifactDefinition>> instArtifacts,
- Map<String, List<PropertyDefinition>> instAttributes, Map<String, Resource> originCompMap,
+ Map<String, List<AttributeDataDefinition>> instAttributes,
+ Map<String, Resource> originCompMap,
Map<String, List<ComponentInstanceInput>> instInputs,
UploadComponentInstanceInfo uploadComponentInstanceInfo) {
Optional<ComponentInstance> currentCompInstanceOpt = componentInstancesList.stream()
@@ -2914,24 +2925,22 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
if (isNotEmpty(originResource.getCapabilities())) {
processComponentInstanceCapabilities(allDataTypes, instCapabilties, uploadComponentInstanceInfo,
- currentCompInstance, originResource);
+ currentCompInstance, originResource);
}
if (originResource.getDeploymentArtifacts() != null && !originResource.getDeploymentArtifacts()
- .isEmpty()) {
+ .isEmpty()) {
instDeploymentArtifacts.put(resourceInstanceId, originResource.getDeploymentArtifacts());
}
- if (originResource.getArtifacts() != null && !originResource.getArtifacts()
- .isEmpty()) {
+ if (originResource.getArtifacts() != null && !originResource.getArtifacts().isEmpty()) {
instArtifacts.put(resourceInstanceId, originResource.getArtifacts());
}
- if (originResource.getAttributes() != null && !originResource.getAttributes()
- .isEmpty()) {
+ if (originResource.getAttributes() != null && !originResource.getAttributes().isEmpty()) {
instAttributes.put(resourceInstanceId, originResource.getAttributes());
}
if (originResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResponseFormat addPropertiesValueToRiRes = addPropertyValuesToRi(uploadComponentInstanceInfo, resource,
- originResource, currentCompInstance, instProperties, allDataTypes.left()
- .value());
+ originResource, currentCompInstance, instProperties, allDataTypes.left()
+ .value());
if (addPropertiesValueToRiRes.getStatus() != 200) {
throw new ByResponseFormatComponentException(addPropertiesValueToRiRes);
}
@@ -3982,11 +3991,9 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
mergeOldResourceMetadataWithNew(oldResource, newResource);
validateResourceFieldsBeforeUpdate(oldResource, newResource, inTransaction, isNested);
- validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), newResource,
- AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
+ validateCapabilityTypesCreate(user, getCapabilityTypeOperation(), newResource, AuditingActionEnum.IMPORT_RESOURCE, inTransaction);
// contact info normalization
- newResource.setContactId(newResource.getContactId()
- .toLowerCase());
+ newResource.setContactId(newResource.getContactId().toLowerCase());
PropertyConstraintsUtils.validatePropertiesConstraints(newResource, oldResource);
// non-updatable fields
newResource.setCreatorUserId(user.getUserId());
@@ -4008,58 +4015,56 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
newResource.setAbstract(oldResource.isAbstract());
- if (newResource.getDerivedFrom() == null || newResource.getDerivedFrom()
- .isEmpty()) {
+ if (CollectionUtils.isEmpty(newResource.getDerivedFrom())) {
newResource.setDerivedFrom(oldResource.getDerivedFrom());
}
- if (newResource.getDerivedFromGenericType() == null || newResource.getDerivedFromGenericType()
- .isEmpty()) {
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericType())) {
newResource.setDerivedFromGenericType(oldResource.getDerivedFromGenericType());
}
- if (newResource.getDerivedFromGenericVersion() == null || newResource.getDerivedFromGenericVersion()
- .isEmpty()) {
+ if (StringUtils.isEmpty(newResource.getDerivedFromGenericVersion())) {
newResource.setDerivedFromGenericVersion(oldResource.getDerivedFromGenericVersion());
}
// add for new)
// created without tosca artifacts - add the placeholders
- if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts()
- .isEmpty()) {
+ if (MapUtils.isEmpty(newResource.getToscaArtifacts())) {
setToscaArtifactsPlaceHolders(newResource, user);
}
- if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
+ if (MapUtils.isEmpty(newResource.getInterfaces())) {
newResource.setInterfaces(oldResource.getInterfaces());
}
+ if (CollectionUtils.isEmpty(newResource.getAttributes())) {
+ newResource.setAttributes(oldResource.getAttributes());
+ }
- if (CollectionUtils.isEmpty(newResource.getProperties())) {
- newResource.setProperties(oldResource.getProperties());
- }
+ if (CollectionUtils.isEmpty(newResource.getProperties())) {
+ newResource.setProperties(oldResource.getProperties());
+ }
- Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
- .overrideComponent(newResource, oldResource);
+ Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade.overrideComponent(newResource, oldResource);
if (overrideResource.isRight()) {
ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(overrideResource.right()
- .value()), newResource);
+ .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(overrideResource.right()
+ .value()), newResource);
componentsUtils.auditResource(responseFormat, user, newResource, AuditingActionEnum.IMPORT_RESOURCE);
throwComponentException(responseFormat);
}
updateCatalog(overrideResource.left()
- .value(), ChangeTypeEnum.LIFECYCLE);
+ .value(), ChangeTypeEnum.LIFECYCLE);
log.debug("Resource updated successfully!!!");
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.OK);
componentsUtils.auditResource(responseFormat, user, newResource, AuditingActionEnum.IMPORT_RESOURCE,
- ResourceVersionInfo.newBuilder()
- .state(oldResource.getLifecycleState()
- .name())
- .version(oldResource.getVersion())
- .build());
+ ResourceVersionInfo.newBuilder()
+ .state(oldResource.getLifecycleState()
+ .name())
+ .version(oldResource.getVersion())
+ .build());
resourcePair = new ImmutablePair<>(overrideResource.left()
- .value(), ActionStatus.OK);
+ .value(), ActionStatus.OK);
return resourcePair;
} finally {
if (resourcePair == null) {
@@ -4439,7 +4444,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw e;
} finally {
- if (!inTransaction) {
+ if (!inTransaction) {
graphLockOperation.unlockComponentByName(resource.getSystemName(), resource.getUniqueId(),
NodeTypeEnum.Resource);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index 46942d96d4..1a0dfaa9fd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -23,6 +23,7 @@
package org.openecomp.sdc.be.components.impl;
import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.QUOTE;
+import static org.openecomp.sdc.be.utils.TypeUtils.setField;
import fj.data.Either;
import java.util.LinkedHashMap;
@@ -43,6 +44,7 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
@@ -53,7 +55,9 @@ import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
+import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -100,6 +104,7 @@ import java.util.stream.Collectors;
@Component("resourceImportManager")
public class ResourceImportManager {
+
private static final Logger log = Logger.getLogger(ResourceImportManager.class);
static final Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern.compile("[\\w\\-\\_\\d\\:]+");
@@ -136,27 +141,46 @@ public class ResourceImportManager {
this.toscaOperationFacade = toscaOperationFacade;
}
- public ImmutablePair<Resource, ActionStatus> importNormativeResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
+ public ImmutablePair<Resource, ActionStatus> importNormativeResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean createNewVersion,
+ boolean needLock) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
lifecycleChangeInfo.setUserRemarks("certification on import");
- Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
+ Function<Resource, Boolean> validator = resource -> resourceBusinessLogic
+ .validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false,
+ createNewVersion, needLock, null, null, false, null, null, false);
}
- public ImmutablePair<Resource, ActionStatus> importNormativeResourceFromCsar(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean createNewVersion, boolean needLock) {
+ public ImmutablePair<Resource, ActionStatus> importNormativeResourceFromCsar(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean createNewVersion,
+ boolean needLock) {
LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction();
lifecycleChangeInfo.setUserRemarks("certification on import");
- Function<Resource, Boolean> validator = resource -> resourceBusinessLogic.validatePropertiesDefaultValues(resource);
+ Function<Resource, Boolean> validator = resource -> resourceBusinessLogic
+ .validatePropertiesDefaultValues(resource);
- return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false, createNewVersion, needLock, null, null, false, null, null, false);
+ return importCertifiedResource(resourceYml, resourceMetaData, creator, validator, lifecycleChangeInfo, false,
+ createNewVersion, needLock, null, null, false, null, null, false);
}
- public ImmutablePair<Resource, ActionStatus> importCertifiedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator,
+ public ImmutablePair<Resource, ActionStatus> importCertifiedResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator,
Function<Resource, Boolean> validationFunction,
- LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean isInTransaction, boolean createNewVersion, boolean needLock, Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, boolean forceCertificationAllowed, CsarInfo csarInfo, String nodeName, boolean isNested) {
+ LifecycleChangeInfoWithAction lifecycleChangeInfo,
+ boolean isInTransaction,
+ boolean createNewVersion, boolean needLock,
+ Map<ArtifactOperationEnum, List<ArtifactDefinition>> nodeTypeArtifactsToHandle,
+ List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
+ boolean forceCertificationAllowed,
+ CsarInfo csarInfo, String nodeName,
+ boolean isNested) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> response = Either.left(responsePair);
@@ -170,32 +194,38 @@ public class ResourceImportManager {
populateResourceFromYaml(resourceYml, resource);
Boolean isValidResource = validationFunction.apply(resource);
- if (!createNewVersion) {
- Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade.getLatestByName(resource.getName());
- if (latestByName.isLeft()) {
- throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, resource.getName());
- }
+ if (!createNewVersion) {
+ Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade
+ .getLatestByName(resource.getName());
+ if (latestByName.isLeft()) {
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
+ resource.getName());
}
- resource = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName, isNested).left;
- Resource changeStateResponse;
-
- if (nodeTypeArtifactsToHandle != null && !nodeTypeArtifactsToHandle.isEmpty()) {
- Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
- resourceBusinessLogic.handleNodeTypeArtifacts(resource, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, creator, isInTransaction, false);
- if (handleNodeTypeArtifactsRes.isRight()) {
- //TODO: should be used more correct action
- throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
- }
+ }
+ resource = resourceBusinessLogic
+ .createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName,
+ isNested).left;
+ Resource changeStateResponse;
+
+ if (nodeTypeArtifactsToHandle != null && !nodeTypeArtifactsToHandle.isEmpty()) {
+ Either<List<ArtifactDefinition>, ResponseFormat> handleNodeTypeArtifactsRes =
+ resourceBusinessLogic
+ .handleNodeTypeArtifacts(resource, nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts,
+ creator, isInTransaction, false);
+ if (handleNodeTypeArtifactsRes.isRight()) {
+ //TODO: should be used more correct action
+ throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
- latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
- changeStateResponse = resourceBusinessLogic.propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock, forceCertificationAllowed);
- responsePair = new ImmutablePair<>(changeStateResponse, response.left()
- .value().right);
- }
- catch (RuntimeException e) {
+ }
+ latestCertifiedResourceId = getLatestCertifiedResourceId(resource);
+ changeStateResponse = resourceBusinessLogic
+ .propagateStateToCertified(creator, resource, lifecycleChangeInfo, isInTransaction, needLock,
+ forceCertificationAllowed);
+ responsePair = new ImmutablePair<>(changeStateResponse, response.left()
+ .value().right);
+ } catch (RuntimeException e) {
handleImportResourceException(resourceMetaData, creator, true, e);
- }
- finally {
+ } finally {
if (latestCertifiedResourceId != null && needLock) {
log.debug("unlock resource {}", latestCertifiedResourceId);
graphLockOperation.unlockComponent(latestCertifiedResourceId, NodeTypeEnum.Resource);
@@ -206,9 +236,11 @@ public class ResourceImportManager {
}
private ResponseFormat getResponseFormatFromComponentException(RuntimeException e) {
- if(e instanceof ComponentException){
+ if (e instanceof ComponentException) {
return ((ComponentException) e).getResponseFormat() == null ?
- componentsUtils.getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams()) :
+ componentsUtils
+ .getResponseFormat(((ComponentException) e).getActionStatus(), ((ComponentException) e).getParams())
+ :
((ComponentException) e).getResponseFormat();
}
return null;
@@ -225,8 +257,7 @@ public class ResourceImportManager {
}
}
return allVersions.get(String.valueOf(latestCertifiedVersion));
- }
- else {
+ } else {
return null;
}
}
@@ -250,7 +281,9 @@ public class ResourceImportManager {
}
}
- public ImmutablePair<Resource, ActionStatus> importUserDefinedResource(String resourceYml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction) {
+ public ImmutablePair<Resource, ActionStatus> importUserDefinedResource(String resourceYml,
+ UploadResourceInfo resourceMetaData,
+ User creator, boolean isInTransaction) {
Resource resource = new Resource();
ImmutablePair<Resource, ActionStatus> responsePair = new ImmutablePair<>(resource, ActionStatus.CREATED);
@@ -271,10 +304,9 @@ public class ResourceImportManager {
Boolean validatePropertiesTypes = resourceBusinessLogic.validatePropertiesDefaultValues(resource);
responsePair = resourceBusinessLogic.createOrUpdateResourceByImport(resource, creator,
- false, isInTransaction, true, null, null, false);
+ false, isInTransaction, true, null, null, false);
- }
- catch (RuntimeException e) {
+ } catch (RuntimeException e) {
handleImportResourceException(resourceMetaData, creator, false, e);
}
return responsePair;
@@ -289,9 +321,11 @@ public class ResourceImportManager {
Map<String, Object> toscaJson = toscaJsonAll;
// Checks if exist and builds the node_types map
- if (toscaJsonAll.containsKey(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()) && resource.getResourceType() != ResourceTypeEnum.CVFC) {
+ if (toscaJsonAll.containsKey(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName())
+ && resource.getResourceType() != ResourceTypeEnum.CVFC) {
toscaJson = new HashMap<>();
- toscaJson.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(), toscaJsonAll.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()));
+ toscaJson.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(),
+ toscaJsonAll.get(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName()));
}
// Derived From
Resource parentResource = setDerivedFrom(toscaJson, resource);
@@ -303,15 +337,15 @@ public class ResourceImportManager {
setProperties(toscaJson, resource);
setRequirements(toscaJson, resource, parentResource);
setInterfaceLifecycle(toscaJson, resource);
- }
- else {
+ } else {
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
}
private void setToscaResourceName(Map<String, Object> toscaJson, Resource resource) {
- Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
+ Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.NODE_TYPES);
if (toscaElement.isLeft() || toscaElement.left().value().size() == 1) {
String toscaResourceName = toscaElement.left().value().keySet().iterator().next();
resource.setToscaResourceName(toscaResourceName);
@@ -319,7 +353,8 @@ public class ResourceImportManager {
}
private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource) {
- Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.INTERFACES);
+ Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.INTERFACES);
if (toscaInterfaces.isLeft()) {
Map<String, Object> jsonInterfaces = toscaInterfaces.left().value();
Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>();
@@ -327,11 +362,11 @@ public class ResourceImportManager {
while (interfacesNameValue.hasNext()) {
Entry<String, Object> interfaceNameValue = interfacesNameValue.next();
Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue
- .getValue(), resource);
+ .getValue(), resource);
if (eitherInterface.isRight()) {
- log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(), resource.getName());
- }
- else {
+ log.info("error when creating interface:{}, for resource:{}", interfaceNameValue.getKey(),
+ resource.getName());
+ } else {
moduleInterfaces.put(interfaceNameValue.getKey(), eitherInterface.left().value());
}
@@ -342,7 +377,8 @@ public class ResourceImportManager {
}
}
- private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(Object interfaceJson, Resource resource) {
+ private Either<InterfaceDefinition, ResultStatusEnum> createModuleInterface(Object interfaceJson,
+ Resource resource) {
final InterfaceDefinition interf = new InterfaceDefinition();
Either<InterfaceDefinition, ResultStatusEnum> result = Either.left(interf);
@@ -384,8 +420,7 @@ public class ResourceImportManager {
result = Either.right(ResultStatusEnum.GENERAL_ERROR);
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
BeEcompErrorManager.getInstance().logBeSystemError("Import Resource- create interface");
log.debug("error when creating interface, message:{}", e.getMessage(), e);
result = Either.right(ResultStatusEnum.GENERAL_ERROR);
@@ -405,7 +440,8 @@ public class ResourceImportManager {
return implementation;
}
- private ListDataDefinition<OperationInputDefinition> handleInterfaceInput(final Map<String, Object> interfaceInputs) {
+ private ListDataDefinition<OperationInputDefinition> handleInterfaceInput(
+ final Map<String, Object> interfaceInputs) {
final ListDataDefinition<OperationInputDefinition> inputs = new ListDataDefinition<>();
for (final Entry<String, Object> interfaceInput : interfaceInputs.entrySet()) {
final OperationInputDefinition operationInput = new OperationInputDefinition();
@@ -446,52 +482,60 @@ public class ResourceImportManager {
}
private boolean entryIsInterfaceType(final Entry<String, Object> entry) {
- if(entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
- if (entry.getValue() instanceof String) {
- return true;
- }
- throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
- }
- return false;
+ if (entry.getKey().equals(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
+ if (entry.getValue() instanceof String) {
+ return true;
+ }
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
+ }
+ return false;
}
-
- private boolean entryContainsImplementationForAKnownOperation(final Entry<String, Object> entry, final String interfaceType) {
- if (entry.getValue() instanceof Map && ((Map<?, ?>)entry.getValue()).containsKey(IMPLEMENTATION)) {
- if (isAKnownOperation(interfaceType, entry.getKey())){
- return true;
- }
- throw new ByActionStatusComponentException(ActionStatus.INTERFACE_OPERATION_NOT_FOUND);
- }
- return false;
+
+ private boolean entryContainsImplementationForAKnownOperation(final Entry<String, Object> entry,
+ final String interfaceType) {
+ if (entry.getValue() instanceof Map && ((Map<?, ?>) entry.getValue()).containsKey(IMPLEMENTATION)) {
+ if (isAKnownOperation(interfaceType, entry.getKey())) {
+ return true;
+ }
+ throw new ByActionStatusComponentException(ActionStatus.INTERFACE_OPERATION_NOT_FOUND);
+ }
+ return false;
}
-
- private boolean isAKnownOperation(String interfaceType, String operation) {
- Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
- if (interfaceLifecycleTypes.isRight() || interfaceLifecycleTypes.left().value() == null) {
- return false;
- }
-
- for (Entry<String, InterfaceDefinition> interfaceLifecycleType : interfaceLifecycleTypes.left().value().entrySet()) {
- if (interfaceTypeAndOperationMatches(interfaceLifecycleType, interfaceType, operation)) {
- return true;
- }
- }
- return false;
+
+ private boolean isAKnownOperation(String interfaceType, String operation) {
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> interfaceLifecycleTypes = interfaceOperationBusinessLogic
+ .getAllInterfaceLifecycleTypes();
+ if (interfaceLifecycleTypes.isRight() || interfaceLifecycleTypes.left().value() == null) {
+ return false;
+ }
+
+ for (Entry<String, InterfaceDefinition> interfaceLifecycleType : interfaceLifecycleTypes.left().value()
+ .entrySet()) {
+ if (interfaceTypeAndOperationMatches(interfaceLifecycleType, interfaceType, operation)) {
+ return true;
+ }
+ }
+ return false;
}
-
- private boolean interfaceTypeAndOperationMatches(Entry<String, InterfaceDefinition> interfaceLifecycleType, String interfaceType, String operation) {
- if (interfaceLifecycleType.getKey().equalsIgnoreCase(interfaceType) && interfaceLifecycleType.getValue().getOperations() != null) {
- for (String interfaceLifecycleTypeOperation : interfaceLifecycleType.getValue().getOperations().keySet()) {
- if (interfaceLifecycleTypeOperation != null && interfaceLifecycleTypeOperation.equalsIgnoreCase(operation)){
- return true;
- }
- }
- }
- return false;
+
+ private boolean interfaceTypeAndOperationMatches(Entry<String, InterfaceDefinition> interfaceLifecycleType,
+ String interfaceType, String operation) {
+ if (interfaceLifecycleType.getKey().equalsIgnoreCase(interfaceType)
+ && interfaceLifecycleType.getValue().getOperations() != null) {
+ for (String interfaceLifecycleTypeOperation : interfaceLifecycleType.getValue().getOperations().keySet()) {
+ if (interfaceLifecycleTypeOperation != null && interfaceLifecycleTypeOperation
+ .equalsIgnoreCase(operation)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
- private void setRequirements(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
- Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils.findFirstToscaListElement(toscaJson, TypeUtils.ToscaTagNamesEnum.REQUIREMENTS);
+ private void setRequirements(Map<String, Object> toscaJson, Resource resource,
+ Resource parentResource) {// Note that parentResource can be null
+ Either<List<Object>, ResultStatusEnum> toscaRequirements = ImportUtils
+ .findFirstToscaListElement(toscaJson, TypeUtils.ToscaTagNamesEnum.REQUIREMENTS);
if (toscaRequirements.isLeft()) {
List<Object> jsonRequirements = toscaRequirements.left().value();
Map<String, List<RequirementDefinition>> moduleRequirements = new HashMap<>();
@@ -506,17 +550,19 @@ public class ResourceImportManager {
String requirementName = requirementJsonWrapper.keySet().iterator().next();
String reqNameLowerCase = requirementName.toLowerCase();
if (reqNames.contains(reqNameLowerCase)) {
- log.debug("More than one requirement with same name {} (case-insensitive) in imported TOSCA file is invalid", reqNameLowerCase);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "requirement", reqNameLowerCase);
+ log.debug(
+ "More than one requirement with same name {} (case-insensitive) in imported TOSCA file is invalid",
+ reqNameLowerCase);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME,
+ "requirement", reqNameLowerCase);
}
reqNames.add(reqNameLowerCase);
RequirementDefinition requirementDef = createRequirementFromImportFile(requirementJsonWrapper
- .get(requirementName));
+ .get(requirementName));
requirementDef.setName(requirementName);
if (moduleRequirements.containsKey(requirementDef.getCapability())) {
moduleRequirements.get(requirementDef.getCapability()).add(requirementDef);
- }
- else {
+ } else {
List<RequirementDefinition> list = new ArrayList<>();
list.add(requirementDef);
moduleRequirements.put(requirementDef.getCapability(), list);
@@ -524,13 +570,15 @@ public class ResourceImportManager {
// Validating against req/cap of "derived from" node
Boolean validateVsParentCap = validateCapNameVsDerived(reqName2TypeMap, requirementDef
- .getCapability(), requirementDef.getName());
+ .getCapability(), requirementDef.getName());
if (!validateVsParentCap) {
String parentResourceName = parentResource != null ? parentResource.getName() : "";
- log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(), parentResourceName);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "requirement", requirementDef
- .getName()
- .toLowerCase(), parentResourceName);
+ log.debug("Requirement with name {} already exists in parent {}", requirementDef.getName(),
+ parentResourceName);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
+ "requirement", requirementDef
+ .getName()
+ .toLowerCase(), parentResourceName);
}
}
if (moduleRequirements.size() > 0) {
@@ -538,7 +586,7 @@ public class ResourceImportManager {
}
}
- }
+ }
private RequirementDefinition createRequirementFromImportFile(Object requirementJson) {
RequirementDefinition requirement = new RequirementDefinition();
@@ -546,11 +594,11 @@ public class ResourceImportManager {
if (requirementJson instanceof String) {
String requirementJsonString = (String) requirementJson;
requirement.setCapability(requirementJsonString);
- }
- else if (requirementJson instanceof Map) {
+ } else if (requirementJson instanceof Map) {
Map<String, Object> requirementJsonMap = (Map<String, Object>) requirementJson;
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName())) {
- requirement.setCapability((String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName()));
+ requirement.setCapability(
+ (String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.CAPABILITY.getElementName()));
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.NODE.getElementName())) {
@@ -558,16 +606,17 @@ public class ResourceImportManager {
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName())) {
- requirement.setRelationship((String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName()));
+ requirement.setRelationship(
+ (String) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.RELATIONSHIP.getElementName()));
}
if (requirementJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
- List<Object> occurrencesList = (List) requirementJsonMap.get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
+ List<Object> occurrencesList = (List) requirementJsonMap
+ .get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
validateOccurrences(occurrencesList);
requirement.setMinOccurrences(occurrencesList.get(0).toString());
requirement.setMaxOccurrences(occurrencesList.get(1).toString());
}
- }
- else {
+ } else {
throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
}
return requirement;
@@ -576,7 +625,8 @@ public class ResourceImportManager {
private void setProperties(Map<String, Object> toscaJson, Resource resource) {
Map<String, Object> reducedToscaJson = new HashMap<>(toscaJson);
ImportUtils.removeElementFromJsonMap(reducedToscaJson, "capabilities");
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(reducedToscaJson);
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils
+ .getProperties(reducedToscaJson);
if (properties.isLeft()) {
List<PropertyDefinition> propertiesList = new ArrayList<>();
Map<String, PropertyDefinition> value = properties.left().value();
@@ -584,8 +634,11 @@ public class ResourceImportManager {
for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
String name = entry.getKey();
if (!PROPERTY_NAME_PATTERN_IGNORE_LENGTH.matcher(name).matches()) {
- log.debug("The property with invalid name {} occured upon import resource {}. ", name, resource.getName());
- throw new ByActionStatusComponentException(componentsUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY));
+ log.debug("The property with invalid name {} occured upon import resource {}. ", name,
+ resource.getName());
+ throw new ByActionStatusComponentException(componentsUtils
+ .convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME,
+ JsonPresentationFields.PROPERTY));
}
PropertyDefinition propertyDefinition = entry.getValue();
propertyDefinition.setName(name);
@@ -593,44 +646,45 @@ public class ResourceImportManager {
}
}
resource.setProperties(propertiesList);
- }
- else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
+ } else if (properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND) {
throw new ByActionStatusComponentException(componentsUtils.convertFromResultStatusEnum(properties
- .right()
- .value(), JsonPresentationFields.PROPERTY));
+ .right()
+ .value(), JsonPresentationFields.PROPERTY));
}
}
private ResultStatusEnum setAttributes(Map<String, Object> toscaJson, Resource resource) {
ResultStatusEnum result = ResultStatusEnum.OK;
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> attributes = ImportUtils.getAttributes(toscaJson);
+ Either<Map<String, AttributeDataDefinition>, ResultStatusEnum> attributes = ImportUtils
+ .getAttributes(toscaJson);
if (attributes.isLeft()) {
- List<PropertyDefinition> attributeList = new ArrayList<>();
- Map<String, PropertyDefinition> value = attributes.left().value();
+ List<AttributeDataDefinition> attributeList = new ArrayList<>();
+ Map<String, AttributeDataDefinition> value = attributes.left().value();
if (value != null) {
- for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
+ for (Entry<String, AttributeDataDefinition> entry : value.entrySet()) {
String name = entry.getKey();
- PropertyDefinition attributeDef = entry.getValue();
+ AttributeDataDefinition attributeDef = entry.getValue();
attributeDef.setName(name);
attributeList.add(attributeDef);
}
}
resource.setAttributes(attributeList);
- }
- else {
+ } else {
result = attributes.right().value();
}
return result;
}
private Resource setDerivedFrom(Map<String, Object> toscaJson, Resource resource) {
- Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils.findFirstToscaStringElement(toscaJson, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM);
+ Either<String, ResultStatusEnum> toscaDerivedFromElement = ImportUtils
+ .findFirstToscaStringElement(toscaJson, TypeUtils.ToscaTagNamesEnum.DERIVED_FROM);
Resource derivedFromResource = null;
if (toscaDerivedFromElement.isLeft()) {
String derivedFrom = toscaDerivedFromElement.left().value();
log.debug("Derived from TOSCA name is {}", derivedFrom);
resource.setDerivedFrom(Arrays.asList(new String[]{derivedFrom}));
- Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade.getLatestByToscaResourceName(derivedFrom);
+ Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade
+ .getLatestByToscaResourceName(derivedFrom);
if (latestByToscaResourceName.isRight()) {
StorageOperationStatus operationStatus = latestByToscaResourceName.right().value();
@@ -640,7 +694,7 @@ public class ResourceImportManager {
log.debug("Error when fetching parent resource {}, error: {}", derivedFrom, operationStatus);
ActionStatus convertFromStorageResponse = componentsUtils.convertFromStorageResponse(operationStatus);
BeEcompErrorManager.getInstance()
- .logBeComponentMissingError("Import TOSCA YAML", "resource", derivedFrom);
+ .logBeComponentMissingError("Import TOSCA YAML", "resource", derivedFrom);
throw new ByActionStatusComponentException(convertFromStorageResponse, derivedFrom);
}
derivedFromResource = latestByToscaResourceName.left().value();
@@ -648,8 +702,10 @@ public class ResourceImportManager {
return derivedFromResource;
}
- private void setCapabilities(Map<String, Object> toscaJson, Resource resource, Resource parentResource) {// Note that parentResource can be null
- Either<Map<String, Object>, ResultStatusEnum> toscaCapabilities = ImportUtils.findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.CAPABILITIES);
+ private void setCapabilities(Map<String, Object> toscaJson, Resource resource,
+ Resource parentResource) {// Note that parentResource can be null
+ Either<Map<String, Object>, ResultStatusEnum> toscaCapabilities = ImportUtils
+ .findFirstToscaMapElement(toscaJson, TypeUtils.ToscaTagNamesEnum.CAPABILITIES);
if (toscaCapabilities.isLeft()) {
Map<String, Object> jsonCapabilities = toscaCapabilities.left().value();
Map<String, List<CapabilityDefinition>> moduleCapabilities = new HashMap<>();
@@ -664,18 +720,20 @@ public class ResourceImportManager {
// Validating that no req/cap duplicates exist in imported YAML
String capNameLowerCase = capabilityNameValue.getKey().toLowerCase();
if (capNames.contains(capNameLowerCase)) {
- log.debug("More than one capability with same name {} (case-insensitive) in imported TOSCA file is invalid", capNameLowerCase);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "capability", capNameLowerCase);
+ log.debug(
+ "More than one capability with same name {} (case-insensitive) in imported TOSCA file is invalid",
+ capNameLowerCase);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_DUPLICATE_REQ_CAP_NAME, "capability",
+ capNameLowerCase);
}
capNames.add(capNameLowerCase);
CapabilityDefinition capabilityDef = createCapabilityFromImportFile(capabilityNameValue
- .getValue());
+ .getValue());
capabilityDef.setName(capabilityNameValue.getKey());
if (moduleCapabilities.containsKey(capabilityDef.getType())) {
moduleCapabilities.get(capabilityDef.getType()).add(capabilityDef);
- }
- else {
+ } else {
List<CapabilityDefinition> list = new ArrayList<>();
list.add(capabilityDef);
moduleCapabilities.put(capabilityDef.getType(), list);
@@ -683,17 +741,19 @@ public class ResourceImportManager {
// Validating against req/cap of "derived from" node
Boolean validateVsParentCap = validateCapNameVsDerived(capName2TypeMap, capabilityDef
- .getType(), capabilityDef.getName());
+ .getType(), capabilityDef.getName());
if (!validateVsParentCap) {
// Here parentResource is for sure not null, so it's
// null-safe
// Check added to avoid sonar warning
String parentResourceName = parentResource != null ? parentResource.getName() : "";
- log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(), parentResourceName);
- throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED, "capability", capabilityDef
- .getName()
- .toLowerCase(), parentResourceName);
+ log.debug("Capability with name {} already exists in parent {}", capabilityDef.getName(),
+ parentResourceName);
+ throw new ByActionStatusComponentException(ActionStatus.IMPORT_REQ_CAP_NAME_EXISTS_IN_DERIVED,
+ "capability", capabilityDef
+ .getName()
+ .toLowerCase(), parentResourceName);
}
}
if (moduleCapabilities.size() > 0) {
@@ -712,9 +772,12 @@ public class ResourceImportManager {
String nameLowerCase = capDefinition.getName().toLowerCase();
if (capName2type.get(nameLowerCase) != null) {
String parentResourceName = parentResource.getName();
- log.debug("Resource with name {} has more than one capability with name {}, ignoring case", parentResourceName, nameLowerCase);
+ log.debug("Resource with name {} has more than one capability with name {}, ignoring case",
+ parentResourceName, nameLowerCase);
BeEcompErrorManager.getInstance()
- .logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more capabilities with name " + nameLowerCase, ErrorSeverity.ERROR);
+ .logInternalDataError("Import resource", "Parent resource " + parentResourceName
+ + " of imported resource has one or more capabilities with name " + nameLowerCase,
+ ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
capName2type.put(nameLowerCase, capDefinition.getType());
@@ -735,9 +798,12 @@ public class ResourceImportManager {
String nameLowerCase = reqDefinition.getName().toLowerCase();
if (reqName2type.get(nameLowerCase) != null) {
String parentResourceName = parentResource.getName();
- log.debug("Resource with name {} has more than one requirement with name {}, ignoring case", parentResourceName, nameLowerCase);
+ log.debug("Resource with name {} has more than one requirement with name {}, ignoring case",
+ parentResourceName, nameLowerCase);
BeEcompErrorManager.getInstance()
- .logInternalDataError("Import resource", "Parent resource " + parentResourceName + " of imported resource has one or more requirements with name " + nameLowerCase, ErrorSeverity.ERROR);
+ .logInternalDataError("Import resource", "Parent resource " + parentResourceName
+ + " of imported resource has one or more requirements with name " + nameLowerCase,
+ ErrorSeverity.ERROR);
throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
reqName2type.put(nameLowerCase, reqDefinition.getCapability());
@@ -748,19 +814,24 @@ public class ResourceImportManager {
return reqName2type;
}
- private Boolean validateCapNameVsDerived(Map<String, String> parentCapName2Type, String childCapabilityType, String reqCapName) {
+ private Boolean validateCapNameVsDerived(Map<String, String> parentCapName2Type, String childCapabilityType,
+ String reqCapName) {
String capNameLowerCase = reqCapName.toLowerCase();
log.trace("Validating capability {} vs parent resource", capNameLowerCase);
String parentCapType = parentCapName2Type.get(capNameLowerCase);
if (parentCapType != null) {
if (childCapabilityType.equals(parentCapType)) {
- log.debug("Capability with name {} is of same type {} for imported resource and its parent - this is OK", capNameLowerCase, childCapabilityType);
+ log.debug(
+ "Capability with name {} is of same type {} for imported resource and its parent - this is OK",
+ capNameLowerCase, childCapabilityType);
return true;
}
- Either<Boolean, StorageOperationStatus> capabilityTypeDerivedFrom = capabilityTypeOperation.isCapabilityTypeDerivedFrom(childCapabilityType, parentCapType);
+ Either<Boolean, StorageOperationStatus> capabilityTypeDerivedFrom = capabilityTypeOperation
+ .isCapabilityTypeDerivedFrom(childCapabilityType, parentCapType);
if (capabilityTypeDerivedFrom.isRight()) {
log.debug("Couldn't check whether imported resource capability derives from its parent's capability");
- throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
+ throw new ByActionStatusComponentException(
+ componentsUtils.convertFromStorageResponse(capabilityTypeDerivedFrom
.right()
.value()));
}
@@ -776,69 +847,73 @@ public class ResourceImportManager {
if (capabilityJson instanceof String) {
String capabilityJsonString = (String) capabilityJson;
capabilityDefinition.setType(capabilityJsonString);
- }
- else if (capabilityJson instanceof Map) {
+ } else if (capabilityJson instanceof Map) {
Map<String, Object> capabilityJsonMap = (Map<String, Object>) capabilityJson;
// Type
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName())) {
- capabilityDefinition.setType((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()));
+ capabilityDefinition
+ .setType((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES.getElementName())) {
- capabilityDefinition.setValidSourceTypes((List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
+ capabilityDefinition.setValidSourceTypes(
+ (List<String>) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.VALID_SOURCE_TYPES
.getElementName()));
}
// ValidSourceTypes
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName())) {
- capabilityDefinition.setDescription((String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName()));
+ capabilityDefinition.setDescription(
+ (String) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName()));
}
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName())) {
- List<Object> occurrencesList = (List) capabilityJsonMap.get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
+ List<Object> occurrencesList = (List) capabilityJsonMap
+ .get(TypeUtils.ToscaTagNamesEnum.OCCURRENCES.getElementName());
validateOccurrences(occurrencesList);
capabilityDefinition.setMinOccurrences(occurrencesList.get(0).toString());
capabilityDefinition.setMaxOccurrences(occurrencesList.get(1).toString());
}
if (capabilityJsonMap.containsKey(TypeUtils.ToscaTagNamesEnum.PROPERTIES.getElementName())) {
- Either<Map<String, PropertyDefinition>, ResultStatusEnum> propertiesRes = ImportUtils.getProperties(capabilityJsonMap);
+ Either<Map<String, PropertyDefinition>, ResultStatusEnum> propertiesRes = ImportUtils
+ .getProperties(capabilityJsonMap);
if (propertiesRes.isRight()) {
throw new ByActionStatusComponentException(ActionStatus.PROPERTY_NOT_FOUND);
- }
- else {
+ } else {
propertiesRes.left()
- .value()
- .entrySet()
- .stream()
- .forEach(e -> e.getValue().setName(e.getKey().toLowerCase()));
+ .value()
+ .entrySet()
+ .stream()
+ .forEach(e -> e.getValue().setName(e.getKey().toLowerCase()));
List<ComponentInstanceProperty> capabilityProperties = propertiesRes.left()
- .value()
- .values()
- .stream()
- .map(p -> new ComponentInstanceProperty(p, p
- .getDefaultValue(), null))
- .collect(Collectors.toList());
+ .value()
+ .values()
+ .stream()
+ .map(p -> new ComponentInstanceProperty(p, p
+ .getDefaultValue(), null))
+ .collect(Collectors.toList());
capabilityDefinition.setProperties(capabilityProperties);
}
}
- }
- else if (!(capabilityJson instanceof List)) {
+
+ } else if (!(capabilityJson instanceof List)) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_YAML);
}
return capabilityDefinition;
}
- private void handleImportResourceException(UploadResourceInfo resourceMetaData, User user, boolean isNormative, RuntimeException e) {
+ private void handleImportResourceException(UploadResourceInfo resourceMetaData, User user, boolean isNormative,
+ RuntimeException e) {
ResponseFormat responseFormat;
ComponentException newException;
if (e instanceof ComponentException) {
- ComponentException componentException = (ComponentException)e;
+ ComponentException componentException = (ComponentException) e;
responseFormat = componentException.getResponseFormat();
if (responseFormat == null) {
- responseFormat = getResponseFormatManager().getResponseFormat(componentException.getActionStatus(), componentException.getParams());
+ responseFormat = getResponseFormatManager()
+ .getResponseFormat(componentException.getActionStatus(), componentException.getParams());
}
newException = componentException;
- }
- else{
+ } else {
responseFormat = getResponseFormatManager().getResponseFormat(ActionStatus.GENERAL_ERROR);
newException = new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR);
}
@@ -849,13 +924,13 @@ public class ResourceImportManager {
throw newException;
}
- private void auditErrorImport(UploadResourceInfo resourceMetaData, User user, ResponseFormat errorResponseWrapper, boolean isNormative) {
+ private void auditErrorImport(UploadResourceInfo resourceMetaData, User user, ResponseFormat errorResponseWrapper,
+ boolean isNormative) {
String version, lifeCycleState;
if (isNormative) {
version = TypeUtils.getFirstCertifiedVersionVersion();
lifeCycleState = LifecycleStateEnum.CERTIFIED.name();
- }
- else {
+ } else {
version = "";
lifeCycleState = LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name();
@@ -867,23 +942,22 @@ public class ResourceImportManager {
}
message += errorResponseWrapper.getFormattedMessage();
-
AuditEventFactory factory = new AuditImportResourceAdminEventFactory(
- CommonAuditData.newBuilder()
- .status(errorResponseWrapper.getStatus())
- .description(message)
- .requestId(ThreadLocalsHolder.getUuid())
- .build(),
- new ResourceCommonInfo(resourceMetaData.getName(), ComponentTypeEnum.RESOURCE.getValue()),
- ResourceVersionInfo.newBuilder()
- .state(lifeCycleState)
- .version(version)
- .build(),
- ResourceVersionInfo.newBuilder()
- .state("")
- .version("")
- .build(),
- "", user, "");
+ CommonAuditData.newBuilder()
+ .status(errorResponseWrapper.getStatus())
+ .description(message)
+ .requestId(ThreadLocalsHolder.getUuid())
+ .build(),
+ new ResourceCommonInfo(resourceMetaData.getName(), ComponentTypeEnum.RESOURCE.getValue()),
+ ResourceVersionInfo.newBuilder()
+ .state(lifeCycleState)
+ .version(version)
+ .build(),
+ ResourceVersionInfo.newBuilder()
+ .state("")
+ .version("")
+ .build(),
+ "", user, "");
getAuditingManager().auditEvent(factory);
}
@@ -895,15 +969,58 @@ public class ResourceImportManager {
final String payloadData = resourceMetaData.getPayloadData();
if (payloadData != null) {
resource.setToscaVersion(getToscaVersion(payloadData));
+ resource.setAttributes(getAttributes(payloadData));
}
final List<CategoryDefinition> categories = resourceMetaData.getCategories();
calculateResourceIsAbstract(resource, categories);
}
- private String getToscaVersion(final String payloadData) {
+ private List<AttributeDataDefinition> getAttributes(final String payloadData) {
+ final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
+
+ final List<AttributeDataDefinition> attributeDataDefinitionList = new ArrayList<>();
+
+ final Either<Map<String, Object>, ResultStatusEnum> firstToscaMapElement = ImportUtils
+ .findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.ATTRIBUTES);
+ if (firstToscaMapElement.isRight()) {
+ return attributeDataDefinitionList;
+ }
+ final Map<String, Object> attributes = firstToscaMapElement.left().value();
+
+ final Iterator<Entry<String, Object>> propertiesNameValue = attributes.entrySet().iterator();
+ while (propertiesNameValue.hasNext()) {
+ final Entry<String, Object> attributeNameValue = propertiesNameValue.next();
+ final Object value = attributeNameValue.getValue();
+ final String key = attributeNameValue.getKey();
+ if (value instanceof Map) {
+
+ final Map<String, Object> attributeMap = (Map<String, Object>) value;
+
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(key);
+
+ setField(attributeMap, ToscaTagNamesEnum.DESCRIPTION, attributeDefinition::setDescription);
+ setField(attributeMap, ToscaTagNamesEnum.TYPE, attributeDefinition::setType);
+ setField(attributeMap, ToscaTagNamesEnum.STATUS, attributeDefinition::setStatus);
+ setField(attributeMap, ToscaTagNamesEnum.ENTRY_SCHEMA, attributeDefinition::setEntry_schema);
+ attributeDataDefinitionList.add(attributeDefinition);
+ } else {
+ final AttributeDefinition attributeDefinition = new AttributeDefinition();
+ attributeDefinition.setName(key);
+ attributeDataDefinitionList.add(attributeDefinition);
+ }
+ }
+ return attributeDataDefinitionList;
+ }
+
+ private Map<String, Object> decodePayload(final String payloadData) {
final String decodedPayload = new String(Base64.decodeBase64(payloadData));
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(decodedPayload);
+ return (Map<String, Object>) new Yaml().load(decodedPayload);
+ }
+
+ private String getToscaVersion(final String payloadData) {
+ final Map<String, Object> mappedToscaTemplate = decodePayload(payloadData);
final Either<String, ResultStatusEnum> findFirstToscaStringElement =
ImportUtils.findFirstToscaStringElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
return findFirstToscaStringElement.left().value();
@@ -914,7 +1031,7 @@ public class ResourceImportManager {
CategoryDefinition categoryDef = categories.get(0);
resource.setAbstract(false);
if (categoryDef != null && categoryDef.getName() != null && categoryDef.getName()
- .equals(Constants.ABSTRACT_CATEGORY_NAME)) {
+ .equals(Constants.ABSTRACT_CATEGORY_NAME)) {
SubCategoryDefinition subCategoryDef = categoryDef.getSubcategories().get(0);
if (subCategoryDef != null && subCategoryDef.getName().equals(Constants.ABSTRACT_SUBCATEGORY)) {
resource.setAbstract(true);
@@ -929,8 +1046,7 @@ public class ResourceImportManager {
if (shouldBeCertified) {
version = TypeUtils.getFirstCertifiedVersionVersion();
state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE;
- }
- else {
+ } else {
version = ImportUtils.Constants.FIRST_NON_CERTIFIED_VERSION;
state = ImportUtils.Constants.NORMATIVE_TYPE_LIFE_CYCLE_NOT_CERTIFIED_CHECKOUT;
}
@@ -959,8 +1075,7 @@ public class ResourceImportManager {
Integer maxOccurrences;
if (minObj instanceof Integer) {
minOccurrences = (Integer) minObj;
- }
- else {
+ } else {
log.debug("Invalid occurrenses format. low_bound occurrense must be Integer {}", minObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
@@ -969,23 +1084,22 @@ public class ResourceImportManager {
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
- if (maxObj instanceof String){
- if(!"UNBOUNDED".equals(maxObj)) {
+ if (maxObj instanceof String) {
+ if (!"UNBOUNDED".equals(maxObj)) {
log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
- }
- else {
+ } else {
if (maxObj instanceof Integer) {
maxOccurrences = (Integer) maxObj;
- }
- else {
+ } else {
log.debug("Invalid occurrenses format. Max occurrence is {}", maxObj);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
if (maxOccurrences <= 0 || maxOccurrences < minOccurrences) {
- log.debug("Invalid occurrenses format. min occurrence is {}, Max occurrence is {}", minOccurrences, maxOccurrences);
+ log.debug("Invalid occurrenses format. min occurrence is {}, Max occurrence is {}", minOccurrences,
+ maxOccurrences);
throw new ByActionStatusComponentException(ActionStatus.INVALID_OCCURRENCES);
}
}
@@ -1004,7 +1118,8 @@ public class ResourceImportManager {
}
private ResourceBusinessLogic getResourceBL(ServletContext context) {
- WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(org.openecomp.sdc.common.api.Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
+ WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context
+ .getAttribute(org.openecomp.sdc.common.api.Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
return webApplicationContext.getBean(ResourceBusinessLogic.class);
}
@@ -1033,7 +1148,7 @@ public class ResourceImportManager {
public void setResourceBusinessLogic(ResourceBusinessLogic resourceBusinessLogic) {
this.resourceBusinessLogic = resourceBusinessLogic;
}
-
+
@Autowired
public void setInterfaceOperationBusinessLogic(InterfaceOperationBusinessLogic interfaceOperationBusinessLogic) {
this.interfaceOperationBusinessLogic = interfaceOperationBusinessLogic;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
index 3050128531..9f54f1fae8 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
@@ -31,9 +31,7 @@ import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.servers.Server;
-import io.swagger.v3.oas.annotations.servers.Servers;
import io.swagger.v3.oas.annotations.tags.Tag;
-import io.swagger.v3.oas.annotations.tags.Tags;
import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
@@ -41,9 +39,10 @@ import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
-import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.openecomp.sdc.be.model.AttributeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.Constants;
@@ -76,8 +75,8 @@ import java.io.IOException;
*/
@Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
@Path("/v1/catalog")
-@Tags({@Tag(name = "SDC Internal APIs")})
-@Servers({@Server(url = "/sdc2/rest")})
+@Tag(name = "SDC Internal APIs")
+@Server(url = "/sdc2/rest")
@Controller
public class AttributeServlet extends AbstractValidationsServlet {
private static final Logger log = Logger.getLogger(AttributeServlet.class);
@@ -124,13 +123,13 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
+ Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
// convert json to AttributeDefinition
buildAttributeFromString(data, attributesWrapper, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
+ Either<AttributeDataDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
if (createAttribute.isRight()) {
errorWrapper.setInnerElement(createAttribute.right().value());
} else {
@@ -143,7 +142,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to create Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- PropertyDefinition createdAttDef = attributesWrapper.getInnerElement();
+ AttributeDataDefinition createdAttDef = attributesWrapper.getInnerElement();
log.debug("Attribute {} created successfully with id {}", createdAttDef.getName(), createdAttDef.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(createdAttDef));
@@ -200,14 +199,14 @@ public class AttributeServlet extends AbstractValidationsServlet {
try {
// convert json to PropertyDefinition
Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
- Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
+ Wrapper<AttributeDataDefinition> attributesWrapper = new Wrapper<>();
// convert json to AttributeDefinition
buildAttributeFromString(data, attributesWrapper, errorWrapper);
if (errorWrapper.isEmpty()) {
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
// update property
if (eitherUpdateAttribute.isRight()) {
errorWrapper.setInnerElement(eitherUpdateAttribute.right().value());
@@ -221,7 +220,7 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.info("Failed to update Attribute. Reason - ", errorWrapper.getInnerElement());
response = buildErrorResponse(errorWrapper.getInnerElement());
} else {
- PropertyDefinition updatedAttribute = attributesWrapper.getInnerElement();
+ AttributeDataDefinition updatedAttribute = attributesWrapper.getInnerElement();
log.debug("Attribute id {} updated successfully ", updatedAttribute.getUniqueId());
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(updatedAttribute));
@@ -271,15 +270,14 @@ public class AttributeServlet extends AbstractValidationsServlet {
log.debug("modifier id is {}", userId);
try {
-
// delete the property
AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
- Either<PropertyDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
+ Either<AttributeDataDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
if (eitherAttribute.isRight()) {
log.debug("Failed to delete Attribute. Reason - ", eitherAttribute.right().value());
return buildErrorResponse(eitherAttribute.right().value());
}
- PropertyDefinition attributeDefinition = eitherAttribute.left().value();
+ AttributeDataDefinition attributeDefinition = eitherAttribute.left().value();
String name = attributeDefinition.getName();
log.debug("Attribute {} deleted successfully with id {}", name, attributeDefinition.getUniqueId());
@@ -293,11 +291,11 @@ public class AttributeServlet extends AbstractValidationsServlet {
}
}
- private void buildAttributeFromString(String data, Wrapper<PropertyDefinition> attributesWrapper,
+ private void buildAttributeFromString(String data, Wrapper<AttributeDataDefinition> attributesWrapper,
Wrapper<ResponseFormat> errorWrapper) {
try {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
- final PropertyDefinition attribute = gson.fromJson(data, PropertyDefinition.class);
+ final AttributeDataDefinition attribute = gson.fromJson(data, AttributeDefinition.class);
if (attribute == null) {
log.info(ATTRIBUTE_CONTENT_IS_INVALID, data);
ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
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 13a90a822f..518ed5726c 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
@@ -54,6 +54,7 @@ import org.openecomp.sdc.be.components.impl.exceptions.SdcResourceNotFoundExcept
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CINodeFilterDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
@@ -1060,6 +1061,14 @@ public class ToscaExportHandler {
: NATIVE_ROOT;
toscaNodeType.setDerived_from(derivedFrom);
}
+ if (component instanceof Resource) {
+ final List<AttributeDataDefinition> attributes = ((Resource) component).getAttributes();
+ if (CollectionUtils.isNotEmpty(attributes)) {
+ final Map<String, AttributeDataDefinition> attributeDataDefinitionMap
+ = attributes.stream().collect(Collectors.toMap(AttributeDataDefinition::getName, a -> a));
+ toscaNodeType.setAttributes(attributeDataDefinitionMap);
+ }
+ }
return toscaNodeType;
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
index b7fe3bc13a..04515b297c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/model/ToscaNodeTemplate.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.tosca.model;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -31,6 +32,7 @@ import java.util.Map;
@Getter
@Setter
+@NoArgsConstructor
public class ToscaNodeTemplate {
private String type;
@@ -45,11 +47,7 @@ public class ToscaNodeTemplate {
private Map<String, Object> interfaces;
public void setDirectives(List<String> directives) {
- if (CollectionUtils.isEmpty(directives)) {
- this.directives = null;
- return;
- }
- this.directives = directives;
+ this.directives = CollectionUtils.isEmpty(directives) ? null : directives;
}
public void addInterface(String interfaceName, Object interfaceDataDefinition) {
@@ -60,4 +58,3 @@ public class ToscaNodeTemplate {
this.interfaces.put(interfaceName, interfaceDataDefinition);
}
}
-
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 0d0cfb27b7..b5e5866fe4 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
@@ -22,75 +22,25 @@ package org.openecomp.sdc.be.tosca.model;
import java.util.List;
import java.util.Map;
-
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
+
+@Getter
+@Setter
+@NoArgsConstructor
public class ToscaNodeType {
- public ToscaNodeType() {
- }
-
private ToscaMetadata metadata;
private String derived_from;
private String description;
private Map<String, ToscaProperty> properties;
- private Map<String, Object> interfaces; //ToscaInterfaceDefinition
+ private Map<String, Object> interfaces;
private Map<String, ToscaCapability> capabilities;
private List<Map<String, ToscaRequirement>> requirements;
+ private Map<String, AttributeDataDefinition> attributes;
- public Map<String, ToscaProperty> getProperties() {
- return properties;
- }
-
- public void setProperties(Map<String, ToscaProperty> properties) {
- this.properties = properties;
- }
-
- public Map<String, ToscaCapability> getCapabilities() {
- return capabilities;
- }
-
- public void setCapabilities(Map<String, ToscaCapability> capabilities) {
- this.capabilities = capabilities;
- }
-
- public List<Map<String, ToscaRequirement>> getRequirements() {
- return requirements;
- }
-
- public void setRequirements(List<Map<String, ToscaRequirement>> requirements) {
- this.requirements = requirements;
- }
-
- public String getDerived_from() {
- return derived_from;
- }
-
- public void setDerived_from(String derived_from) {
- this.derived_from = derived_from;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public ToscaMetadata getMetadata() {
- return metadata;
- }
-
- public void setMetadata(ToscaMetadata metadata) {
- this.metadata = metadata;
- }
-
- public Map<String, Object> getInterfaces() {
- return interfaces;
- }
-
- public void setInterfaces(Map<String, Object> interfaces) {
- this.interfaces = interfaces;
- }
}