/** * returns list of output lines * * @param userId user id * @return sessionId session id object */ public static List<SessionOutput> getOutput(Connection con, Long userId) { List<SessionOutput> outputList = new ArrayList<SessionOutput>(); UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput != null) { for (Long key : userSessionsOutput.getSessionOutputMap().keySet()) { // get output chars and set to output try { SessionOutput sessionOutput = (SessionOutput) BeanUtils.cloneBean(userSessionsOutput.getSessionOutputMap().get(key)); outputList.add(sessionOutput); SessionAuditDB.insertTerminalLog(con, sessionOutput); userSessionsOutput.getSessionOutputMap().get(key).setOutput(""); } catch (Exception ex) { ex.printStackTrace(); } } } return outputList; }
/** * removes session output for host system * * @param userId user id * @param hostSystemId host system id */ public static void removeOutput(Long userId, Long hostSystemId) { UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput != null) { userSessionsOutput.getSessionOutputMap().remove(hostSystemId); } }
/** * removes session for user * * @param userId user id */ public static void removeUserSession(Long userId) { UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput != null) { userSessionsOutput.getSessionOutputMap().clear(); } userSessionsOutputMap.remove(userId); }
/** * adds a new output * * @param userId user id * @param sessionOutput session output object */ public static void addOutput(Long userId, SessionOutput sessionOutput) { UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput == null) { userSessionsOutputMap.put(userId, new UserSessionsOutput()); userSessionsOutput = userSessionsOutputMap.get(userId); } userSessionsOutput.getSessionOutputMap().put(sessionOutput.getHostSystemId(), sessionOutput); }
/** * adds a new output * * @param userId user id * @param hostSystemId host system id * @param c character */ public static void addCharToOutput(Long userId, Long hostSystemId, char c) { UserSessionsOutput userSessionsOutput = userSessionsOutputMap.get(userId); if (userSessionsOutput != null) { SessionOutput sessionOutput = userSessionsOutput.getSessionOutputMap().get(hostSystemId); if (sessionOutput != null) { sessionOutput.setOutput(sessionOutput.getOutput() + Character.toString(c)); } } }