aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-18 16:23:55 +0530
committerSkip Wonnell <skip@att.com>2017-09-19 14:27:55 +0000
commit807828291309411ab6bae1fe27bbf300fbe7b094 (patch)
tree955f0f413193d3143e452dbe047acc5da356c6cf
parentb692bc3615f276b58c08f3891d0543718d5398d8 (diff)
Fix Blocker/Critical sonar issues
Fix Blocker/Critical sonar issues in appc module https://sonar.onap.org/component_issues?id=org.openecomp.appc%3Aappc#resolved=false|severities=BLOCKER Fixed null pointer exceptions for localContext and removed redundant check for localContext Issue-Id: APPC-186 Change-Id: I38223655d69b89f6828fbdc7f3f388031e22f412 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
-rw-r--r--appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java80
1 files changed, 41 insertions, 39 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java
index 34ba743d2..153f5efbb 100644
--- a/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java
+++ b/appc-config/appc-flow-controller/provider/src/main/java/org/openecomp/appc/flow/controller/dbervices/FlowControlDBService.java
@@ -104,24 +104,26 @@ public class FlowControlDBService {
if(status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting FlowReferenceData ");
}
-
- return localContext.getAttribute("artifact-content");
+ return localContext != null ? localContext.getAttribute("artifact-content") : null;
}
public QueryStatus loadSequenceIntoDB(SvcLogicContext localContext) throws SvcLogicException {
- String fn = "DBService.saveArtifacts";
- localContext.setAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED, EscapeUtils.escapeSql(localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT)));
- log.debug("ESCAPED sequence for DB : " + localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED));
+
+ QueryStatus status = null;
+
+ if (localContext != null) {
+ String fn = "DBService.saveArtifacts";
+
+ localContext.setAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED,
+ EscapeUtils.escapeSql(localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT)));
+ log.debug("ESCAPED sequence for DB : " + localContext.getAttribute(FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED));
- for (Object key : localContext.getAttributeKeySet()) {
- String parmName = (String) key;
- String parmValue = localContext.getAttribute(parmName);
- log.debug(" loadSequenceIntoDB " + parmName + "=" + parmValue);
+ for (Object key : localContext.getAttributeKeySet()) {
+ String parmName = (String) key;
+ String parmValue = localContext.getAttribute(parmName);
+ log.debug(" loadSequenceIntoDB " + parmName + "=" + parmValue);
- }
-
-
- QueryStatus status = null;
- if (serviceLogic != null && localContext != null) {
+ }
+
String queryString = "INSERT INTO " + FlowControllerConstants.DB_REQUEST_ARTIFACTS +
" set request_id = $" + FlowControllerConstants.REQUEST_ID +
" , action = $" + FlowControllerConstants.REQUEST_ACTION +
@@ -130,7 +132,8 @@ public class FlowControlDBService {
" , category = $" + FlowControllerConstants.CATEGORY +
" , artifact_content = $" + FlowControllerConstants.ARTIFACT_CONTENT_ESCAPED +
" , updated_date = sysdate() ";
-
+
+ log.debug(fn + "Query String : " + queryString);
status = serviceLogic.save("SQL", false, false, queryString, null, null, localContext);
if(status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing storing Artifact: " +localContext.getAttribute(FlowControllerConstants.ARTIFACT_NAME));
@@ -142,26 +145,25 @@ public class FlowControlDBService {
String fn = "FlowControlDBService.populateModuleAndRPC ";
QueryStatus status = null;
SvcLogicContext context = new SvcLogicContext();
- if (serviceLogic != null && context != null) {
- String key = "select execution_type, execution_module, execution_rpc from " + FlowControllerConstants.DB_PROCESS_FLOW_REFERENCE +
- " where action = '" + transaction.getAction() + "'" +
- " and action_level = '" + transaction.getActionLevel() + "'" +
- " and protocol in ( select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE +
- " where action = '" + transaction.getAction() + "'" ;
- if(vnf_type !=null && !vnf_type.isEmpty())
- key = key + " and vnf_type ='" + vnf_type + "' )" ;
- else
- key = key + " ) " ;
- log.debug(fn + "Query String : " + key);
- status = serviceLogic.query("SQL", false, null, key, null, null, context);
- if(status.toString().equals("FAILURE"))
- throw new SvcLogicException("Error - while getting FlowReferenceData ");
-
- transaction.setExecutionModule(context.getAttribute(FlowControllerConstants.EXECUTTION_MODULE));
- transaction.setExecutionRPC(context.getAttribute(FlowControllerConstants.EXECUTION_RPC));
- transaction.setExecutionType(context.getAttribute(FlowControllerConstants.EXECUTION_TYPE));
- }
-
+
+ String key = "select execution_type, execution_module, execution_rpc from " + FlowControllerConstants.DB_PROCESS_FLOW_REFERENCE +
+ " where action = '" + transaction.getAction() + "'" +
+ " and action_level = '" + transaction.getActionLevel() + "'" +
+ " and protocol in ( select protocol from " + FlowControllerConstants.DB_PROTOCOL_REFERENCE +
+ " where action = '" + transaction.getAction() + "'" ;
+ if(vnf_type !=null && !vnf_type.isEmpty())
+ key = key + " and vnf_type ='" + vnf_type + "' )" ;
+ else
+ key = key + " ) " ;
+ log.debug(fn + "Query String : " + key);
+ status = serviceLogic.query("SQL", false, null, key, null, null, context);
+ if(status.toString().equals("FAILURE"))
+ throw new SvcLogicException("Error - while getting FlowReferenceData ");
+
+ transaction.setExecutionModule(context.getAttribute(FlowControllerConstants.EXECUTTION_MODULE));
+ transaction.setExecutionRPC(context.getAttribute(FlowControllerConstants.EXECUTION_RPC));
+ transaction.setExecutionType(context.getAttribute(FlowControllerConstants.EXECUTION_TYPE));
+
}
public String getDependencyInfo(SvcLogicContext localContext) throws SvcLogicException {
@@ -187,8 +189,9 @@ public class FlowControlDBService {
if(status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting dependencyData ");
}
-
- return localContext.getAttribute("artifact-content");
+
+ return localContext != null ? localContext.getAttribute("artifact-content") : null;
+
}
public String getCapabilitiesData(SvcLogicContext localContext) throws SvcLogicException {
@@ -214,7 +217,6 @@ public class FlowControlDBService {
if(status.toString().equals("FAILURE"))
throw new SvcLogicException("Error - while getting capabilitiesData ");
}
-
- return localContext.getAttribute("artifact-content");
+ return localContext != null ? localContext.getAttribute("artifact-content") : null;
}
}