Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7
--- lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java (.../IImportService.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java (.../IImportService.java) (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -26,7 +26,7 @@
import java.io.IOException;
import java.util.List;
-import org.apache.struts.upload.FormFile;
+import org.springframework.web.multipart.MultipartFile;
/**
*
@@ -49,65 +49,65 @@
/**
* Returns true if spreadsheet contains user data.
- *
+ *
* @param fileItem
* @return
* @throws IOException
*/
- public boolean isUserSpreadsheet(FormFile fileItem) throws IOException;
+ public boolean isUserSpreadsheet(MultipartFile fileItem) throws IOException;
/**
* Returns true if spreadsheet contains userorgrole data.
- *
+ *
* @param fileItem
* @return
* @throws IOException
*/
- public boolean isRolesSpreadsheet(FormFile fileItem) throws IOException;
+ public boolean isRolesSpreadsheet(MultipartFile fileItem) throws IOException;
/**
* Checks first row of spreadsheet and determines whether to parse as
* a user or orgrole spreadsheet.
- *
+ *
* @param fileItem
* @throws IOException
*/
- public List parseSpreadsheet(FormFile fileItem, String sessionId) throws IOException;
+ public List parseSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException;
/**
- *
+ *
* @param fileItem
* @return
* @throws IOException
*/
- public List parseGroupSpreadsheet(FormFile fileItem, String sessionId) throws IOException;
+ public List parseGroupSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException;
/**
* Returns number of rows found in spreadsheet.
- *
+ *
* @param fileItem
* @return
* @throws IOException
*/
- public int getNumRows(FormFile fileItem) throws IOException;
+ public int getNumRows(MultipartFile fileItem) throws IOException;
/**
* Returns message results from parsing list of users in spreadsheet.
- *
+ *
* @param file
* @param sessionId
* @return
* @throws IOException
*/
- public List parseUserSpreadsheet(FormFile file, String sessionId) throws IOException;
+ public List parseUserSpreadsheet(MultipartFile file, String sessionId) throws IOException;
/**
* Returns message results from parsing list of organisation memberships.
- *
+ *
* @param file
* @param sessionId
* @return
* @throws IOException
*/
- public List parseRolesSpreadsheet(FormFile file, String sessionId) throws IOException;
+ public List parseRolesSpreadsheet(MultipartFile file, String sessionId) throws IOException;
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java
===================================================================
diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -re2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7
--- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -37,7 +37,6 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.Cell;
-import org.apache.struts.upload.FormFile;
import org.lamsfoundation.lams.logevent.LogEvent;
import org.lamsfoundation.lams.logevent.service.ILogEventService;
import org.lamsfoundation.lams.themes.Theme;
@@ -56,6 +55,7 @@
import org.lamsfoundation.lams.util.ValidationUtil;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
+import org.springframework.web.multipart.MultipartFile;
/**
*
@@ -133,36 +133,36 @@
private static final short ADMIN_CHANGE_STATUS = 7;
// class-wide variables
- ArrayList results = new ArrayList();
- ArrayList rowResult = new ArrayList();
+ ArrayList results = new ArrayList<>();
+ ArrayList rowResult = new ArrayList<>();
private boolean emptyRow;
private boolean hasError;
private Organisation parentOrg;
- private HSSFSheet getSheet(FormFile fileItem) throws IOException {
+ private HSSFSheet getSheet(MultipartFile fileItem) throws IOException {
POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream());
HSSFWorkbook wb = new HSSFWorkbook(fs);
return wb.getSheetAt(0);
}
@Override
- public boolean isUserSpreadsheet(FormFile fileItem) throws IOException {
+ public boolean isUserSpreadsheet(MultipartFile fileItem) throws IOException {
HSSFSheet sheet = getSheet(fileItem);
HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
String string = parseStringCell(row.getCell(ImportService.PASSWORD));
return (StringUtils.equals(string, "* password")) ? true : false;
}
@Override
- public boolean isRolesSpreadsheet(FormFile fileItem) throws IOException {
+ public boolean isRolesSpreadsheet(MultipartFile fileItem) throws IOException {
HSSFSheet sheet = getSheet(fileItem);
HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
String string = parseStringCell(row.getCell(ImportService.ORGANISATION));
return (StringUtils.equals(string, "* organisation")) ? true : false;
}
@Override
- public List parseSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
+ public List parseSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException {
if (isUserSpreadsheet(fileItem)) {
return parseUserSpreadsheet(fileItem, sessionId);
} else if (isRolesSpreadsheet(fileItem)) {
@@ -175,8 +175,8 @@
// each item in the list lists the id, name, and parent's id of that org; otherwise
// the items in the list are error messages.
@Override
- public List parseGroupSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- results = new ArrayList();
+ public List parseGroupSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException {
+ results = new ArrayList<>();
parentOrg = service.getRootOrganisation();
HSSFSheet sheet = getSheet(fileItem);
int startRow = sheet.getFirstRowNum();
@@ -191,7 +191,7 @@
for (int i = startRow + 1; i < (endRow + 1); i++) {
emptyRow = true;
hasError = false;
- rowResult = new ArrayList();
+ rowResult = new ArrayList<>();
row = sheet.getRow(i);
if (row != null) {
org = parseGroup(row, i);
@@ -297,16 +297,16 @@
}
@Override
- public int getNumRows(FormFile fileItem) throws IOException {
+ public int getNumRows(MultipartFile fileItem) throws IOException {
HSSFSheet sheet = getSheet(fileItem);
int startRow = sheet.getFirstRowNum();
int endRow = sheet.getLastRowNum();
return endRow - startRow;
}
@Override
- public List parseUserSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- results = new ArrayList();
+ public List parseUserSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException {
+ results = new ArrayList<>();
HSSFSheet sheet = getSheet(fileItem);
int startRow = sheet.getFirstRowNum();
int endRow = sheet.getLastRowNum();
@@ -322,7 +322,7 @@
for (int i = startRow + 1; i < (endRow + 1); i++) {
emptyRow = true;
hasError = false;
- rowResult = new ArrayList();
+ rowResult = new ArrayList<>();
row = sheet.getRow(i);
user = parseUser(row, i);
@@ -376,8 +376,8 @@
}
@Override
- public List parseRolesSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- results = new ArrayList();
+ public List parseRolesSpreadsheet(MultipartFile fileItem, String sessionId) throws IOException {
+ results = new ArrayList<>();
HSSFSheet sheet = getSheet(fileItem);
int startRow = sheet.getFirstRowNum();
int endRow = sheet.getLastRowNum();
@@ -393,7 +393,7 @@
for (int i = startRow + 1; i < (endRow + 1); i++) {
emptyRow = true;
hasError = false;
- rowResult = new ArrayList();
+ rowResult = new ArrayList<>();
row = sheet.getRow(i);
String login = parseStringCell(row.getCell(ImportService.LOGIN));
@@ -711,7 +711,7 @@
ImportService.log.error("Caught exception when reading roles in spreadsheet: " + e.getMessage());
return null;
}
- List roles = new ArrayList();
+ List roles = new ArrayList<>();
int fromIndex = 0;
int index = roleDescription.indexOf(IImportService.SEPARATOR, fromIndex);
while (index != -1) {
@@ -751,7 +751,7 @@
// return false if a role shouldn't be assigned in given org type
private boolean checkValidRoles(List idList, boolean isSysadmin, OrganisationType orgType) {
// convert list of id's into list of Roles
- List roleList = new ArrayList();
+ List roleList = new ArrayList<>();
for (String id : idList) {
Role role = (Role) service.findById(Role.class, Integer.parseInt(id));
if (role != null) {
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java
===================================================================
diff -u -r550e1b37b507779064955267ef47e9085f791357 -re2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java (.../CleanupTempFilesController.java) (revision 550e1b37b507779064955267ef47e9085f791357)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CleanupTempFilesController.java (.../CleanupTempFilesController.java) (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -29,7 +29,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.struts.Globals;
import org.lamsfoundation.lams.admin.web.form.CleanupForm;
import org.lamsfoundation.lams.usermanagement.Role;
import org.lamsfoundation.lams.util.FileUtil;
@@ -77,7 +76,7 @@
return "error";
}
- if (request.getAttribute(Globals.CANCEL_KEY) != null) {
+ if (request.getAttribute("CANCEL") != null) {
return "redirect:/sysadminstart.do";
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java
===================================================================
diff -u -r550e1b37b507779064955267ef47e9085f791357 -re2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java (.../CloneLessonsController.java) (revision 550e1b37b507779064955267ef47e9085f791357)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/CloneLessonsController.java (.../CloneLessonsController.java) (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -32,8 +32,6 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
-import org.apache.struts.action.ActionForm;
-import org.apache.struts.action.ActionMapping;
import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
import org.lamsfoundation.lams.lesson.Lesson;
import org.lamsfoundation.lams.lesson.service.ILessonService;
@@ -76,8 +74,7 @@
private WebApplicationContext applicationContext;
@RequestMapping("/start")
- public String execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws UserAccessDeniedException {
+ public String execute(HttpServletRequest request, HttpServletResponse response) throws UserAccessDeniedException {
if (!(request.isUserInRole(Role.SYSADMIN))) {
throw new UserAccessDeniedException();
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ConfigController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,140 @@
+/****************************************************************
+ * Copyright (C) 2006 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.lang.StringUtils;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.web.form.ConfigForm;
+import org.lamsfoundation.lams.config.ConfigurationItem;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.MessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * ConfigAction
+ *
+ * @author Mitchell Seaton
+ */
+/**
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+@RequestMapping("/config")
+public class ConfigController {
+
+ private static Configuration configurationService;
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @Autowired
+ @Qualifier("adminMessageService")
+ private MessageService adminMessageService;
+
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ configurationService = AdminServiceProxy.getConfiguration(applicationContext.getServletContext());
+ }
+ return configurationService;
+ }
+
+ @RequestMapping("/start")
+ public String unspecified(HttpServletRequest request) throws Exception {
+
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+
+ return "config/editconfig";
+ }
+
+ @RequestMapping("/save")
+ public String save(@ModelAttribute ConfigForm configForm, HttpServletRequest request) throws Exception {
+
+ if (request.getAttribute("CANCEL") != null) {
+ return "redirect:/sysadminstart.do";
+ }
+
+ String[] keys = configForm.getKey();
+ String[] values = configForm.getValue();
+
+ String errorForward = "config";
+
+ for (int i = 0; i < keys.length; i++) {
+ ConfigurationItem item = getConfiguration().getConfigItemByKey(keys[i]);
+
+ if (item != null) {
+ // return to ldap page if that's where we came from
+ if (StringUtils.contains(item.getHeaderName(), "config.header.ldap")) {
+ errorForward = "ldap";
+ }
+
+ if (item.getRequired()) {
+ if (!(values[i] != null && values[i].length() > 0)) {
+ request.setAttribute("error", getRequiredError(item.getDescriptionKey()));
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+ return mapping.findForward(errorForward);
+ }
+ }
+ String format = item.getFormat();
+ if (format != null && format.equals(ConfigurationItem.LONG_FORMAT)) {
+ try {
+ Long.parseLong(values[i]);
+ } catch (NumberFormatException e) {
+ request.setAttribute("error", getNumericError(item.getDescriptionKey()));
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+ return mapping.findForward(errorForward);
+ }
+ }
+ Configuration.updateItem(keys[i], values[i]);
+ }
+ }
+ getConfiguration().persistUpdate();
+
+ Configuration.refreshCache();
+
+ return "redirect:/sysadminstart.do";
+ }
+
+ private String getRequiredError(String arg) {
+ String[] args = new String[1];
+ args[0] = adminMessageService.getMessage(arg);
+ return adminMessageService.getMessage("error.required", args);
+ }
+
+ private String getNumericError(String arg) {
+ String[] args = new String[1];
+ args[0] = adminMessageService.getMessage(arg);
+ return adminMessageService.getMessage("error.numeric", args);
+ }
+
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/DisabledUserManageController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ */
+@Controller
+public class DisabledUserManageController {
+
+ private static final Logger log = Logger.getLogger(DisabledUserManageController.class);
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @Autowired
+ @Qualifier("adminMessageService")
+ private MessageService adminMessageService;
+
+ @RequestMapping("/disabledmanage")
+ public String execute(HttpServletRequest request) throws Exception {
+
+ IUserManagementService service = AdminServiceProxy.getService(applicationContext.getServletContext());
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "DisabledUserManageAction");
+ request.setAttribute("errorMessage", adminMessageService.getMessage("error.need.sysadmin"));
+ return "error";
+ }
+
+ List users = service.findByProperty(User.class, "disabledFlag", true);
+ log.debug("got " + users.size() + " disabled users");
+ request.setAttribute("users", users);
+
+ return "disabledusers";
+ }
+
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+public class ImportExcelController {
+
+ @RequestMapping("/importexcel")
+ public String execute(@ModelAttribute ImportExcelForm importExcelForm, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ //if (orgId==null) orgId = (Integer)request.getAttribute("orgId");
+
+ importExcelForm.setOrgId(orgId);
+
+ return "import/importexcel";
+ }
+
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportExcelSaveController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,112 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+public class ImportExcelSaveController {
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/importexcelsave")
+ public String execute(@ModelAttribute ImportExcelForm importExcelForm, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (request.getAttribute("CANCEL") != null) {
+ return "redirect:/sysadminstart.do";
+ }
+
+ IImportService importService = AdminServiceProxy.getImportService(applicationContext.getServletContext());
+ MultipartFile file = importExcelForm.getFile();
+
+ // validation
+ if (file == null || file.getSize() <= 0) {
+ return "forward:/importexcel.do";
+ }
+
+ String sessionId = SessionManager.getSession().getId();
+ SessionManager.getSession().setAttribute(IImportService.IMPORT_FILE, file);
+ // use a new thread only if number of users is > threshold
+ if (importService.getNumRows(file) < IImportService.THRESHOLD) {
+ List results = importService.parseSpreadsheet(file, sessionId);
+ SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
+ return "forward:/importuserresult.do";
+ } else {
+ Thread t = new Thread(new ImportExcelThread(sessionId));
+ t.start();
+ return "import/status";
+ }
+ }
+
+ private class ImportExcelThread implements Runnable {
+ private String sessionId;
+
+ public ImportExcelThread(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public void run() {
+ IImportService importService = AdminServiceProxy.getImportService(applicationContext.getServletContext());
+ try {
+ MultipartFile file = (MultipartFile) SessionManager.getSession(sessionId)
+ .getAttribute(IImportService.IMPORT_FILE);
+ List results = importService.parseSpreadsheet(file, sessionId);
+ SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
+ } catch (Exception e) {
+ }
+ }
+ }
+
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportGroupsController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,83 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.admin.web.form.ImportExcelForm;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+public class ImportGroupsController {
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/importgroups")
+ public String execute(@ModelAttribute ImportExcelForm importForm, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (request.getAttribute("CANCEL") != null) {
+ return "redirect:/sysadminstart.do";
+ }
+
+ IImportService importService = AdminServiceProxy.getImportService(applicationContext.getServletContext());
+ importForm.setOrgId(0);
+ MultipartFile file = importForm.getFile();
+
+ // validation
+ if (file == null || file.getSize() <= 0) {
+ return "import/importGroups";
+ }
+
+ String sessionId = SessionManager.getSession().getId();
+ List results = importService.parseGroupSpreadsheet(file, sessionId);
+ request.setAttribute("results", results);
+
+ return "import/importGroups";
+ }
+
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/ImportUserResultController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.admin.service.IImportService;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ */
+@Controller
+public class ImportUserResultController {
+
+ private static Logger log = Logger.getLogger(ImportUserResultController.class);
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/importuserresult")
+ public String execute(HttpServletRequest request) throws Exception {
+
+ MessageService messageService = AdminServiceProxy.getMessageService(applicationContext.getServletContext());
+ IImportService importService = AdminServiceProxy.getImportService(applicationContext.getServletContext());
+ HttpSession ss = SessionManager.getSession();
+
+ List results = (List) ss.getAttribute(IImportService.IMPORT_RESULTS);
+ String successMessageKey = "";
+ try {
+ MultipartFile file = (MultipartFile) ss.getAttribute(IImportService.IMPORT_FILE);
+ successMessageKey = (importService.isUserSpreadsheet(file) ? "msg.users.created" : "msg.users.added");
+ } catch (Exception e) {
+ log.error("Couldn't check spreadsheet type!", e);
+ }
+
+ int successful = 0;
+ for (int i = 0; i < results.size(); i++) {
+ ArrayList rowResult = (ArrayList) results.get(i);
+ if (rowResult.isEmpty()) {
+ successful++;
+ }
+ }
+ String[] args = new String[1];
+ args[0] = String.valueOf(successful);
+
+ request.setAttribute("results", results);
+ request.setAttribute("successful", messageService.getMessage(successMessageKey, args));
+
+ // remove temporary session vars that allowed status to be displayed
+ // to user during import
+ ss.removeAttribute(IImportService.STATUS_IMPORT_TOTAL);
+ ss.removeAttribute(IImportService.STATUS_IMPORTED);
+ ss.removeAttribute(IImportService.IMPORT_FILE);
+ ss.removeAttribute(IImportService.IMPORT_RESULTS);
+
+ return "import/importresult";
+ }
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LdapConfigController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,231 @@
+/****************************************************************
+ * 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.usermanagement.AuthenticationMethod;
+import org.lamsfoundation.lams.usermanagement.dto.BulkUpdateResultDTO;
+import org.lamsfoundation.lams.usermanagement.service.ILdapService;
+import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
+import org.lamsfoundation.lams.usermanagement.service.LdapService;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * @author jliew
+ *
+ *
+ *
+ *
+ *
+ */
+@Controller
+@RequestMapping("/ldap")
+public class LdapConfigController {
+
+ private static Logger log = Logger.getLogger(LdapConfigController.class);
+ private static IUserManagementService service;
+ private static LdapService ldapService;
+ private static MessageService messageService;
+ private static Configuration configurationService;
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ private IUserManagementService getService() {
+ if (service == null) {
+ service = AdminServiceProxy.getService(applicationContext.getServletContext());
+ }
+ return service;
+ }
+
+ private LdapService getLdapService() {
+ if (ldapService == null) {
+ ldapService = AdminServiceProxy.getLdapService(applicationContext.getServletContext());
+ }
+ return ldapService;
+ }
+
+ private MessageService getMessageService() {
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(applicationContext.getServletContext());
+ }
+ return messageService;
+ }
+
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ configurationService = AdminServiceProxy.getConfiguration(applicationContext.getServletContext());
+ }
+ return configurationService;
+ }
+
+ @RequestMapping("/start")
+ public String execute(HttpServletRequest request) throws Exception {
+
+ String action = WebUtil.readStrParam(request, "action", true);
+ if (action != null) {
+ if (StringUtils.equals(action, "sync")) {
+ return sync(request);
+ }
+ if (StringUtils.equals(action, "waiting")) {
+ return waiting(request);
+ }
+ if (StringUtils.equals(action, "results")) {
+ return results(request);
+ }
+ }
+
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_ONLY_LDAP));
+
+ int numLdapUsers = getNumLdapUsers();
+ request.setAttribute("numLdapUsersMsg", getNumLdapUsersMsg(numLdapUsers));
+
+ return "ldap";
+ }
+
+ @RequestMapping("/sync")
+ public String sync(HttpServletRequest request) throws Exception {
+
+ String sessionId = SessionManager.getSession().getId();
+ Thread t = new Thread(new LdapSyncThread(sessionId));
+ t.start();
+
+ request.setAttribute("wait", getMessageService().getMessage("msg.ldap.synchronise.wait"));
+
+ return "ldap";
+ }
+
+ @RequestMapping("/waiting")
+ public String waiting(HttpServletRequest request) throws Exception {
+
+ request.setAttribute("wait", getMessageService().getMessage("msg.ldap.synchronise.wait"));
+
+ return "ldap";
+ }
+
+ @RequestMapping("/results")
+ public String results(HttpServletRequest request) throws Exception {
+
+ HttpSession ss = SessionManager.getSession();
+ Object o = ss.getAttribute(ILdapService.SYNC_RESULTS);
+ if (o instanceof BulkUpdateResultDTO) {
+ BulkUpdateResultDTO dto = (BulkUpdateResultDTO) o;
+
+ int numLdapUsers = getNumLdapUsers();
+ request.setAttribute("numLdapUsersMsg", getNumLdapUsersMsg(numLdapUsers));
+
+ request.setAttribute("numSearchResults", getNumSearchResultsUsersMsg(dto.getNumSearchResults()));
+ request.setAttribute("numLdapUsersCreated", getNumCreatedUsersMsg(dto.getNumUsersCreated()));
+ request.setAttribute("numLdapUsersUpdated", getNumUpdatedUsersMsg(dto.getNumUsersUpdated()));
+ request.setAttribute("numLdapUsersDisabled", getNumDisabledUsersMsg(dto.getNumUsersDisabled()));
+ request.setAttribute("messages", dto.getMessages());
+ request.setAttribute("done", getMessageService().getMessage("msg.done"));
+ } else {
+ ArrayList list = new ArrayList<>();
+ list.add((String) o);
+ request.setAttribute("messages", list);
+ request.setAttribute("done", getMessageService().getMessage("msg.done"));
+ }
+
+ // remove session variable that flags bulk update as done
+ ss.removeAttribute(ILdapService.SYNC_RESULTS);
+
+ return "ldap";
+ }
+
+ private int getNumLdapUsers() {
+ Integer count = getService().getCountUsers(AuthenticationMethod.LDAP);
+ return (count != null ? count.intValue() : -1);
+ }
+
+ private String getNumLdapUsersMsg(int numLdapUsers) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(numLdapUsers);
+ return getMessageService().getMessage("msg.num.ldap.users", args);
+ }
+
+ private String getNumSearchResultsUsersMsg(int searchResults) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(searchResults);
+ return getMessageService().getMessage("msg.num.search.results.users", args);
+ }
+
+ private String getNumCreatedUsersMsg(int created) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(created);
+ return getMessageService().getMessage("msg.num.created.users", args);
+ }
+
+ private String getNumUpdatedUsersMsg(int updated) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(updated);
+ return getMessageService().getMessage("msg.num.updated.users", args);
+ }
+
+ private String getNumDisabledUsersMsg(int disabled) {
+ String[] args = new String[1];
+ args[0] = String.valueOf(disabled);
+ return getMessageService().getMessage("msg.num.disabled.users", args);
+ }
+
+ private class LdapSyncThread implements Runnable {
+ private String sessionId;
+
+ private Logger log = Logger.getLogger(LdapSyncThread.class);
+
+ public LdapSyncThread(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public void run() {
+ this.log.info("=== Beginning LDAP user sync ===");
+ long start = System.currentTimeMillis();
+ try {
+ BulkUpdateResultDTO dto = getLdapService().bulkUpdate();
+ long end = System.currentTimeMillis();
+ this.log.info("=== Finished LDAP user sync ===");
+ this.log.info("Bulk update took " + (end - start) / 1000 + " seconds.");
+ SessionManager.getSession(sessionId).setAttribute(ILdapService.SYNC_RESULTS, dto);
+ } catch (Exception e) {
+ String message = e.getMessage() != null ? e.getMessage() : e.getClass().getName();
+ SessionManager.getSession(sessionId).setAttribute(ILdapService.SYNC_RESULTS, message);
+ e.printStackTrace();
+ }
+ }
+ }
+}
Fisheye: Tag e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventAction.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventController.java
===================================================================
diff -u
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventController.java (revision 0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/controller/LogEventController.java (revision e2c0c928c2cf3c0527ec942ad9af0ec67a3aa8d7)
@@ -0,0 +1,211 @@
+/****************************************************************
+ * Copyright (C) 2006 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 version 2.0
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.admin.web.controller;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
+import org.lamsfoundation.lams.logevent.LogEvent;
+import org.lamsfoundation.lams.logevent.LogEventType;
+import org.lamsfoundation.lams.logevent.dto.LogEventTypeDTO;
+import org.lamsfoundation.lams.logevent.service.ILogEventService;
+import org.lamsfoundation.lams.usermanagement.Role;
+import org.lamsfoundation.lams.usermanagement.User;
+import org.lamsfoundation.lams.util.JsonUtil;
+import org.lamsfoundation.lams.util.MessageService;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Report on events in the log event table. Used for auditing.
+ */
+@Controller
+@RequestMapping("/logevent")
+public class LogEventController {
+
+ private static ILogEventService logEventService;
+ private MessageService messageService;
+ private static SimpleDateFormat START_DATE_FORMAT = new SimpleDateFormat("YYYY-MM-dd");
+
+ @Autowired
+ private WebApplicationContext applicationContext;
+
+ @RequestMapping("/start")
+ public String unspecified(HttpServletRequest request) throws Exception {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "EventLogAdmin");
+ request.setAttribute("errorMessage", AdminServiceProxy
+ .getMessageService(applicationContext.getServletContext()).getMessage("error.authorisation"));
+ return "error";
+ }
+
+ logEventService = getLogEventService();
+
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(applicationContext.getServletContext());
+ }
+
+ // get the log type data and return display for user selection. Also get the start and stop dates from the log.
+ // TODO check conversion the dates to the user's timezone
+ List types = logEventService.getEventTypes();
+ List convertedTypes = new ArrayList<>(types.size());
+ for (LogEventType type : types) {
+ convertedTypes.add(new LogEventTypeDTO(type, messageService.getMessage(type.getDescriptionI18NKey()),
+ messageService.getMessage(type.getAreaI18NKey())));
+ }
+ request.setAttribute("eventLogTypes", convertedTypes);
+
+ // jsp page expects date of the first audit log entry as YYYY-DD-MM.
+ Date oldestDate = logEventService.getOldestEventDate();
+// oldestDate = DateUtil.convertToTimeZoneFromDefault(userTimeZone, oldestDate);
+ request.setAttribute("startDate", START_DATE_FORMAT.format(oldestDate != null ? oldestDate : new Date()));
+ return "logevent";
+ }
+
+ /**
+ * The initial method for monitoring. List all users according to given Content ID.
+ */
+ @RequestMapping("/getEventLog")
+ @ResponseBody
+ public String getEventLog(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ // check permission
+ if (!request.isUserInRole(Role.SYSADMIN)) {
+ request.setAttribute("errorName", "EventLogAdmin");
+ request.setAttribute("errorMessage", AdminServiceProxy
+ .getMessageService(applicationContext.getServletContext()).getMessage("error.authorisation"));
+ return "error";
+ }
+
+ logEventService = getLogEventService();
+
+ // paging parameters of tablesorter
+ int size = WebUtil.readIntParam(request, "size");
+ int page = WebUtil.readIntParam(request, "page");
+ Integer isSort1 = WebUtil.readIntParam(request, "column[0]", true);
+// String searchString = request.getParameter("fcol[0]");
+
+ int sorting = ILogEventService.SORT_BY_DATE_ASC;
+ if ((isSort1 != null) && isSort1.equals(1)) {
+ sorting = ILogEventService.SORT_BY_DATE_DESC;
+ }
+
+ Long dateParameter = WebUtil.readLongParam(request, "startDate", true);
+ Date startDate = null;
+ if (dateParameter != null) {
+ startDate = new Date(dateParameter);
+ // TODO if using time zones then convert to server timezone
+// HttpSession ss = SessionManager.getSession();
+// org.lamsfoundation.lams.usermanagement.dto.UserDTO teacher = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) ss
+// .getAttribute(AttributeNames.USER);
+// TimeZone teacherTimeZone = teacher.getTimeZone();
+// tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline);
+ }
+
+ dateParameter = WebUtil.readLongParam(request, "endDate", true);
+ Date endDate = null;
+ if (dateParameter != null) {
+ endDate = new Date(dateParameter);
+ }
+
+ String area = WebUtil.readStrParam(request, "area", true);
+ Integer typeId = WebUtil.readIntParam(request, "typeId", true);
+ List