diff options
author | MichaelMorris <michael.morris@est.tech> | 2023-01-31 22:42:55 +0000 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2023-02-10 00:12:39 +0000 |
commit | 9c057c26f14de77dff432403941322edaca7ea4e (patch) | |
tree | 60a5c37b189c9159ac3530fd395fbb145fef3745 /catalog-be/src | |
parent | abbc25ad32db4f4c898bdaaea0b66c0a1d5fd8da (diff) |
Fix inconsistencies in interface property removal
Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-4377
Change-Id: Iaeebddfbc7c9e2d7249040db031ccda93746e9b3
Diffstat (limited to 'catalog-be/src')
2 files changed, 19 insertions, 17 deletions
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 2f71959d9d..1d0be1f4c1 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 @@ -3643,9 +3643,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic { if (MapUtils.isEmpty(newResource.getToscaArtifacts())) { setToscaArtifactsPlaceHolders(newResource, user); } - if (MapUtils.isEmpty(newResource.getInterfaces())) { - newResource.setInterfaces(oldResource.getInterfaces()); - } + if (CollectionUtils.isEmpty(newResource.getAttributes())) { newResource.setAttributes(oldResource.getAttributes()); } 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 076dd50655..7710a4878b 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 @@ -27,6 +27,7 @@ import static org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaElementO import fj.data.Either; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Comparator; import java.util.EnumMap; import java.util.HashMap; @@ -453,9 +454,10 @@ public class ResourceImportManager { private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource, Either<Resource, StorageOperationStatus> existingResource) { final Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils .findFirstToscaMapElement(toscaJson, ToscaTagNamesEnum.INTERFACES); + final Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>(); + final Map<String, Object> map; if (toscaInterfaces.isLeft()) { - final Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>(); - final Map<String, Object> map = toscaInterfaces.left().value(); + map = toscaInterfaces.left().value(); for (final Entry<String, Object> interfaceNameValue : map.entrySet()) { final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue(), resource.getModel()); @@ -466,20 +468,22 @@ public class ResourceImportManager { moduleInterfaces.put(interfaceDefinition.getType(), interfaceDefinition); } } - if (existingResource.isLeft()) { - final Map<String, InterfaceDefinition> userCreatedInterfaceDefinitions = - existingResource.left().value().getInterfaces().entrySet().stream() - .filter(i -> i.getValue().isUserCreated()) - .filter(i -> !map.containsKey(i.getValue().getType())) - .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); - if (MapUtils.isNotEmpty(userCreatedInterfaceDefinitions)) { - moduleInterfaces.putAll(userCreatedInterfaceDefinitions); - } + } else { + map = Collections.emptyMap(); + } + if (existingResource.isLeft()) { + final Map<String, InterfaceDefinition> userCreatedInterfaceDefinitions = + existingResource.left().value().getInterfaces().entrySet().stream() + .filter(i -> i.getValue().isUserCreated()) + .filter(i -> !map.containsKey(i.getValue().getType())) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + if (MapUtils.isNotEmpty(userCreatedInterfaceDefinitions)) { + moduleInterfaces.putAll(userCreatedInterfaceDefinitions); } + } - if (MapUtils.isNotEmpty(moduleInterfaces)) { - resource.setInterfaces(moduleInterfaces); - } + if (MapUtils.isNotEmpty(moduleInterfaces)) { + resource.setInterfaces(moduleInterfaces); } } |