diff options
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
3 files changed, 41 insertions, 56 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java index d87a5b13..e976f144 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/controller/ActionHandler.java @@ -1995,11 +1995,8 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { String insertQry = Globals.getDownloadAllInsert(); - Connection connection = null; - PreparedStatement pst = null; - try { - connection = DbUtils.getConnection(); - pst = connection.prepareStatement(insertQry); + try(Connection connection = DbUtils.getConnection(); + PreparedStatement pst = connection.prepareStatement(insertQry)){ if(nvl(emailId).length()>0){ pst.setInt(1, Integer.parseInt(userId)); pst.setInt(2, Integer.parseInt(rr.getReportID())); @@ -2019,8 +2016,6 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { connection.commit(); } } - pst.close(); - connection.close(); logger.debug(EELFLoggerDelegate.debugLogger, ("Data inserted")); } catch (SQLException ex) { throw new RaptorException(ex); @@ -2028,16 +2023,7 @@ public class ActionHandler extends org.onap.portalsdk.analytics.RaptorObject { throw new RaptorException(ex); } catch (Exception ex) { throw new RaptorException (ex); - } finally { - try { - if(connection!=null) - connection.close(); - if(pst!=null) - pst.close(); - } catch (SQLException ex) { - throw new RaptorException(ex); - } - } + } //DbUtils.commitTransaction(connection); //DbUtils.clearConnection(connection); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java index ec83ffbf..60c45b4f 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartD3Helper.java @@ -3179,10 +3179,8 @@ public class ChartD3Helper { } } - try { - BufferedWriter out = new BufferedWriter(new FileWriter("test.txt")); + try(BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"))) { out.write(wholeScript.toString()); - out.close(); } catch (IOException e) { e.printStackTrace(); System.out.println("Exception "); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java index 12355573..b5390c92 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/util/jar/ExtractJar.java @@ -73,17 +73,18 @@ public class ExtractJar { * @throws Exception */ public static void readJar(File jarFile) throws Exception { - JarInputStream in = new JarInputStream(new FileInputStream(jarFile)); - JarEntry je; - while ((je = in.getNextJarEntry()) != null) { - if (je.isDirectory() == false) { - if (je.getName().startsWith("org/onap/portalsdk/analytics/config/")) { - System.out.println(je.getName() + " " + je.getTime()); - + try(JarInputStream in = new JarInputStream(new FileInputStream(jarFile))) + { + JarEntry je; + while ((je = in.getNextJarEntry()) != null) { + if (je.isDirectory() == false) { + if (je.getName().startsWith("org/onap/portalsdk/analytics/config/")) { + System.out.println(je.getName() + " " + je.getTime()); + + } } } } - in.close(); } /** @@ -95,37 +96,37 @@ public class ExtractJar { Class clazz = ExtractJar.class; URL jarUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); - JarInputStream entryStream = new JarInputStream(jarUrl.openStream()); - JarEntry entry; - - while (true) { - entry = entryStream.getNextJarEntry(); - if (entry == null) - break; - if (entry.getName().indexOf("jarutil") < 0) { - System.out.println(entry.getName()); - File file = new File(directory, entry.getName()); - if (entry.isDirectory()) { - if (!file.exists()) - file.mkdirs(); - } else { - File dir = new File(file.getParent()); - if (!dir.exists()) - dir.mkdirs(); - if (file.exists()) - file.delete(); - FileOutputStream fout = new FileOutputStream(file); - copy(entryStream, fout); - fout.close(); - - if (entry.getTime() >= 0) - file.setLastModified(entry.getTime()); + try(JarInputStream entryStream = new JarInputStream(jarUrl.openStream())){ + JarEntry entry; + + while (true) { + entry = entryStream.getNextJarEntry(); + if (entry == null) + break; + if (entry.getName().indexOf("jarutil") < 0) { + System.out.println(entry.getName()); + File file = new File(directory, entry.getName()); + if (entry.isDirectory()) { + if (!file.exists()) + file.mkdirs(); + } else { + File dir = new File(file.getParent()); + if (!dir.exists()) + dir.mkdirs(); + if (file.exists()) + file.delete(); + try(FileOutputStream fout = new FileOutputStream(file)){ + copy(entryStream, fout); + } + + if (entry.getTime() >= 0) + file.setLastModified(entry.getTime()); + } + } - + entryStream.closeEntry(); } - entryStream.closeEntry(); } - entryStream.close(); System.out.println("/WEB-INF/classes/org/onap/portalsdk/analytics"); System.out.println("Delete .... "); |