Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveController.java =================================================================== diff -u -rbd5afdb894181e618bc5871783f7c621bbb1453f -r8d4e389c1f1f6c95b91080d82960db4478640ced --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveController.java (.../UserOrgSaveController.java) (revision bd5afdb894181e618bc5871783f7c621bbb1453f) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/UserOrgSaveController.java (.../UserOrgSaveController.java) (revision 8d4e389c1f1f6c95b91080d82960db4478640ced) @@ -42,7 +42,6 @@ import org.lamsfoundation.lams.usermanagement.UserOrganisation; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; -import org.lamsfoundation.lams.web.filter.AuditLogFilter; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.beans.factory.annotation.Autowired; @@ -57,7 +56,6 @@ @Controller public class UserOrgSaveController { private static Logger log = Logger.getLogger(UserOrgSaveController.class); - private static Logger auditLogger = Logger.getLogger(AuditLogFilter.class); @Autowired private IUserManagementService userManagementService; @@ -70,8 +68,6 @@ Integer orgId = userOrgForm.getOrgId(); request.setAttribute("org", orgId); - UserDTO loggedInUser = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)); - boolean canEditRole = false; // sysadmin, global course admins can add/change users and their roles. @@ -83,6 +79,8 @@ canEditRole = true; } else { + Integer loggeduserId = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)) + .getUserID(); Organisation organisation = (Organisation) userManagementService.findById(Organisation.class, orgId); if (organisation == null) { String message = "Adding users to organisation: No permission to access organisation " + orgId; @@ -93,8 +91,8 @@ if (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) { organisation = organisation.getParentOrganisation(); } - if (userManagementService.isUserInRole(loggedInUser.getUserID(), organisation.getOrganisationId(), - Role.GROUP_MANAGER) && !orgId.equals(rootOrgId)) { + if (userManagementService.isUserInRole(loggeduserId, organisation.getOrganisationId(), Role.GROUP_MANAGER) + && !orgId.equals(rootOrgId)) { canEditRole = true; } else { String message = "Adding users to organisation: No permission to access organisation " + orgId; @@ -127,8 +125,6 @@ user.setUserOrganisations(userUos); iter.remove(); log.debug("removed userId=" + userId + " from orgId=" + orgId); - auditLogger.info("\"" + loggedInUser.getLogin() + "\" (" + loggedInUser.getUserID() + ") removed user " - + userId + " from organisation " + orgId); // remove from subgroups userManagementService.deleteChildUserOrganisations(uo.getUser(), uo.getOrganisation()); } @@ -138,7 +134,7 @@ for (int i = 0; i < userIdList.size(); i++) { Integer userId = new Integer(userIdList.get(i)); Iterator iter2 = uos.iterator(); - boolean alreadyInOrg = false; + Boolean alreadyInOrg = false; while (iter2.hasNext()) { UserOrganisation uo = (UserOrganisation) iter2.next(); if (uo.getUser().getUserId().equals(userId)) { @@ -166,9 +162,6 @@ for (UserOrganisation uo : newUserOrganisations) { userManagementService.setRolesForUserOrganisation(uo.getUser(), orgId, Arrays.asList(Role.ROLE_LEARNER.toString())); - - auditLogger.info("\"" + loggedInUser.getLogin() + "\" (" + loggedInUser.getUserID() + ") added user " - + uo.getUser().getUserId() + " as " + Role.LEARNER + " to organisation " + orgId); } return "redirect:/usermanage.do?org=" + orgId; } else { Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java =================================================================== diff -u -rbd5afdb894181e618bc5871783f7c621bbb1453f -r8d4e389c1f1f6c95b91080d82960db4478640ced --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision bd5afdb894181e618bc5871783f7c621bbb1453f) +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java (.../UserManagementService.java) (revision 8d4e389c1f1f6c95b91080d82960db4478640ced) @@ -81,7 +81,6 @@ import org.lamsfoundation.lams.util.LanguageUtil; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.imgscalr.ResizePictureUtil; -import org.lamsfoundation.lams.web.filter.AuditLogFilter; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.beans.factory.InitializingBean; @@ -101,8 +100,7 @@ */ public class UserManagementService implements IUserManagementService, InitializingBean { - private static Logger log = Logger.getLogger(UserManagementService.class); - private static Logger auditLogger = Logger.getLogger(AuditLogFilter.class); + private Logger log = Logger.getLogger(UserManagementService.class); private static final String SEQUENCES_FOLDER_NAME_KEY = "runsequences.folder.name"; @@ -742,8 +740,6 @@ setRolesForUserOrganisation(user, org.getParentOrganisation(), rolesList, checkGroupManagerRoles); } - UserDTO loggedInUser = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)); - List rolesCopy = new ArrayList<>(); rolesCopy.addAll(rolesList); log.debug("rolesList.size: " + rolesList.size()); @@ -759,11 +755,6 @@ // remove from the Copys the ones we are keeping rolesCopy.remove(roleId); uorsCopy.remove(uor); - - auditLogger.info((loggedInUser == null ? "Unauthenticated user" - : "\"" + loggedInUser.getLogin() + "\" (" + loggedInUser.getUserID() + ")") - + " removed user " + uo.getUser().getUserId() + " as " + uor.getRole().getName() - + " from organisation " + uo.getOrganisation().getOrganisationId()); } } } @@ -779,13 +770,7 @@ Role role = (Role) findById(Role.class, Integer.parseInt(roleId)); UserOrganisationRole uor = new UserOrganisationRole(uo, role); save(uor); - log.debug("setting role: " + role.getName() + " in organisation: " + org.getName()); - auditLogger.info((loggedInUser == null ? "Unauthenticated user" - : "\"" + loggedInUser.getLogin() + "\" (" + loggedInUser.getUserID() + ")") + " added user " - + uo.getUser().getUserId() + " as " + uor.getRole().getName() + " to organisation " - + uo.getOrganisation().getOrganisationId()); - uors.add(uor); // when a user gets these roles, they need a workspace if (role.getName().equals(Role.AUTHOR) || role.getName().equals(Role.SYSADMIN)) { @@ -868,16 +853,8 @@ UserOrganisationRole uor = new UserOrganisationRole(uo, role); save(uor); uo.addUserOrganisationRole(uor); - - UserDTO loggedInUser = ((UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER)); - log.debug("setting role: " + uor.getRole().getName() + " in organisation: " + uor.getUserOrganisation().getOrganisation().getName()); - auditLogger.info((loggedInUser == null ? "Unauthenticated user" - : "\"" + loggedInUser.getLogin() + "\" (" + loggedInUser.getUserID() + ")") + " added user " - + uo.getUser().getUserId() + " as " + uor.getRole().getName() + " to organisation " - + uo.getOrganisation().getOrganisationId()); - return uo; }