use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.
the class AuditLog method log.
public static final void log(final String subsystem, final String message) {
logToSlf(message, subsystem, Level.INFO);
publishEvent(new AuditLogEvent(subsystem.toUpperCase(), message, Level.INFO));
}
use of com.dexels.navajo.events.types.AuditLogEvent in project navajo by Dexels.
the class SQLMap method getResultSet.
protected ResultSetMap[] getResultSet(boolean updateOnly) throws UserException {
requestCount++;
ResultSet rs = null;
long start = 0;
if (debug || timeAlert > 0) {
start = System.currentTimeMillis();
}
try {
if (resultSet == null) {
rs = getDBResultSet(updateOnly);
}
if (debug) {
Access.writeToConsole(myAccess, "SQLMAP, QUERY HAS BEEN EXECUTED, RETRIEVING RESULTSET\n");
}
if (rs != null) {
int columns = 0;
ResultSetMetaData meta = null;
try {
meta = rs.getMetaData();
columns = meta.getColumnCount();
} catch (Exception e) {
throw new UserException(-1, "Error getting metadata / columns", e);
}
ArrayList dummy = new ArrayList();
int index = 1;
remainCount = 0;
rowCount = 0;
while (rs.next()) {
if ((index >= startIndex) && (index <= endIndex)) {
ResultSetMap rm = getResultSetMap(meta, columns, rs);
dummy.add(rm);
viewCount++;
}
// else if (index >= startIndex) {
// remainCount++;
// }
rowCount++;
index++;
}
if (debug) {
Access.writeToConsole(myAccess, "GOT RESULTSET\n");
}
resultSet = new ResultSetMap[dummy.size()];
resultSet = (ResultSetMap[]) dummy.toArray(resultSet);
}
} catch (SQLException sqle) {
logger.error("The following query failed: {}", this.getQuery());
AuditLog.log("SQLMap", sqle.getMessage(), sqle, Level.SEVERE, (myAccess != null ? (myAccess != null ? myAccess.accessID : "unknown access") : "unknown access"));
throw new UserException(-1, sqle.getMessage(), sqle);
} catch (Exception sqle) {
AuditLog.log("SQLMap", sqle.getMessage(), sqle, Level.SEVERE, (myAccess != null ? (myAccess != null ? myAccess.accessID : "unknown access") : "unknown access"));
throw new UserException(-1, sqle.getMessage(), sqle);
} finally {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
e.printStackTrace(Access.getConsoleWriter(myAccess));
}
rs = null;
}
this.resetAll();
}
if (debug || timeAlert > 0) {
long end = System.currentTimeMillis();
double total = (end - start) / 1000.0;
if (timeAlert > 0 && (int) (end - start) > timeAlert) {
AuditLogEvent ale = new AuditLogEvent("SQLMAPTIMEALERT", "Query took " + (end - start) + " millis:\n" + (query != null ? query : update), Level.WARNING);
ale.setAccessId(myAccess.accessID);
NavajoEventRegistry.getInstance().publishEvent(ale);
}
// Log total if needed....
// totaltiming += total;
}
return resultSet;
}
Aggregations