summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java10
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java25
2 files changed, 28 insertions, 7 deletions
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 8d12751c07..ef55381974 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
@@ -2853,6 +2853,16 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
} else {
origComponent = getOriginComponentFromComponentInstance(newComponentInstance);
newComponentInstance.setName(resResourceInfo.getName());
+ final Either<Component, StorageOperationStatus> getComponentRes = toscaOperationFacade
+ .getToscaFullElement(newComponentInstance.getComponentUid());
+ if (getComponentRes.isRight()) {
+ throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getComponentRes.right().value()));
+ }
+ final Component component = getComponentRes.left().value();
+ final Map<String, InterfaceDefinition> componentInterfaces = component.getInterfaces();
+ if (MapUtils.isNotEmpty(componentInterfaces)) {
+ componentInterfaces.forEach(newComponentInstance::addInterface);
+ }
}
newComponentInstance.setInvariantName(resResourceInfo.getInvariantName());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java
index 2d49eaeffe..43da6181cd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java
@@ -74,18 +74,29 @@ public class ComponentInstanceInterfacesMerge implements ComponentInstanceMergeI
newOperationDef -> prevInstanceInterfaces.stream().filter(in -> in.getUniqueId().equals(newInterfaceDef.getUniqueId())).forEach(
prevInterfaceDef -> prevInterfaceDef.getOperationsMap().values().stream()
.filter(in1 -> in1.getUniqueId().equals(newOperationDef.getUniqueId()))
- .forEach(oldOperationDef -> mergeOperationInputDefinitions(oldOperationDef.getInputs(), newOperationDef.getInputs())))));
+ .forEach(oldOperationDef -> {
+ if(oldOperationDef.getInputs() != null) {
+ if(newOperationDef.getInputs() == null) {
+ newOperationDef.setInputs(new ListDataDefinition<>());
+ }
+ mergeOperationInputDefinitions(oldOperationDef.getInputs(), newOperationDef.getInputs());
+ }
+ }))));
StorageOperationStatus updateStatus = toscaOperationFacade.updateComponentInstanceInterfaces(currentComponent, instanceId);
return componentsUtils.convertFromStorageResponse(updateStatus);
}
private void mergeOperationInputDefinitions(ListDataDefinition<OperationInputDefinition> origInputs,
ListDataDefinition<OperationInputDefinition> newInputs) {
- newInputs.getListToscaDataDefinition()
- .forEach(inp -> origInputs.getListToscaDataDefinition().stream().filter(in -> in.getInputId().equals(inp.getInputId())).forEach(in -> {
- inp.setSourceProperty(in.getSourceProperty());
- inp.setSource(in.getSource());
- inp.setValue(in.getValue());
- }));
+ newInputs.getListToscaDataDefinition().
+ forEach(inp -> origInputs.getListToscaDataDefinition().stream().filter(in -> in.getInputId().equals(inp.getInputId())).
+ forEach(in -> {
+ inp.setSourceProperty(in.getSourceProperty());
+ inp.setSource(in.getSource());
+ inp.setValue(in.getValue());
+ }));
+ origInputs.getListToscaDataDefinition().stream().
+ filter(inp -> newInputs.getListToscaDataDefinition().stream().noneMatch(in -> in.getInputId().equals(inp.getInputId()))).
+ forEach(inp -> newInputs.getListToscaDataDefinition().add(inp));
}
}