aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org/openecomp
diff options
context:
space:
mode:
authorSatoshi Fujii <fujii-satoshi@jp.fujitsu.com>2019-05-20 16:00:56 +0900
committerOren Kleks <orenkle@amdocs.com>2019-05-20 12:37:00 +0000
commitc0b223d4fa51947c1aad771cae210678554aff3e (patch)
treefc6a6625dd32b9ef19bdc87042583383d4ed6855 /catalog-model/src/main/java/org/openecomp
parent258900e4a46d7e414e526e7322b0d6319fdb79a8 (diff)
Fixed declared properties are not updated properly
Change-Id: I3712f9656d7cdeb8fa9c4212b2dd1496043c1006 Issue-ID: SDC-2314 Signed-off-by: Satoshi Fujii <fujii-satoshi@jp.fujitsu.com>
Diffstat (limited to 'catalog-model/src/main/java/org/openecomp')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java60
1 files changed, 30 insertions, 30 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 4482f7f943..dd9c3ca29e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -20,7 +20,6 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
-import com.datastax.driver.core.DataType;
import fj.data.Either;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
@@ -47,7 +46,6 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
-import org.openecomp.sdc.be.resources.data.DataTypeData;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility;
import org.openecomp.sdc.common.jsongraph.util.CommonUtility.LogLevelEnum;
import org.openecomp.sdc.common.log.wrappers.Logger;
@@ -1236,30 +1234,31 @@ public class ToscaOperationFacade {
public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addComponentInstancePropertiesToComponent(Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
requireNonNull(instProperties);
- StorageOperationStatus status = null;
for (Entry<String, List<ComponentInstanceProperty>> entry : instProperties.entrySet()) {
List<ComponentInstanceProperty> props = entry.getValue();
String componentInstanceId = entry.getKey();
-
+ List<ComponentInstanceProperty> originalComponentInstProps =
+ containerComponent.getComponentInstancesProperties().get(componentInstanceId);
Map<String, List<CapabilityDefinition>> containerComponentCapabilities = containerComponent.getCapabilities();
- if (!isEmpty(props)) {
- for (ComponentInstanceProperty property : props) {
- String propertyParentUniqueId = property.getParentUniqueId();
- Optional<CapabilityDefinition>
- capPropDefinition = getPropertyCapability(propertyParentUniqueId, containerComponent);
- if(capPropDefinition.isPresent() && MapUtils.isNotEmpty(containerComponentCapabilities)) {
- status = populateAndUpdateInstanceCapProperty(containerComponent, componentInstanceId,
- containerComponentCapabilities, property, capPropDefinition.get());
- }
- if(status == null) {
- List<ComponentInstanceProperty> instanceProperties = containerComponent
- .getComponentInstancesProperties().get(componentInstanceId);
- status = updateInstanceProperty(containerComponent, componentInstanceId, instanceProperties, property);
- }
- if(status != StorageOperationStatus.OK) {
- return Either.right(status);
- }
+ if(isEmpty(props)) {
+ continue;
+ }
+ for (ComponentInstanceProperty property : props) {
+ StorageOperationStatus status = null;
+ String propertyParentUniqueId = property.getParentUniqueId();
+ Optional<CapabilityDefinition>
+ capPropDefinition = getPropertyCapability(propertyParentUniqueId, containerComponent);
+ if(capPropDefinition.isPresent() && MapUtils.isNotEmpty(containerComponentCapabilities)) {
+ status = populateAndUpdateInstanceCapProperty(containerComponent, componentInstanceId,
+ containerComponentCapabilities, property, capPropDefinition.get());
+ }
+ if(status == null) {
+ status = updateOrAddComponentInstanceProperty(containerComponent, componentInstanceId,
+ originalComponentInstProps, property);
+ }
+ if(status != StorageOperationStatus.OK) {
+ return Either.right(status);
}
}
}
@@ -1299,23 +1298,24 @@ public class ToscaOperationFacade {
.findAny();
}
- private StorageOperationStatus updateInstanceProperty(Component containerComponent, String componentInstanceId,
- List<ComponentInstanceProperty> instanceProperties,
- ComponentInstanceProperty property) {
+ private StorageOperationStatus updateOrAddComponentInstanceProperty(Component containerComponent,
+ String componentInstanceId, List<ComponentInstanceProperty> originalComponentInstProps,
+ ComponentInstanceProperty property)
+ {
StorageOperationStatus status;
- Optional<ComponentInstanceProperty> instanceProperty = instanceProperties.stream()
- .filter(p -> p.getUniqueId().equals(property.getUniqueId()))
- .findAny();
+ // check if the property already exists or not
+ Optional<ComponentInstanceProperty> instanceProperty = originalComponentInstProps.stream()
+ .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
if (instanceProperty.isPresent()) {
status = updateComponentInstanceProperty(containerComponent, componentInstanceId, property);
} else {
status = addComponentInstanceProperty(containerComponent, componentInstanceId, property);
}
if (status != StorageOperationStatus.OK) {
- log.debug("Failed to update instance property {} for instance {} error {} ", property, componentInstanceId, status);
- return status;
+ log.debug("Failed to update instance property {} for instance {} error {} ",
+ property, componentInstanceId, status);
}
- return StorageOperationStatus.OK;
+ return status;
}
public StorageOperationStatus updateInstanceCapabilityProperty(Component containerComponent, String componentInstanceId,