diff options
author | Venkata Harish Kajur <vk250x@att.com> | 2018-08-22 20:53:09 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-08-22 20:53:09 +0000 |
commit | 68628a4047e9ff4bfedd55788b2cc637cc2b4f1b (patch) | |
tree | 51282070c9cf0150e5327615c807865566d99026 /aai-core/src/main/java | |
parent | 2d13f752c694afb221ae1e1f7ed0a1c989f51762 (diff) | |
parent | 468c740aa7142801b0b4566cbfc3b75b24e4cab8 (diff) |
Merge "Sonar violation"
Diffstat (limited to 'aai-core/src/main/java')
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()); |