/** * Load the tracks retrieved from the database into TemplateExecutionMap object. */ private static void loadTemplatesExecutionCache(Connection con) { PreparedStatement stm = null; ResultSet rs = null; try { String sql = "SELECT tt.templatename, tt.username, tt.sessionidentifier" + " FROM templatetrack tt" + " LEFT JOIN tag t ON tt.templatename = t.objectidentifier" + " WHERE t.type = ? AND t.tagname = ?"; stm = con.prepareStatement(sql); stm.setString(1, TagTypes.TEMPLATE); stm.setString(2, TagNames.IM_PUBLIC); rs = stm.executeQuery(); TemplateTrack tt; while (rs.next()) { tt = new TemplateTrack(rs.getString(1), rs.getString(2), rs.getString(3)); templatesExecutionCache.addExecution(tt); } } catch (SQLException sqle) { LOG.error("Error during loading template tracks into the cache", sqle); } }
/** * Load the tracks retrieved from the database into TemplateExecutionMap object. */ private static void loadTemplatesExecutionCache(Connection con) { PreparedStatement stm = null; ResultSet rs = null; try { String sql = "SELECT tt.templatename, tt.username, tt.sessionidentifier" + " FROM templatetrack tt" + " LEFT JOIN tag t ON tt.templatename = t.objectidentifier" + " WHERE t.type = ? AND t.tagname = ?"; stm = con.prepareStatement(sql); stm.setString(1, TagTypes.TEMPLATE); stm.setString(2, TagNames.IM_PUBLIC); rs = stm.executeQuery(); TemplateTrack tt; while (rs.next()) { tt = new TemplateTrack(rs.getString(1), rs.getString(2), rs.getString(3)); templatesExecutionCache.addExecution(tt); } } catch (SQLException sqle) { LOG.error("Error during loading template tracks into the cache", sqle); } }
/** * Store into the database the template execution by the user or if the user is not logged * during a specific http session. Update the cache. * @param templateName the template name * @param profile the user profile * @param sessionIdentifier the session id */ protected void trackTemplate(String templateName, Profile profile, String sessionIdentifier) { String userName = (profile.getUsername() != null) ? profile.getUsername() : ""; TemplateTrack templateTrack = new TemplateTrack(templateName, userName, sessionIdentifier, new Timestamp(System.currentTimeMillis())); if (templateTracker != null) { templateTracker.storeTrack(templateTrack); templatesExecutionCache.addExecution(templateTrack); } else { LOG.warn("Template not tracked. Check if the TemplateTracker has been configured"); } }
/** * Store into the database the template execution by the user or if the user is not logged * during a specific http session. Update the cache. * @param templateName the template name * @param profile the user profile * @param sessionIdentifier the session id */ protected void trackTemplate(String templateName, Profile profile, String sessionIdentifier) { String userName = (profile.getUsername() != null) ? profile.getUsername() : ""; TemplateTrack templateTrack = new TemplateTrack(templateName, userName, sessionIdentifier, new Timestamp(System.currentTimeMillis())); if (templateTracker != null) { templateTracker.storeTrack(templateTrack); templatesExecutionCache.addExecution(templateTrack); } else { LOG.warn("Template not tracked. Check if the TemplateTracker has been configured"); } }