Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rdf6deaa8ac6cd72359c5436608ab66b1b87529e0 -rd665bfd982e0a9e11818f0ed08c265d9c36adedb Binary files differ Index: lams_common/conf/language/ApplicationResources.properties =================================================================== diff -u -ra7766445094c16b343aa56dc1f73fd3051cef1db -rd665bfd982e0a9e11818f0ed08c265d9c36adedb --- lams_common/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision a7766445094c16b343aa56dc1f73fd3051cef1db) +++ lams_common/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision d665bfd982e0a9e11818f0ed08c265d9c36adedb) @@ -28,4 +28,9 @@ theme.service.setTheme.saved=User theme saved. theme.service.setTheme.type.invalid=Invalid theme type. theme.service.setTheme.noSuchTheme=No such theme exists. -theme.service.setTheme.noSuchUser=No such User exists. \ No newline at end of file +theme.service.setTheme.noSuchUser=No such User exists. + +# Audit entry made when a staff member changes a learner entry (in monitoring) +audit.change.entry=Changed text for user {0}. Old text: {1} New Text: {2} +# Audit entry made when a staff member hides a learner entry (in monitoring) +audit.hide.entry=Hide entry for user {0}. Entry was {1} \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== diff -u -r3f60ecf7d3a92231a1089191ae75c68bc66e9595 -rd665bfd982e0a9e11818f0ed08c265d9c36adedb --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision 3f60ecf7d3a92231a1089191ae75c68bc66e9595) +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml (.../commonContext.xml) (revision d665bfd982e0a9e11818f0ed08c265d9c36adedb) @@ -150,6 +150,11 @@ + + + + + Index: lams_common/src/java/org/lamsfoundation/lams/util/audit/AuditService.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/util/audit/AuditService.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/util/audit/AuditService.java (revision d665bfd982e0a9e11818f0ed08c265d9c36adedb) @@ -0,0 +1,113 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ + +package org.lamsfoundation.lams.util.audit; + +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * Write out audit entries to a log4j based log file. Gets the user details from the shared session. +*/ +/* + * Relies on the followig two entries in the log4j configuration file: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +public class AuditService implements IAuditService { + + static Logger logger = Logger.getLogger(AuditService.class.getName()); + + private final String AUDIT_CHANGE_I18N_KEY = "audit.change.entry"; + private final String AUDIT_HIDE_I18N_KEY = "audit.hide.entry"; + + protected MessageService messageService; + + private String getUserString() { + HttpSession ss = SessionManager.getSession(); + if ( ss != null ) { + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + if ( user != null ) { + return user.getLogin()+"("+user.getUserID()+"): "; + } + } + return "User unknown (session does not contain user details): "; + } + + public void log(String moduleName, String message) { + logger.info(getUserString()+moduleName+": "+message); + } + + public void logChange(String moduleName, Long originalUserId, String originalUserLogin, + String originalText, String newText) { + String[] args = new String[3]; + args[0] = originalUserLogin+"("+originalUserId+")"; + args[1] = originalText; + args[2] = newText; + String message = messageService.getMessage(AUDIT_CHANGE_I18N_KEY, args); + log(moduleName, message); + } + + public void logHide(String moduleName, Long originalUserId, String originalUserLogin, String hiddenItem) { + String[] args = new String[3]; + args[0] = originalUserLogin+"("+originalUserId+")"; + args[1] = hiddenItem; + String message = messageService.getMessage(AUDIT_HIDE_I18N_KEY, args); + log(moduleName, message); + } + + /* *** Spring Injection Methods *************/ + + public MessageService getMessageService() { + return messageService; + } + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + +} Index: lams_common/src/java/org/lamsfoundation/lams/util/audit/IAuditService.java =================================================================== diff -u --- lams_common/src/java/org/lamsfoundation/lams/util/audit/IAuditService.java (revision 0) +++ lams_common/src/java/org/lamsfoundation/lams/util/audit/IAuditService.java (revision d665bfd982e0a9e11818f0ed08c265d9c36adedb) @@ -0,0 +1,59 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ + +package org.lamsfoundation.lams.util.audit; + +/** Public interface for a service that writes audit records */ +public interface IAuditService { + + /** + * Log a message. The username, date, moduleName and message are recorded in the audit log + * @param moduleName module generating the audit entry e.g. learning, voting tool + * @param message message to be logged + */ + public void log(String moduleName, String message); + + /** + * Log a data change. The username, date, moduleName and change details are recorded in the audit log. + * @param moduleName tool generating the audit entry + * @param originalText the text before it was changed + * @param newText the text after it was changed + * @param originalUserID the userID of the user who created the text initially + * @param originalUserLogin the login of the user who created the text initially + */ + public void logChange(String moduleName, Long originalUserId, String originalUserLogin, + String originalText, String newText); + + /** + * Log staff member hiding a user entry. The username, date, moduleName and hidden entry are + * recorded in the audit log. + * @param moduleName tool generating the audit entry + * @param hiddenItem String version of the item that has been hidden + * @param newText the text after it was changed + * @param originalUserID the userID of the user who created the text initially + * @param originalUserLogin the login of the user who created the text initially + */ + public void logHide(String moduleName, Long originalUserId, String originalUserLogin, String hiddenItem); + +}