summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src
diff options
context:
space:
mode:
authorSudarshan Kumar <sudars19@in.ibm.com>2019-03-08 15:41:16 +0530
committerSudarshan Kumar <sudars19@in.ibm.com>2019-03-08 14:11:39 +0000
commit3686b0edb3f946044592389e5c62fec4a6da9f4c (patch)
treef86df6c6ff96399162c667988f5edb2df6aaafb6 /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src
parent8c3c912f2fe3d13b36859a4825a338bc3715903e (diff)
Sonar Fix- NullPointer & removed unused variables
Sonar Fix- Handling NullPointerException and removed unused variables Issue-ID: APPC-1399 Change-Id: Iac61f72e7c1547ee7cf5aeab82a621a380e109fa Signed-off-by: Sudarshan Kumar <sudars19@in.ibm.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src')
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java23
1 files changed, 15 insertions, 8 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java
index 0f79d64bd..606df1ed3 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/onap/appc/adapter/iaas/provider/operation/impl/DettachVolumeServer.java
@@ -29,7 +29,6 @@ import static org.onap.appc.adapter.utils.Constants.ADAPTER_NAME;
import com.att.cdp.exceptions.ZoneException;
import com.att.cdp.zones.ComputeService;
import com.att.cdp.zones.Context;
-import com.att.cdp.zones.VolumeService;
import com.att.cdp.zones.model.ModelObject;
import com.att.cdp.zones.model.Server;
import com.att.cdp.zones.model.Volume;
@@ -105,14 +104,14 @@ public class DettachVolumeServer extends ProviderServerOperation {
}
logger.debug(Msg.SERVER_FOUND, vmUrl, context.getTenantName(), server.getStatus().toString());
if (volumeId == null || volumeId.isEmpty()) {
- ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ if(ctx != null){
+ ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ }
doFailure(requestContext, HttpStatus.BAD_REQUEST_400, "Volumeid is mandatory");
}
Context contx = server.getContext();
ComputeService service = contx.getComputeService();
Volume volume = new Volume();
- VolumeService vs = contx.getVolumeService();
- Volume s = vs.getVolume(volumeId);
boolean flag = false;
if (validateDetach(service, vm.getServerId(), volumeId)) {
volume.setId(volumeId);
@@ -122,24 +121,32 @@ public class DettachVolumeServer extends ProviderServerOperation {
} else {
String msg = "Volume with volume id " + volumeId + " cannot be detached as it does not exists";
logger.info("Volume doesnot exists:");
- ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ if(ctx != null){
+ ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ }
doFailure(requestContext, HttpStatus.METHOD_NOT_ALLOWED_405, msg);
flag = false;
}
if (flag) {
if (validateDetach(requestContext, service, vm.getServerId(), volumeId)) {
String msg = "Volume with volume id " + volumeId + " cannot be detached ";
- ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ if(ctx != null){
+ ctx.setAttribute("VOLUME_STATUS", "FAILURE");
+ }
doFailure(requestContext, HttpStatus.CONFLICT_409, msg);
} else {
logger.info("status of detaching volume");
- ctx.setAttribute("VOLUME_STATUS", "SUCCESS");
+ if(ctx != null){
+ ctx.setAttribute("VOLUME_STATUS", "SUCCESS");
+ }
doSuccess(requestContext);
}
}
context.close();
} else {
- ctx.setAttribute("VOLUME_STATUS", "CONTEXT_NOT_FOUND");
+ if(ctx != null){
+ ctx.setAttribute("VOLUME_STATUS", "CONTEXT_NOT_FOUND");
+ }
}
} catch (ZoneException e) {
String msg = EELFResourceManager.format(Msg.SERVER_NOT_FOUND, e, vmUrl);