From 6301770df5b399f7dd2b8cce9a0ad1051845765e Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Fri, 8 Nov 2019 11:17:37 +0100 Subject: fix wrong handling of checking null values Checking null values is handled by catching null pointer exception, this is not acceptable. Change-Id: I0c43bc8853b67579a50bc9e69c599b93b978f741 Issue-ID: SO-2187 Signed-off-by: Lukasz Muszkieta --- .../workflow/tasks/WorkflowAction.java | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'bpmn/so-bpmn-tasks') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 11c6455474..c3f5a98ce7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -71,11 +71,13 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; import org.onap.so.serviceinstancebeans.Networks; import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestInfo; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.serviceinstancebeans.VfModules; @@ -182,21 +184,7 @@ public class WorkflowAction { execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); - String cloudOwner = ""; - try { - cloudOwner = requestDetails.getCloudConfiguration().getCloudOwner(); - } catch (Exception ex) { - logger.error("Exception in getCloundOwner", ex); - cloudOwner = environment.getProperty(defaultCloudOwner); - } - boolean suppressRollback = false; - try { - suppressRollback = requestDetails.getRequestInfo().getSuppressRollback(); - } catch (Exception ex) { - logger.error("Exception in getSuppressRollback", ex); - suppressRollback = false; - } - execution.setVariable("suppressRollback", suppressRollback); + execution.setVariable("suppressRollback", isSuppressRollback(requestDetails.getRequestInfo())); boolean isResume = false; if (isUriResume(uri)) { isResume = true; @@ -234,6 +222,7 @@ public class WorkflowAction { "Could not resume request with request Id: " + requestId + ". No flowsToExecute was found"); } } else { + String cloudOwner = getCloudOwner(requestDetails.getCloudConfiguration()); if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, @@ -410,6 +399,21 @@ public class WorkflowAction { } } + private String getCloudOwner(CloudConfiguration cloudConfiguration) { + if (cloudConfiguration != null && cloudConfiguration.getCloudOwner() != null) { + return cloudConfiguration.getCloudOwner(); + } + logger.warn("cloud owner value not found in request details, it will be set as default"); + return environment.getProperty(defaultCloudOwner); + } + + private boolean isSuppressRollback(RequestInfo requestInfo) { + if (requestInfo != null) { + return requestInfo.getSuppressRollback(); + } + return false; + } + protected List getRelatedResourcesInVfModule(String vnfId, String vfModuleId, Class resultClass, AAIObjectType type) { List vnfcs = new ArrayList<>(); -- cgit 1.2.3-korg