summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
authorChris André <chris.andre@yoppworks.com>2020-04-21 12:25:29 -0400
committerOjas Dubey <Ojas.Dubey@amdocs.com>2020-05-06 05:40:35 +0000
commit57ac9cec55b6470da859330a0fcab70e35422b3c (patch)
treefda1356d94afc637b6bf637c851d20abe9467adb /catalog-be/src
parentc9c7f88f77c9cab341485c27e1e67f6294a0b1c2 (diff)
Handle null case in `addCalculatedCapabilitiesWithPropertiesToComponent`
- Change code to handle a null value for `groupDefinitions` as if it was an empty List Issue-ID: SDC-2910 Signed-off-by: Chris Andre <chris.andre@yoppworks.com> Change-Id: I5fca0ab76886e5f6a73a8f05ec35d38848f96dd8
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index 417380b5d9..e0bf727408 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -23,6 +23,7 @@
package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
+import java.util.Vector;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.io.FilenameUtils;
@@ -1181,12 +1182,20 @@ public class GroupBusinessLogic extends BaseBusinessLogic {
}
}
- private void addCalculatedCapabilitiesWithPropertiesToComponent(Component component, final List<GroupDefinition> groupDefinitions, boolean fromCsar) {
- groupDefinitions.forEach(GroupDefinition::updateEmptyCapabilitiesOwnerFields);
- StorageOperationStatus status = groupsOperation.addCalculatedCapabilitiesWithProperties(component.getUniqueId(),
- extractCapabilitiesFromGroups(groupDefinitions), extractCapabilityPropertiesFromGroups(groupDefinitions, fromCsar));
- if(status != StorageOperationStatus.OK){
- log.error("#addCalculatedCapabilitiesWithPropertiesToComponent - failed to add the groups' calculated capabilities with the properties to the component {}. ", component.getUniqueId());
+ private void addCalculatedCapabilitiesWithPropertiesToComponent(Component component,
+ final List<GroupDefinition> groupDefinitions, boolean fromCsar) {
+ final List<GroupDefinition> nonNullGroupDefinitions =
+ (groupDefinitions == null) ? Collections.emptyList() : groupDefinitions;
+
+ nonNullGroupDefinitions.forEach(GroupDefinition::updateEmptyCapabilitiesOwnerFields);
+ StorageOperationStatus status = groupsOperation.addCalculatedCapabilitiesWithProperties(
+ component.getUniqueId(),
+ extractCapabilitiesFromGroups(nonNullGroupDefinitions),
+ extractCapabilityPropertiesFromGroups(nonNullGroupDefinitions, fromCsar));
+ if (status != StorageOperationStatus.OK) {
+ log.error(
+ "#addCalculatedCapabilitiesWithPropertiesToComponent - failed to add the groups' calculated capabilities with the properties to the component {}. ",
+ component.getUniqueId());
rollbackWithException(componentsUtils.convertFromStorageResponse(status));
}
}