summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-08-18 19:40:44 +0100
committerJEFF VAN DAM <jeff.van.dam@est.tech>2023-08-21 14:55:31 +0000
commitfda41360dcb7e68c8e3003c73fdb98db2514bf5f (patch)
tree807aaed239a38f75af88374bc7a40ec114090ab9
parentd32437595314c9b5b2aa439a482d0b07286a8072 (diff)
Fix 'Fail to import service with CP'-bug
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I7261b03eb7e796aaa66ac3dbd0116bc62d2d6e71 Issue-ID: SDC-4599
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java28
-rw-r--r--catalog-ui/src/app/utils/service-csar-reader.ts7
2 files changed, 25 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 1ba74a1594..bf27d030b5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -539,7 +539,8 @@ public class ServiceImportBusinessLogic {
&& result.left().value().getProperties().size() != dataType.get("properties").size();
}
- private void createNodeTypes(List<NodeTypeDefinition> nodeTypesToCreate, Map<String, UploadComponentInstanceInfo> instancesFromCsar, String model, User user) {
+ private void createNodeTypes(List<NodeTypeDefinition> nodeTypesToCreate, Map<String, UploadComponentInstanceInfo> instancesFromCsar, String model,
+ User user) {
NodeTypesMetadataList nodeTypesMetadataList = new NodeTypesMetadataList();
List<NodeTypeMetadata> nodeTypeMetadataList = new ArrayList<>();
final Map<String, Object> allTypesToCreate = new HashMap<>();
@@ -611,7 +612,7 @@ public class ServiceImportBusinessLogic {
private void combineInterfacesIntoToscaTemplate(Map<String, Map<String, Object>> newInterfaces,
Map<String, Map<String, Object>> existingInterfaces,
Map<String, Object> combinedMappedToscaTemplate) {
- Map<String, Map<String, Object>> combinedInterfaces = combineAdditionalInterfaces(existingInterfaces, newInterfaces);
+ Map<String, Map<String, Object>> combinedInterfaces = combineAdditionalInterfaces(newInterfaces, existingInterfaces);
if ((MapUtils.isEmpty(existingInterfaces) && MapUtils.isNotEmpty(combinedInterfaces))
|| (MapUtils.isNotEmpty(existingInterfaces) && !existingInterfaces.equals(combinedInterfaces))) {
combinedMappedToscaTemplate.put("interfaces", combinedInterfaces);
@@ -654,8 +655,11 @@ public class ServiceImportBusinessLogic {
}
}
- private Map<String, Map<String, Object>> combineAdditionalInterfaces(Map<String, Map<String, Object>> existingInterfaces,
- Map<String, Map<String, Object>> newInterfaces) {
+ private Map<String, Map<String, Object>> combineAdditionalInterfaces(Map<String, Map<String, Object>> newInterfaces,
+ Map<String, Map<String, Object>> existingInterfaces) {
+ if (MapUtils.isNotEmpty(newInterfaces) && MapUtils.isNotEmpty(existingInterfaces) && newInterfaces.equals(existingInterfaces)) {
+ return new HashMap<>(existingInterfaces);
+ }
if (MapUtils.isEmpty(newInterfaces)) {
newInterfaces = new HashMap<>();
}
@@ -676,6 +680,9 @@ public class ServiceImportBusinessLogic {
private List<Map<String, Object>> combineAdditionalRequirements(List<Map<String, Object>> newReqs,
List<Map<String, Object>> existingResourceReqs) {
+ if (CollectionUtils.isNotEmpty(newReqs) && CollectionUtils.isNotEmpty(existingResourceReqs) && newReqs.equals(existingResourceReqs)) {
+ return new ArrayList<>(existingResourceReqs);
+ }
if (CollectionUtils.isEmpty(existingResourceReqs)) {
existingResourceReqs = new ArrayList<>();
}
@@ -690,6 +697,9 @@ public class ServiceImportBusinessLogic {
}
private Map<String, Object> combineEntries(Map<String, Object> newMap, Map<String, Object> existingMap) {
+ if (MapUtils.isNotEmpty(newMap) && MapUtils.isNotEmpty(existingMap) && newMap.equals(existingMap)) {
+ return new HashMap<>(existingMap);
+ }
if (MapUtils.isEmpty(newMap)) {
newMap = new HashMap<>();
}
@@ -861,7 +871,8 @@ public class ServiceImportBusinessLogic {
}
}
if (CollectionUtils.isNotEmpty(propertyMissingNames)) {
- throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.MISSING_PROPERTIES_ERROR, propertyMissingNames.toString()));
+ throw new ComponentException(
+ componentsUtils.getResponseFormat(ActionStatus.MISSING_PROPERTIES_ERROR, propertyMissingNames.toString()));
}
Either<List<InputDefinition>, StorageOperationStatus> either = toscaOperationFacade.updateInputsToComponent(inputs, componentUniqueId);
if (either.isRight()) {
@@ -927,8 +938,8 @@ public class ServiceImportBusinessLogic {
}
private String associateInputToServiceProperty(final String userId,
- final InputDefinition input, final Service component,
- final Map<String, List<String>> substitutionMappingProperties) {
+ final InputDefinition input, final Service component,
+ final Map<String, List<String>> substitutionMappingProperties) {
final List<PropertyDefinition> properties = component.getProperties();
if (CollectionUtils.isNotEmpty(properties) && MapUtils.isNotEmpty(substitutionMappingProperties)) {
AtomicReference<String> propertyNameFromInput = new AtomicReference<>(" ");
@@ -2388,7 +2399,8 @@ public class ServiceImportBusinessLogic {
Map<String, OperationDataDefinition> operations = uploadInterfaceInfo.getOperations();
for (Map.Entry<String, OperationDataDefinition> operation : operations.entrySet()) {
OperationDataDefinition instanceOperation = operation.getValue();
- OperationDataDefinition templateOperation = currentInterfaceDef.getOperationsMap().getOrDefault(operation.getKey(), new Operation(instanceOperation));
+ OperationDataDefinition templateOperation = currentInterfaceDef.getOperationsMap()
+ .getOrDefault(operation.getKey(), new Operation(instanceOperation));
//Inputs
ListDataDefinition<OperationInputDefinition> instanceInputs = instanceOperation.getInputs();
if (null != instanceInputs) {
diff --git a/catalog-ui/src/app/utils/service-csar-reader.ts b/catalog-ui/src/app/utils/service-csar-reader.ts
index 20dfe6ca6b..4c9b0cd0ca 100644
--- a/catalog-ui/src/app/utils/service-csar-reader.ts
+++ b/catalog-ui/src/app/utils/service-csar-reader.ts
@@ -82,7 +82,10 @@ export class ServiceCsarReader {
}
private readSubstitutionNodeFromMainTemplateFile(entryDefinitionFileContent) {
- this.serviceCsar.substitutionNodeType = load(entryDefinitionFileContent).topology_template.substitution_mappings.node_type;
+ const loadEntryDefinitionFileContent = load(entryDefinitionFileContent);
+ if (loadEntryDefinitionFileContent.topology_template && loadEntryDefinitionFileContent.topology_template.substitution_mappings) {
+ this.serviceCsar.substitutionNodeType = loadEntryDefinitionFileContent.topology_template.substitution_mappings.node_type;
+ }
}
private setMetadata = (metadata:object) : void => {
@@ -147,4 +150,4 @@ export class ServiceCsarReader {
});
this.serviceCsar.extraServiceMetadata = extraServiceMetadata;
}
-} \ No newline at end of file
+}