diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-05-31 18:31:59 +0100 |
---|---|---|
committer | Vasyl Razinkov <vasyl.razinkov@est.tech> | 2022-06-03 11:09:32 +0000 |
commit | ff317808f308af03321de0f0b0849cd9f6f8ccad (patch) | |
tree | 71dd9b6d55ecc7650332ebd99c9d6682e6a0c094 /catalog-be/src/main | |
parent | a2313b70009cae09db66ccc7b542ec4679e6a23a (diff) |
Maintain VFC UI added interface operations after an upgrade
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: I908a4480a8929f9aeeabf4f5c14049cade6ae22b
Issue-ID: SDC-4018
Diffstat (limited to 'catalog-be/src/main')
2 files changed, 19 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java index 4e44967dcb..461edd11dc 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java @@ -249,6 +249,7 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic interfaceDefinition.setUniqueId(componentInterfaceUpdatedKey); interfaceDefinition.setToscaResourceName(componentInterfaceUpdatedKey); + interfaceDefinition.setUserCreated(true); final Optional<OperationDataDefinition> optionalOperationDataDefinition = interfaceDefinition.getOperations().values().stream().findFirst(); if (optionalOperationDataDefinition.isEmpty()) { 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 8fe742af50..aa420673c7 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 @@ -380,7 +380,7 @@ public class ResourceImportManager { setProperties(toscaJson, resource, existingResource); setAttributes(toscaJson, resource); setRequirements(toscaJson, resource, parentResource); - setInterfaceLifecycle(toscaJson, resource); + setInterfaceLifecycle(toscaJson, resource, existingResource); } else { throw new ByActionStatusComponentException(ActionStatus.GENERAL_ERROR); } @@ -434,12 +434,13 @@ public class ResourceImportManager { } } - private void setInterfaceLifecycle(Map<String, Object> toscaJson, Resource resource) { - Either<Map<String, Object>, ResultStatusEnum> toscaInterfaces = ImportUtils + 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); if (toscaInterfaces.isLeft()) { - Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>(); - for (final Entry<String, Object> interfaceNameValue : toscaInterfaces.left().value().entrySet()) { + final Map<String, InterfaceDefinition> moduleInterfaces = new HashMap<>(); + final Map<String, Object> map = toscaInterfaces.left().value(); + for (final Entry<String, Object> interfaceNameValue : map.entrySet()) { final Either<InterfaceDefinition, ResultStatusEnum> eitherInterface = createModuleInterface(interfaceNameValue.getValue(), resource.getModel()); if (eitherInterface.isRight()) { @@ -449,7 +450,18 @@ public class ResourceImportManager { moduleInterfaces.put(interfaceDefinition.getType(), interfaceDefinition); } } - if (!moduleInterfaces.isEmpty()) { + 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); } } |