summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/DbUtils.java63
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java13
-rw-r--r--ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/sessionmgt/TimeoutVO.java7
3 files changed, 37 insertions, 46 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/DbUtils.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/DbUtils.java
index 1ce53c71..e179d388 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/DbUtils.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/DbUtils.java
@@ -66,17 +66,18 @@ public class DbUtils {
public static Connection getConnection() throws ReportSQLException {
try {
- return AppUtils.getDatasource().getConnection();
+ return AppUtils.getDatasource().getConnection();
} catch(SQLException ex) {
- ex.printStackTrace();
+ ex.printStackTrace();
}
return null;
} // getConnection
public static void clearConnection(Connection con) throws ReportSQLException {
try {
- if ((con != null) && !con.isClosed())
- Globals.getDbUtils().clearConnection(con);
+ if ((con != null) && !con.isClosed()) {
+ Globals.getDbUtils().clearConnection(con);
+ }
} catch (SQLException ex) {
throw new ReportSQLException(ex.getMessage(), ex.getCause());
} catch (Exception ex2 ) {
@@ -123,16 +124,16 @@ public class DbUtils {
String result = null;
try {
- if(con.isClosed()) con = getConnection();
+ if(con.isClosed()) con = getConnection();
logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL Call] " + sql));
- CallableStatement stmt = con.prepareCall(sql);
- if (expectResult)
- stmt.registerOutParameter(1, Types.CHAR);
- stmt.executeUpdate();
- if (expectResult)
- result = stmt.getString(1);
- stmt.close();
- con.commit();
+ try(CallableStatement stmt = con.prepareCall(sql)){
+ if (expectResult)
+ stmt.registerOutParameter(1, Types.CHAR);
+ stmt.executeUpdate();
+ if (expectResult)
+ result = stmt.getString(1);
+ con.commit();
+ }
} catch (SQLException e) {
throw new ReportSQLException(e.getMessage(), sql);
} finally {
@@ -152,20 +153,18 @@ public class DbUtils {
} // executeCall
public static int executeUpdate(Connection con, String sql) throws ReportSQLException {
- int rcode = -1;
- try {
- Statement stmt = con.createStatement();
+ int rcode = -1;
+ try(Statement stmt = con.createStatement()) {
logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL Update] " + sql));
rcode = stmt.executeUpdate(sql);
- stmt.close();
- //con.commit();
+ //con.commit();
} catch (SQLException e) {
//e.printStackTrace();
throw new ReportSQLException(e.getMessage(), sql);
- }
- return rcode;
+ }
+ return rcode;
} // executeUpdate
-
+
public static int executeUpdate(String sql) throws ReportSQLException {
Connection con = null;
try {
@@ -189,23 +188,17 @@ public class DbUtils {
public static DataSet executeQuery(Connection con, String sql, int maxRowLimit)
throws ReportSQLException {
try {
- if(con.isClosed()) con = getConnection();
+ if(con.isClosed()) con = getConnection();
//con.
- Statement stmt = con.createStatement();
-
- logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL] " + sql));
- ResultSet rs = stmt.executeQuery(sql);
- DataSet ds = new DataSet(rs, maxRowLimit);
-
- if(rs!=null)
- rs.close();
- if(stmt!=null)
- stmt.close();
-
- return ds;
+ try(Statement stmt = con.createStatement();
+ ResultSet rs = stmt.executeQuery(sql))
+ {
+ logger.debug(EELFLoggerDelegate.debugLogger, ("[SQL CALL FROM RAPTOR] [SQL] " + sql));
+ return new DataSet(rs, maxRowLimit);
+ }
} catch (SQLException e) {
throw new ReportSQLException(e.getMessage(), sql);
- }
+ }
} // executeQuery
public static DataSet executeQuery(String sql) throws ReportSQLException {
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java
index aa01b184..b416f779 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/AntBuild.java
@@ -57,9 +57,8 @@ public class AntBuild {
}
public static void readManifest() {
- JarFile jar = null;
- try {
- jar = new JarFile("./raptor_fusion.jar");
+ try(JarFile jar = new JarFile("./raptor_fusion.jar")){
+
Manifest manifest = jar.getManifest();
Attributes attribs = manifest.getMainAttributes();
@@ -81,14 +80,6 @@ public class AntBuild {
} catch (IOException e) {
System.err.println("Cannot read jar-file manifest: "
+ e.getMessage());
- } finally {
- if (jar != null) {
- try {
- jar.close();
- } catch (IOException e) {
- throw new RuntimeException("Failed to close jar '");
- }
- }
}
}
} \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/sessionmgt/TimeoutVO.java b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/sessionmgt/TimeoutVO.java
index 777f502f..9d7621d6 100644
--- a/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/sessionmgt/TimeoutVO.java
+++ b/ecomp-sdk/epsdk-core/src/main/java/org/onap/portalsdk/core/domain/sessionmgt/TimeoutVO.java
@@ -37,6 +37,8 @@
*/
package org.onap.portalsdk.core.domain.sessionmgt;
+import org.apache.wicket.util.lang.Objects;
+
public class TimeoutVO implements Comparable<TimeoutVO> {
private String jSessionId;
@@ -81,6 +83,11 @@ public class TimeoutVO implements Comparable<TimeoutVO> {
}
@Override
+ public int hashCode() {
+ return Objects.hashCode(getSessionTimOutMilliSec());
+ }
+
+ @Override
public int compareTo(TimeoutVO o) {
return sessionTimOutMilliSec.compareTo(o.sessionTimOutMilliSec);
}