aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/northbound/addCMHandle
diff options
context:
space:
mode:
authorLiard Samuel <samuel.liard@orange.com>2021-10-08 09:21:18 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2021-11-19 11:25:38 +0100
commit6945b75aac0e6bc2bad6f824769b32842f06bc46 (patch)
treefb99e802250d9efd8ac5c75df85a76431bff3ba4 /sdnr/northbound/addCMHandle
parent71031b0b238ee51affd8135fdd648d9a70a6970b (diff)
Fix sonar Security Hotspots
Issue-ID: CCSDK-3491 Signed-off-by: sliard <samuel.liard@gmail.com> Change-Id: I33787ccca2a8acd8085db6b2a915e8f2ac2511ec Signed-off-by: Dan Timoney <dtimoney@att.com> Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/northbound/addCMHandle')
-rw-r--r--sdnr/northbound/addCMHandle/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/addCMHandle/AddCMHandleProvider.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/sdnr/northbound/addCMHandle/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/addCMHandle/AddCMHandleProvider.java b/sdnr/northbound/addCMHandle/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/addCMHandle/AddCMHandleProvider.java
index 1756615cb..0d9cc8f3f 100644
--- a/sdnr/northbound/addCMHandle/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/addCMHandle/AddCMHandleProvider.java
+++ b/sdnr/northbound/addCMHandle/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/addCMHandle/AddCMHandleProvider.java
@@ -146,20 +146,16 @@ public class AddCMHandleProvider implements CMHandleAPIService, NetconfNodeState
// GET configuration from properties file
config = new HashMap<String, String>();
- try {
- FileInputStream fileInput = new FileInputStream(propDir + PROPERTIES_FILE_NAME);
+ try (FileInputStream fileInput = new FileInputStream(propDir + PROPERTIES_FILE_NAME)) {
Properties properties = new Properties();
properties.load(fileInput);
- fileInput.close();
for (String param : new String[] {"url", "user", "password",
"authentication, dmi-service-name"}) {
config.put(param, properties.getProperty(param));
}
- } catch (FileNotFoundException e) {
- e.printStackTrace();
} catch (IOException e) {
- e.printStackTrace();
+ LOG.error("Error while reading properties file: ", e);
}
LOG.info("addCMHandle Session Initiated");
@@ -167,7 +163,7 @@ public class AddCMHandleProvider implements CMHandleAPIService, NetconfNodeState
@Override
public void onCreated(NodeId nNodeId, NetconfNode netconfNode) {
- LOG.info("NetConf device connected ", nNodeId.getValue());
+ LOG.info("NetConf device connected {}", nNodeId.getValue());
JSONObject obj = new JSONObject();
obj.put("cm-handle-id", nNodeId.getValue());
obj.put("dmi-service-name", config.get("dmi-service-name"));
@@ -178,7 +174,7 @@ public class AddCMHandleProvider implements CMHandleAPIService, NetconfNodeState
String authenticationMethod = config.get("authentication");
ClientResponse response = null;
try {
- if (authenticationMethod.equals("basic")) {
+ if ("basic".equals(authenticationMethod)) {
LOG.debug("Sending message to dmaap-message-router: {}", obj.toString());
dmaapClient.addFilter(new HTTPBasicAuthFilter(config.get("user"), config.get("password")));
@@ -188,11 +184,11 @@ public class AddCMHandleProvider implements CMHandleAPIService, NetconfNodeState
response = dmaapClient.resource(config.get("url")).type(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, obj);
}
+ LOG.info("Received response from dmaap-message-router: \n {}", response.toString());
} catch (Exception e) {
- LOG.error("Error while posting message to CM_HANDLE topic: {}", e);
+ LOG.error("Error while posting message to CM_HANDLE topic: ", e);
}
- LOG.info("Received response from dmaap-message-router: \n {}", response.toString());
}
@Override