From cb44534e601539dbe1b882da257f9defad57f5f3 Mon Sep 17 00:00:00 2001 From: vasraz Date: Wed, 17 Feb 2021 12:45:11 +0000 Subject: Fix 'not deleting Outputs' Change-Id: I1a5ab1dec4ab7ec381df157e9c12dc8fa00e82c4 Signed-off-by: Vasyl Razinkov Issue-ID: SDC-3448 --- .../impl/ComponentInstanceBusinessLogic.java | 48 +++++++++++++--------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'catalog-be') 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 5729d246cf..a18d8dc8e4 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 @@ -93,6 +93,7 @@ import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.InputDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; import org.openecomp.sdc.be.model.LifecycleStateEnum; +import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.PolicyDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RelationshipInfo; @@ -1559,6 +1560,17 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } } + if (CollectionUtils.isNotEmpty(containerComponent.getOutputs())) { + final List outputsToDelete = containerComponent.getOutputs().stream().filter(i -> i.getInstanceUniqueId() != null && i.getInstanceUniqueId().equals(componentInstanceId)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(outputsToDelete)) { + final StorageOperationStatus deleteOutputsRes = toscaOperationFacade.deleteComponentInstanceOutputsFromTopologyTemplate(containerComponent, outputsToDelete); + if (deleteOutputsRes != StorageOperationStatus.OK) { + log.debug("Failed to delete outputs of the component instance {} from container component. ", componentInstanceId); + throw new ByActionStatusComponentException( + componentsUtils.convertFromStorageResponse(deleteOutputsRes, containerComponentType), componentInstanceId); + } + } + } return deletedInstance; } @@ -3342,25 +3354,23 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { String sourceAttributeName = sourceAttribute.getName(); for (ComponentInstanceAttribute destAttribute : destAttributeList) { if (sourceAttributeName.equals(destAttribute.getName())) { -// 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 updateAttributeValueEither = - createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum.SERVICE, - destComponent.getUniqueId(), destComponentInstanceId, sourceAttribute, - userId); - if (updateAttributeValueEither.isRight()) { - log.error("Failed to copy the attribute"); - return Either.right(componentsUtils - .getResponseFormat(ActionStatus.INVALID_CONTENT_PARAM, - "Failed to paste component instance to the canvas, attribute copy")); - } - break; -// } + log.debug("Start to copy the attribute exists {}", sourceAttributeName); + + sourceAttribute.setUniqueId( + UniqueIdBuilder.buildResourceInstanceUniuqeId( + "attribute", destComponentInstanceId.split("\\.")[1], sourceAttributeName)); + + Either updateAttributeValueEither = + createOrUpdateAttributeValueForCopyPaste(ComponentTypeEnum.SERVICE, + destComponent.getUniqueId(), destComponentInstanceId, sourceAttribute, + userId); + if (updateAttributeValueEither.isRight()) { + log.error("Failed to copy the attribute"); + return Either.right(componentsUtils + .getResponseFormat(ActionStatus.INVALID_CONTENT_PARAM, + "Failed to paste component instance to the canvas, attribute copy")); + } + break; } } } -- cgit 1.2.3-korg