summaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-artifact-handler
diff options
context:
space:
mode:
authorshashikanth <shashikanth.vh@huawei.com>2017-09-18 13:53:55 +0530
committerSkip Wonnell <skip@att.com>2017-09-18 21:47:22 +0000
commitac822a12b7963c04992684ac3307ed986073f342 (patch)
treef56ffd950e8e4434b2c7146798175ab2336920b2 /appc-inbound/appc-artifact-handler
parent6c34983dce34c834e42eb6e5bf9ca5a137f29cce (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 QueryStatus and db string. Issue-Id: APPC-92 Change-Id: Ic499d7af6c90cd692e8362ba4f7d2f5d65d49471 Signed-off-by: shashikanth.vh <shashikanth.vh@huawei.com>
Diffstat (limited to 'appc-inbound/appc-artifact-handler')
-rw-r--r--appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java79
1 files changed, 39 insertions, 40 deletions
diff --git a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
index 470f068c3..a619a00a8 100644
--- a/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
+++ b/appc-inbound/appc-artifact-handler/provider/src/main/java/org/openecomp/appc/artifact/handler/dbservices/DBService.java
@@ -24,18 +24,17 @@
package org.openecomp.appc.artifact.handler.dbservices;
-import java.sql.SQLException;
-import java.util.HashMap;
-
-import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource;
+import org.openecomp.appc.artifact.handler.utils.SdcArtifactHandlerConstants;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import java.sql.SQLException;
+import java.util.HashMap;
public class DBService {
@@ -202,36 +201,39 @@ public class DBService {
QueryStatus status = null;
whereClause = " where VNF_TYPE = $" + SdcArtifactHandlerConstants.VNF_TYPE;
- if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)
- && context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY)
- .equals(SdcArtifactHandlerConstants.CAPABILITY)
- && context.getAttribute(SdcArtifactHandlerConstants.ACTION) == null) {
- whereClause = whereClause + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY;
- }
+ if (db != null) {
+ if (db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)
+ && context.getAttribute(SdcArtifactHandlerConstants.FILE_CATEGORY)
+ .equals(SdcArtifactHandlerConstants.CAPABILITY)
+ && context.getAttribute(SdcArtifactHandlerConstants.ACTION) == null) {
+ whereClause = whereClause + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY;
+ }
- else if (db != null && db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)) {
- whereClause = whereClause + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
- + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
- + SdcArtifactHandlerConstants.ACTION;
- }
+ else if (db.equals(SdcArtifactHandlerConstants.DB_SDC_REFERENCE)) {
+ whereClause = whereClause + " and VNFC_TYPE = $" + SdcArtifactHandlerConstants.VNFC_TYPE
+ + " and FILE_CATEGORY = $" + SdcArtifactHandlerConstants.FILE_CATEGORY + " and ACTION = $"
+ + SdcArtifactHandlerConstants.ACTION;
+ }
- else if (db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
- whereClause = " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
- } else if (db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
- whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION;
- } else if (db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)) {
- int vm_instance = -1;
- if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
- vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
- int vnfc_instance = -1;
- if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
- vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
- whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $"
- + SdcArtifactHandlerConstants.VNFC_TYPE + " and VNFC_INSTANCE = $"
- + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
- + SdcArtifactHandlerConstants.VM_INSTANCE;
+ else if (db.equals(SdcArtifactHandlerConstants.DB_DOWNLOAD_DG_REFERENCE)) {
+ whereClause = " where PROTOCOL = $" + SdcArtifactHandlerConstants.DEVICE_PROTOCOL;
+ } else if (db.equals(SdcArtifactHandlerConstants.DB_CONFIG_ACTION_DG)) {
+ whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION;
+ } else if (db.equals(SdcArtifactHandlerConstants.DB_VNFC_REFERENCE)) {
+ int vm_instance = -1;
+ if (context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE) != null)
+ vm_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VM_INSTANCE));
+ int vnfc_instance = -1;
+ if (context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE) != null)
+ vnfc_instance = Integer.parseInt(context.getAttribute(SdcArtifactHandlerConstants.VNFC_INSTANCE));
+ whereClause = whereClause + " and ACTION = $" + SdcArtifactHandlerConstants.ACTION + " and VNFC_TYPE = $"
+ + SdcArtifactHandlerConstants.VNFC_TYPE + " and VNFC_INSTANCE = $"
+ + SdcArtifactHandlerConstants.VNFC_INSTANCE + " and VM_INSTANCE = $"
+ + SdcArtifactHandlerConstants.VM_INSTANCE;
+ }
}
+
if (serviceLogic != null && context != null) {
String key = "select COUNT(*) from " + db + whereClause;
log.info("SELECT String : " + key);
@@ -354,7 +356,7 @@ public class DBService {
if (serviceLogic != null && context != null)
status = serviceLogic.save("SQL", false, false, key, null, null, context);
- if (status.toString().equals("FAILURE"))
+ if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing DOWNLOAD_DG_REFERENCE table ");
}
@@ -378,7 +380,7 @@ public class DBService {
if (serviceLogic != null && context != null)
status = serviceLogic.save("SQL", false, false, key, null, null, context);
- if (status.toString().equals("FAILURE"))
+ if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing Configure DG Action table ");
} else
log.info("No Update required for Config DG Action");
@@ -420,7 +422,7 @@ public class DBService {
if (serviceLogic != null && context != null)
status = serviceLogic.save("SQL", false, false, key, null, null, context);
- if (status.toString().equals("FAILURE"))
+ if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing Configure DG Action table ");
}
@@ -439,10 +441,7 @@ public class DBService {
if (serviceLogic != null && context != null)
status = serviceLogic.save("SQL", false, false, key, null, null, context);
- if (status.toString().equals("FAILURE"))
+ if ((status == null) || status.toString().equals("FAILURE"))
throw new SvcLogicException("Error While processing insertProtocolReference ");
-
}
-
-
}