diff options
Diffstat (limited to 'aai-core')
4 files changed, 18 insertions, 14 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..3d055b81 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; @@ -147,6 +148,13 @@ public class PutRelationPathSet { e.printStackTrace(); return; } + finally{ + try { + fop.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } logger.debug(String.join(",\n", relations)); return; } diff --git a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java index 91c9459d..f9ce7c11 100644 --- a/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java +++ b/aai-core/src/main/java/org/onap/aai/util/genxsd/XSDElement.java @@ -297,7 +297,7 @@ public class XSDElement implements Element { sbElement.append(" type=\"xs:int\""); if ( elementType.equals("java.lang.Boolean")) sbElement.append(" type=\"xs:boolean\""); - if ( elementIsRequired == null || !elementIsRequired.equals("true")||addType != null) { + if ( ("java.lang.Boolean".equals(elementType)) || (elementIsRequired == null || !elementIsRequired.equals("true")||addType != null)) { sbElement.append(" minOccurs=\"0\""); } if ( elementContainerType != null && elementContainerType.equals("java.util.ArrayList")) { |