summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2019-09-05 21:35:06 +0900
committerarindamm <arind.mondal@samsung.com>2019-09-10 14:07:19 +0900
commit35ce89dc017ad5285a260a440dcbc26249502c74 (patch)
tree73de6265595742c3707ffe4cca7203468804d007
parentf5f7d0763673dd0af81624eaa93b6951e1d299eb (diff)
General sonar fixes
+)Format logger ++) Remove toString() +++) Extract nested IF Issue-ID: SO-2226 Change-Id: Iff28408584b04ffd03b6aca0f647d0af9090a9c2 Signed-off-by: arind.mondal <arind.mondal@samsung.com>
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java2
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java3
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java1
4 files changed, 17 insertions, 22 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
index 14d83b3b06..35008b6120 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/audit/AuditVServer.java
@@ -84,7 +84,7 @@ public class AuditVServer extends AbstractAudit {
try {
logger.debug("Vserver to Audit: {}", objectMapper.getMapper().writeValueAsString(vserver));
} catch (JsonProcessingException e) {
- logger.error("Json parse exception: {}", e.getMessage());
+ logger.error("Json parse exception: ", e);
}
});
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index afc227faf0..013c7f8a84 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -91,6 +91,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
private static final String CREATE_NETWORK_CONTEXT = "CreateNetwork";
private static final String NEUTRON_MODE = "NEUTRON";
private static final String CLOUD_OWNER = "CloudOwner";
+ private static final String LOG_DEBUG_MSG = "Got Network definition from Catalog: {}";
private static final Logger logger = LoggerFactory.getLogger(MsoNetworkAdapterImpl.class);
@@ -292,7 +293,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString());
+ logger.debug("Got HEAT Template from DB: {}", heatTemplate);
// "Fix" the template if it has CR/LF (getting this from Oracle)
String template = heatTemplate.getHeatTemplate();
@@ -656,7 +657,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.INTERNAL);
}
- logger.debug("Got HEAT Template from DB: {}", heatTemplate.toString());
+ logger.debug("Got HEAT Template from DB: {}", heatTemplate);
// "Fix" the template if it has CR/LF (getting this from Oracle)
String template = heatTemplate.getHeatTemplate();
@@ -798,12 +799,11 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
}
if (networkCust != null) {
- logger.debug("Got Network Customization definition from Catalog: {}", networkCust.toString());
+ logger.debug("Got Network Customization definition from Catalog: {}", networkCust);
networkResource = networkCust.getNetworkResource();
} else if (collectionNetworkCust != null) {
- logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}",
- collectionNetworkCust.toString());
+ logger.debug("Retrieved Collection Network Resource Customization from Catalog: {}", collectionNetworkCust);
networkResource = collectionNetworkCust.getNetworkResource();
}
if (networkResource == null) {
@@ -814,7 +814,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
throw new NetworkException(error, MsoExceptionCategory.USERDATA);
}
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
String mode = networkResource.getOrchestrationMode();
NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType());
@@ -1045,7 +1045,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
String mode = "";
if (networkResource != null) {
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
mode = networkResource.getOrchestrationMode();
}
@@ -1132,7 +1132,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String mode = "";
if (networkResource != null) {
- logger.debug("Got Network definition from Catalog: {}", networkResource.toString());
+ logger.debug(LOG_DEBUG_MSG, networkResource);
mode = networkResource.getOrchestrationMode();
}
@@ -1388,9 +1388,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Resource Property
List<ContrailSubnet> cslist = new ArrayList<>();
for (Subnet subnet : subnets) {
- logger.debug("Input Subnet:{}", subnet.toString());
+ logger.debug("Input Subnet:{}", subnet);
ContrailSubnet cs = new ContrailSubnetMapper(subnet).map();
- logger.debug("Contrail Subnet:{}", cs.toString());
+ logger.debug("Contrail Subnet:{}", cs);
cslist.add(cs);
}
@@ -1523,18 +1523,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
JsonNode rootNode = mapper.readTree(jStr);
if (rootNode != null) {
for (JsonNode sNode : rootNode.path("ipam_subnets")) {
- logger.debug("Output Subnet Node {}", sNode.toString());
+ logger.debug("Output Subnet Node {}", sNode);
String name = sNode.path("subnet_name").textValue();
String uuid = sNode.path("subnet_uuid").textValue();
String aaiId = name; // default
// try to find aaiId for name in input subnetList
if (subnets != null) {
for (Subnet subnet : subnets) {
- if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())) {
- if (subnet.getSubnetName().equals(name)) {
- aaiId = subnet.getSubnetId();
- break;
- }
+ if (subnet != null && !commonUtils.isNullOrEmpty(subnet.getSubnetName())
+ && subnet.getSubnetName().equals(name)) {
+ aaiId = subnet.getSubnetId();
+ break;
}
}
}
@@ -1549,7 +1548,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
ErrorCode.DataError.getValue(), e);
}
- logger.debug("Return sMap {}", sMap.toString());
+ logger.debug("Return sMap {}", sMap);
return sMap;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 9b72bdc608..7c7223e596 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -89,9 +89,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
index 3c4c90cc37..89885f33c2 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java
@@ -36,7 +36,6 @@ import javax.ws.rs.core.UriBuilder;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.json.JSONArray;
-import org.json.JSONException;
import org.json.JSONObject;
import org.onap.so.apihandler.common.ErrorNumbers;
import org.onap.so.apihandler.common.RequestClient;