aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArindam Mondal <arind.mondal@samsung.com>2018-08-21 11:51:20 +0900
committerONAP <arind.mondal@samsung.com>2018-08-22 10:02:12 +0900
commit468c740aa7142801b0b4566cbfc3b75b24e4cab8 (patch)
treea16685b3d427c22eb8665eab672c33eae0dba4dd
parentac93ec514da91f8918d1fc93e334aa939af767f3 (diff)
Sonar violation
Issue-ID: AAI-1521 Change-Id: I34b801a1ec9525e6b1785914f8d02f938cbf0ee7 Signed-off-by: Arindam Mondal <arind.mondal@samsung.com>
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java8
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/NodesYAMLfromOXM.java14
-rw-r--r--aai-core/src/main/java/org/onap/aai/util/genxsd/PutRelationPathSet.java8
3 files changed, 17 insertions, 13 deletions
diff --git a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
index 624a394c..4e673b6a 100644
--- a/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
+++ b/aai-core/src/main/java/org/onap/aai/util/HttpsAuthExternalClient.java
@@ -53,13 +53,11 @@ public class HttpsAuthExternalClient {
config.getClasses().add(org.onap.aai.restcore.CustomJacksonJaxBJsonProvider.class);
Client client = null;
SSLContext ctx = null;
-
- try {
- String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ String truststore_path = AAIConstants.AAI_HOME_ETC_AUTH + AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_FILENAME);
+ try(FileInputStream tin = new FileInputStream(truststore_path)) {
String truststore_password = AAIConfig.get(AAIConstants.AAI_TRUSTSTORE_PASSWD);
String keystore_path = AAIConstants.AAI_HOME_ETC_AUTH + keystoreFileName;
String keystore_password = keystorePassword;
-
//System.setProperty("javax.net.ssl.trustStore", truststore_path);
//System.setProperty("javax.net.ssl.trustStorePassword", truststore_password);
HttpsURLConnection.setDefaultHostnameVerifier( new HostnameVerifier(){
@@ -82,7 +80,7 @@ public class HttpsAuthExternalClient {
String alg = TrustManagerFactory.getDefaultAlgorithm();
TrustManagerFactory tmf = TrustManagerFactory.getInstance(alg);
- FileInputStream tin = new FileInputStream(truststore_path);
+
KeyStore ts = KeyStore.getInstance("PKCS12");
char[] tpwd = truststore_password.toCharArray();
ts.load(tin, tpwd);
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/NodesYAMLfromOXM.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/NodesYAMLfromOXM.java
index 712d82d5..5c4cd8bd 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/NodesYAMLfromOXM.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/NodesYAMLfromOXM.java
@@ -64,7 +64,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
private static final String normalStartDir = "aai-core";
private static final String yaml_dir = (((System.getProperty("user.dir") != null) && (!System.getProperty("user.dir").contains(normalStartDir))) ? autoGenRoot : root) + "/aai_swagger_yaml";
private StringBuilder inventoryDefSb = null;
- private Map<String,String> operationDefinitions = new HashMap<String, String>();
+ private Map<String,String> operationDefinitions = new HashMap<>();
private String basePath;
@@ -154,7 +154,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
javaTypeDefinitions.put("inventory", inventoryDefSb.toString());
}
StringBuffer sb = new StringBuffer("definitions:\n");
- Map<String, String> sortedJavaTypeDefinitions = new TreeMap<String, String>(javaTypeDefinitions);
+ Map<String, String> sortedJavaTypeDefinitions = new TreeMap<>(javaTypeDefinitions);
for (Map.Entry<String, String> entry : sortedJavaTypeDefinitions.entrySet()) {
if(namespaceFilter != null && (! namespaceFilter.contains(entry.getKey()))) {
@@ -383,7 +383,7 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
try {
EdgeRuleQuery q = new EdgeRuleQuery.Builder(xmlRootElementName).version(v).fromOnly().build();
Multimap<String, EdgeRule> results = ei.getRules(q);
- SortedSet<String> ss=new TreeSet<String>(results.keySet());
+ SortedSet<String> ss=new TreeSet<>(results.keySet());
sbEdge.append(nodeCaption);
nodeCaption="";
for(String key : ss) {
@@ -489,11 +489,9 @@ public class NodesYAMLfromOXM extends OxmFileProcessor {
logger.error( "Exception creating output file " + outfileName);
e.printStackTrace();
}
- BufferedWriter bw = null;
- try {
- Charset charset = Charset.forName("UTF-8");
- Path path = Paths.get(outfileName);
- bw = Files.newBufferedWriter(path, charset);
+ Path path = Paths.get(outfileName);
+ Charset charset = Charset.forName("UTF-8");
+ try(BufferedWriter bw = Files.newBufferedWriter(path, charset);) {
bw.write(fileContent);
if ( bw != null ) {
bw.close();
diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/PutRelationPathSet.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/PutRelationPathSet.java
index d6eaa5c9..0b0fd946 100644
--- a/aai-core/src/main/java/org/onap/aai/util/genxsd/PutRelationPathSet.java
+++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/PutRelationPathSet.java
@@ -21,6 +21,7 @@ package org.onap.aai.util.genxsd;
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -137,6 +138,13 @@ public class PutRelationPathSet {
e.printStackTrace();
return;
}
+ finally{
+ try {
+ fop.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
try {
if(relations.size() > 0) {fop.write("[\n".getBytes());}
fop.write(String.join(",\n", relations).getBytes());