Index: lams_admin/src/java/org/lamsfoundation/lams/admin/AdminConstants.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/AdminConstants.java (.../AdminConstants.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/AdminConstants.java (.../AdminConstants.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -26,6 +26,6 @@
public class AdminConstants {
- public static final String MODULE_NAME = "admin";
-
+ public static final String MODULE_NAME = "admin";
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java
===================================================================
diff -u -rb128694883b5db515c3f98f6803b573e04d203d2 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision b128694883b5db515c3f98f6803b573e04d203d2)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -65,8 +65,8 @@
public static final IUserManagementService getService(ServletContext servletContext) {
if (AdminServiceProxy.manageService == null) {
- AdminServiceProxy.manageService = (IUserManagementService) AdminServiceProxy.getDomainService(
- servletContext, "userManagementService");
+ AdminServiceProxy.manageService = (IUserManagementService) AdminServiceProxy
+ .getDomainService(servletContext, "userManagementService");
}
return AdminServiceProxy.manageService;
}
@@ -82,8 +82,8 @@
public static final IIntegrationService getIntegrationService(ServletContext servletContext) {
if (AdminServiceProxy.integrationService == null) {
- AdminServiceProxy.integrationService = (IIntegrationService) AdminServiceProxy.getDomainService(
- servletContext, "integrationService");
+ AdminServiceProxy.integrationService = (IIntegrationService) AdminServiceProxy
+ .getDomainService(servletContext, "integrationService");
}
return AdminServiceProxy.integrationService;
}
@@ -114,8 +114,8 @@
public static final IStatisticsService getStatisticsService(ServletContext servletContext) {
if (AdminServiceProxy.statisticsService == null) {
- AdminServiceProxy.statisticsService = (IStatisticsService) AdminServiceProxy.getDomainService(
- servletContext, "statisticsService");
+ AdminServiceProxy.statisticsService = (IStatisticsService) AdminServiceProxy
+ .getDomainService(servletContext, "statisticsService");
}
return AdminServiceProxy.statisticsService;
}
@@ -146,8 +146,8 @@
public static final IMonitoringService getMonitoringService(ServletContext servletContext) {
if (AdminServiceProxy.monitoringService == null) {
- AdminServiceProxy.monitoringService = (IMonitoringService) AdminServiceProxy.getDomainService(
- servletContext, "monitoringService");
+ AdminServiceProxy.monitoringService = (IMonitoringService) AdminServiceProxy
+ .getDomainService(servletContext, "monitoringService");
}
return AdminServiceProxy.monitoringService;
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java
===================================================================
diff -u -rba24244d8d8029b2673232988f58c6a97672e17e -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java (.../IImportService.java) (revision ba24244d8d8029b2673232988f58c6a97672e17e)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/IImportService.java (.../IImportService.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -32,76 +32,82 @@
*
* View Source
*
- *
+ *
* @author Fei Yang
* @author Jun-Dir Liew
*/
public interface IImportService {
-
- public static final String SEPARATOR = "|";
- public static final String IMPORT_HELP_PAGE = "Import+Users";
- public static final String IMPORT_GROUPS_HELP_PAGE = "Import+Groups";
- public static final String STATUS_IMPORT_TOTAL = "importTotal";
- public static final String STATUS_IMPORTED = "imported";
- public static final String IMPORT_FILE = "file";
- public static final String IMPORT_RESULTS = "results";
- public static final int THRESHOLD = 500;
-
- /**
- * Returns true if spreadsheet contains user data.
- * @param fileItem
- * @return
- * @throws IOException
- */
- public boolean isUserSpreadsheet(FormFile fileItem) throws IOException;
-
- /**
- * Returns true if spreadsheet contains userorgrole data.
- * @param fileItem
- * @return
- * @throws IOException
- */
- public boolean isRolesSpreadsheet(FormFile 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;
-
- /**
- *
- * @param fileItem
- * @return
- * @throws IOException
- */
- public List parseGroupSpreadsheet(FormFile fileItem) throws IOException;
-
- /**
- * Returns number of rows found in spreadsheet.
- * @param fileItem
- * @return
- * @throws IOException
- */
- public int getNumRows(FormFile 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;
-
- /**
- * 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 static final String SEPARATOR = "|";
+ public static final String IMPORT_HELP_PAGE = "Import+Users";
+ public static final String IMPORT_GROUPS_HELP_PAGE = "Import+Groups";
+ public static final String STATUS_IMPORT_TOTAL = "importTotal";
+ public static final String STATUS_IMPORTED = "imported";
+ public static final String IMPORT_FILE = "file";
+ public static final String IMPORT_RESULTS = "results";
+ public static final int THRESHOLD = 500;
+
+ /**
+ * Returns true if spreadsheet contains user data.
+ *
+ * @param fileItem
+ * @return
+ * @throws IOException
+ */
+ public boolean isUserSpreadsheet(FormFile fileItem) throws IOException;
+
+ /**
+ * Returns true if spreadsheet contains userorgrole data.
+ *
+ * @param fileItem
+ * @return
+ * @throws IOException
+ */
+ public boolean isRolesSpreadsheet(FormFile 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;
+
+ /**
+ *
+ * @param fileItem
+ * @return
+ * @throws IOException
+ */
+ public List parseGroupSpreadsheet(FormFile fileItem) throws IOException;
+
+ /**
+ * Returns number of rows found in spreadsheet.
+ *
+ * @param fileItem
+ * @return
+ * @throws IOException
+ */
+ public int getNumRows(FormFile 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;
+
+ /**
+ * 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;
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java
===================================================================
diff -u -r273ac76ea166a02a1e72b10010ac41c545349bd5 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 273ac76ea166a02a1e72b10010ac41c545349bd5)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -23,14 +23,10 @@
/* $Id$ */
package org.lamsfoundation.lams.admin.service;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.servlet.http.HttpSession;
@@ -41,7 +37,7 @@
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
-import org.apache.struts.action.ActionMessage;
+import org.apache.poi.ss.usermodel.Cell;
import org.apache.struts.upload.FormFile;
import org.lamsfoundation.lams.admin.AdminConstants;
import org.lamsfoundation.lams.themes.Theme;
@@ -54,8 +50,6 @@
import org.lamsfoundation.lams.usermanagement.User;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.usermanagement.service.IUserManagementService;
-import org.lamsfoundation.lams.util.Configuration;
-import org.lamsfoundation.lams.util.ConfigurationKeys;
import org.lamsfoundation.lams.util.HashUtil;
import org.lamsfoundation.lams.util.LanguageUtil;
import org.lamsfoundation.lams.util.MessageService;
@@ -68,417 +62,429 @@
*
* View Source
*
- *
+ *
* @author Fei Yang
* @author Jun-Dir Liew
*/
public class ImportService implements IImportService {
- private static Logger log = Logger.getLogger(ImportService.class);
- public IUserManagementService service;
- public MessageService messageService;
- public IAuditService auditService;
-
- public IUserManagementService getService() {
- return service;
+ private static Logger log = Logger.getLogger(ImportService.class);
+ public IUserManagementService service;
+ public MessageService messageService;
+ public IAuditService auditService;
+
+ public IUserManagementService getService() {
+ return service;
+ }
+
+ public void setService(IUserManagementService service) {
+ this.service = service;
+ }
+
+ public MessageService getMessageService() {
+ return messageService;
+ }
+
+ public void setMessageService(MessageService messageService) {
+ this.messageService = messageService;
+ }
+
+ public IAuditService getAuditService() {
+ return auditService;
+ }
+
+ public void setAuditService(IAuditService auditService) {
+ this.auditService = auditService;
+ }
+
+ // spreadsheet column indexes for user spreadsheet
+ private static final short LOGIN = 0;
+ private static final short PASSWORD = 1;
+ private static final short TITLE = 2;
+ private static final short FIRST_NAME = 3;
+ private static final short LAST_NAME = 4;
+ private static final short AUTH_METHOD = 5;
+ private static final short EMAIL = 6;
+ private static final short FLASH_THEME = 7;
+ private static final short HTML_THEME = 8;
+ private static final short LOCALE = 9;
+ private static final short ADDRESS1 = 10;
+ private static final short ADDRESS2 = 11;
+ private static final short ADDRESS3 = 12;
+ private static final short CITY = 13;
+ private static final short STATE = 14;
+ private static final short POSTCODE = 15;
+ private static final short COUNTRY = 16;
+ private static final short DAY_PHONE = 17;
+ private static final short EVE_PHONE = 18;
+ private static final short MOB_PHONE = 19;
+ private static final short FAX = 20;
+
+ // spreadsheet column indexes for userorgrole spreadsheet
+ private static final short ORGANISATION = 1;
+ private static final short ROLES = 2;
+
+ // spreadsheet column indexes for groups spreadsheet
+ private static final short NAME = 0;
+ private static final short CODE = 1;
+ private static final short DESCRIPTION = 2;
+ private static final short LOCALE_ID = 3;
+ private static final short ORGANISATION_STATE = 4;
+ private static final short ADMIN_ADD_NEW_USERS = 5;
+ private static final short ADMIN_BROWSE_ALL_USERS = 6;
+ private static final short ADMIN_CHANGE_STATUS = 7;
+
+ // class-wide variables
+ ArrayList results = new ArrayList();
+ ArrayList rowResult = new ArrayList();
+ private boolean emptyRow;
+ private boolean hasError;
+ private Organisation parentOrg;
+
+ private HSSFSheet getSheet(FormFile 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 {
+ HSSFSheet sheet = getSheet(fileItem);
+ HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
+ String string = parseStringCell(row.getCell(PASSWORD));
+ return (StringUtils.equals(string, "* password")) ? true : false;
+ }
+
+ @Override
+ public boolean isRolesSpreadsheet(FormFile fileItem) throws IOException {
+ HSSFSheet sheet = getSheet(fileItem);
+ HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
+ String string = parseStringCell(row.getCell(ORGANISATION));
+ return (StringUtils.equals(string, "* organisation")) ? true : false;
+ }
+
+ @Override
+ public List parseSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
+ if (isUserSpreadsheet(fileItem)) {
+ return parseUserSpreadsheet(fileItem, sessionId);
+ } else if (isRolesSpreadsheet(fileItem)) {
+ return parseRolesSpreadsheet(fileItem, sessionId);
}
+ return new ArrayList();
+ }
- public void setService(IUserManagementService service) {
- this.service = service;
+ // returns x size list where x is number of orgs.
+ // 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) throws IOException {
+ results = new ArrayList();
+ parentOrg = service.getRootOrganisation();
+ HSSFSheet sheet = getSheet(fileItem);
+ int startRow = sheet.getFirstRowNum();
+ int endRow = sheet.getLastRowNum();
+
+ log.debug("Parsing spreadsheet rows " + startRow + " through " + endRow);
+
+ HSSFRow row;
+ Organisation org = null;
+ int successful = 0;
+ for (int i = startRow + 1; i < endRow + 1; i++) {
+ emptyRow = true;
+ hasError = false;
+ rowResult = new ArrayList();
+ row = sheet.getRow(i);
+ if (row != null) {
+ org = parseGroup(row, i);
+ }
+
+ // an empty row signifies a new group
+ if (emptyRow) {
+ log.debug("Row " + i + " is empty.");
+ parentOrg = service.getRootOrganisation();
+ continue;
+ }
+ if (hasError) {
+ log.debug("Row " + i + " has an error which has been sent to the browser.");
+ results.add(rowResult);
+ continue;
+ } else {
+ org = service.saveOrganisation(org, getCurrentUserId());
+ successful++;
+ rowResult.add(org.getOrganisationId().toString());
+ rowResult.add(org.getName());
+ rowResult.add(org.getParentOrganisation().getOrganisationId().toString());
+ rowResult.add(org.getOrganisationType().getOrganisationTypeId().toString());
+ writeOrgAuditLog(org);
+ // if we just added a group, then the rows under it become it's subgroups
+ if (parentOrg.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.ROOT_TYPE)) {
+ parentOrg = org;
+ }
+ results.add(rowResult);
+ }
}
-
- public MessageService getMessageService() {
- return messageService;
+ log.debug("Found " + results.size() + " orgs in spreadsheet.");
+ writeSuccessAuditLog(successful, null, "audit.successful.organisation.import");
+ return results;
+ }
+
+ private Integer getCurrentUserId() {
+ try {
+ UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
+ return user.getUserID();
+ } catch (Exception e) {
+ log.error(e);
}
+ return null;
+ }
- public void setMessageService(MessageService messageService) {
- this.messageService = messageService;
+ private Organisation parseGroup(HSSFRow row, int rowIndex) {
+ Organisation org = new Organisation();
+ String[] args = new String[1];
+
+ String name = parseStringCell(row.getCell(NAME));
+
+ //validate organisation name
+ if (StringUtils.isBlank(name)) {
+ rowResult.add(messageService.getMessage("error.name.required"));
+ hasError = true;
+ return null;
+
+ } else if (!ValidationUtil.isOrgNameValid(name)) {
+ rowResult.add(messageService.getMessage("error.name.invalid.characters"));
+ hasError = true;
+ return null;
}
-
- public IAuditService getAuditService() {
- return auditService;
- }
- public void setAuditService(IAuditService auditService) {
- this.auditService = auditService;
+ org.setName(name);
+ org.setCode(parseStringCell(row.getCell(CODE)));
+ org.setDescription(parseStringCell(row.getCell(DESCRIPTION)));
+
+ String localeId = parseStringCell(row.getCell(LOCALE_ID));
+ SupportedLocale locale = getLocale(localeId);
+ if (locale == null) {
+ args[0] = "(" + localeId + ")";
+ rowResult.add(messageService.getMessage("error.locale.invalid", args));
+ hasError = true;
+ } else {
+ org.setLocale(locale);
}
-
- // spreadsheet column indexes for user spreadsheet
- private static final short LOGIN = 0;
- private static final short PASSWORD = 1;
- private static final short TITLE = 2;
- private static final short FIRST_NAME = 3;
- private static final short LAST_NAME = 4;
- private static final short AUTH_METHOD = 5;
- private static final short EMAIL = 6;
- private static final short FLASH_THEME = 7;
- private static final short HTML_THEME = 8;
- private static final short LOCALE = 9;
- private static final short ADDRESS1 = 10;
- private static final short ADDRESS2 = 11;
- private static final short ADDRESS3 = 12;
- private static final short CITY = 13;
- private static final short STATE = 14;
- private static final short POSTCODE = 15;
- private static final short COUNTRY = 16;
- private static final short DAY_PHONE = 17;
- private static final short EVE_PHONE = 18;
- private static final short MOB_PHONE = 19;
- private static final short FAX = 20;
-
- // spreadsheet column indexes for userorgrole spreadsheet
- private static final short ORGANISATION = 1;
- private static final short ROLES = 2;
-
- // spreadsheet column indexes for groups spreadsheet
- private static final short NAME = 0;
- private static final short CODE = 1;
- private static final short DESCRIPTION = 2;
- private static final short LOCALE_ID = 3;
- private static final short ORGANISATION_STATE = 4;
- private static final short ADMIN_ADD_NEW_USERS = 5;
- private static final short ADMIN_BROWSE_ALL_USERS = 6;
- private static final short ADMIN_CHANGE_STATUS = 7;
-
- // class-wide variables
- ArrayList results = new ArrayList();
- ArrayList rowResult = new ArrayList();
- private boolean emptyRow;
- private boolean hasError;
- private Organisation parentOrg;
- private HSSFSheet getSheet(FormFile fileItem) throws IOException {
- POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream());
- HSSFWorkbook wb = new HSSFWorkbook(fs);
- return wb.getSheetAt(0);
+ String orgStateText = parseStringCell(row.getCell(ORGANISATION_STATE));
+ OrganisationState orgState = getOrganisationState(orgStateText);
+ org.setOrganisationState(orgState);
+
+ org.setOrganisationType((OrganisationType) service.findById(OrganisationType.class,
+ parentOrg.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.ROOT_TYPE)
+ ? OrganisationType.COURSE_TYPE : OrganisationType.CLASS_TYPE));
+
+ org.setParentOrganisation(parentOrg);
+ org.setCourseAdminCanAddNewUsers(parseBooleanCell(row.getCell(ADMIN_ADD_NEW_USERS)));
+ org.setCourseAdminCanBrowseAllUsers(parseBooleanCell(row.getCell(ADMIN_BROWSE_ALL_USERS)));
+ org.setCourseAdminCanChangeStatusOfCourse(parseBooleanCell(row.getCell(ADMIN_CHANGE_STATUS)));
+
+ return (hasError ? null : org);
+ }
+
+ private boolean isIntegratedUser(List integPrefixes, String login) {
+ int underscore = login.indexOf('_');
+ if (underscore >= 0) {
+ if (integPrefixes.contains(login.substring(0, underscore))) {
+ return true;
+ }
}
-
- public boolean isUserSpreadsheet(FormFile fileItem) throws IOException {
- HSSFSheet sheet = getSheet(fileItem);
- HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
- String string = parseStringCell(row.getCell(PASSWORD));
- return (StringUtils.equals(string, "* password")) ? true : false;
- }
-
- public boolean isRolesSpreadsheet(FormFile fileItem) throws IOException {
- HSSFSheet sheet = getSheet(fileItem);
- HSSFRow row = sheet.getRow(sheet.getFirstRowNum());
- String string = parseStringCell(row.getCell(ORGANISATION));
- return (StringUtils.equals(string, "* organisation")) ? true : false;
- }
-
- public List parseSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- if (isUserSpreadsheet(fileItem)) {
- return parseUserSpreadsheet(fileItem, sessionId);
- } else if (isRolesSpreadsheet(fileItem)) {
- return parseRolesSpreadsheet(fileItem, sessionId);
- }
- return new ArrayList();
- }
-
- // returns x size list where x is number of orgs.
- // 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.
- public List parseGroupSpreadsheet(FormFile fileItem) throws IOException {
- results = new ArrayList();
- parentOrg = service.getRootOrganisation();
- HSSFSheet sheet = getSheet(fileItem);
- int startRow = sheet.getFirstRowNum();
- int endRow = sheet.getLastRowNum();
-
- log.debug("Parsing spreadsheet rows "+startRow+" through "+endRow);
-
- HSSFRow row;
- Organisation org = null;
- int successful = 0;
- for (int i = startRow + 1; i < endRow + 1; i++) {
- emptyRow = true;
- hasError = false;
- rowResult = new ArrayList();
- row = sheet.getRow(i);
- if (row != null) {
- org = parseGroup(row, i);
- }
-
- // an empty row signifies a new group
- if (emptyRow) {
- log.debug("Row "+i+" is empty.");
- parentOrg = service.getRootOrganisation();
- continue;
- }
- if (hasError) {
- log.debug("Row "+i+" has an error which has been sent to the browser.");
- results.add(rowResult);
- continue;
- } else {
- org = service.saveOrganisation(org, getCurrentUserId());
- successful++;
- rowResult.add(org.getOrganisationId().toString());
- rowResult.add(org.getName());
- rowResult.add(org.getParentOrganisation().getOrganisationId().toString());
- rowResult.add(org.getOrganisationType().getOrganisationTypeId().toString());
- writeOrgAuditLog(org);
- // if we just added a group, then the rows under it become it's subgroups
- if (parentOrg.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.ROOT_TYPE)) {
- parentOrg = org;
- }
- results.add(rowResult);
- }
- }
- log.debug("Found "+results.size()+" orgs in spreadsheet.");
- writeSuccessAuditLog(successful, null, "audit.successful.organisation.import");
- return results;
- }
-
- private Integer getCurrentUserId() {
+ return false;
+ }
+
+ @Override
+ public int getNumRows(FormFile 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();
+ HSSFSheet sheet = getSheet(fileItem);
+ int startRow = sheet.getFirstRowNum();
+ int endRow = sheet.getLastRowNum();
+
+ setupImportStatus(sessionId, endRow - startRow);
+ UserDTO userDTO = (UserDTO) SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
+
+ log.debug("Parsing spreadsheet rows " + startRow + " through " + endRow);
+
+ HSSFRow row;
+ User user = null;
+ int successful = 0;
+ for (int i = startRow + 1; i < endRow + 1; i++) {
+ emptyRow = true;
+ hasError = false;
+ rowResult = new ArrayList();
+ row = sheet.getRow(i);
+ user = parseUser(row, i);
+
+ if (emptyRow) {
+ log.debug("Row " + i + " is empty.");
+ break;
+ }
+ if (hasError) {
+ log.debug("Row " + i + " has an error which has been sent to the browser.");
+ results.add(rowResult);
+ writeErrorsAuditLog(i + 1, rowResult, userDTO);
+ updateImportStatus(sessionId, results.size());
+ continue;
+ } else {
try {
- UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
- return user.getUserID();
+ service.save(user);
+ successful++;
+ writeAuditLog(user, userDTO);
+ log.debug("Row " + i + " saved user: " + user.getLogin());
} catch (Exception e) {
- log.error(e);
+ log.debug(e);
+ rowResult.add(messageService.getMessage("error.fail.add"));
}
- return null;
- }
-
- private Organisation parseGroup(HSSFRow row, int rowIndex) {
- Organisation org = new Organisation();
- String[] args = new String[1];
-
- String name = parseStringCell(row.getCell(NAME));
-
- //validate organisation name
- if (StringUtils.isBlank(name)) {
- rowResult.add(messageService.getMessage("error.name.required"));
- hasError = true;
- return null;
-
- } else if (!ValidationUtil.isOrgNameValid(name)) {
- rowResult.add(messageService.getMessage("error.name.invalid.characters"));
- hasError = true;
- return null;
+ if (rowResult.size() > 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("Row " + i + " has " + rowResult.size() + " messages.");
+ }
+ writeErrorsAuditLog(i + 1, rowResult, userDTO);
}
-
- org.setName(name);
- org.setCode(parseStringCell(row.getCell(CODE)));
- org.setDescription(parseStringCell(row.getCell(DESCRIPTION)));
-
- String localeId = parseStringCell(row.getCell(LOCALE_ID));
- SupportedLocale locale = getLocale(localeId);
- if (locale==null) {
- args[0] = "("+localeId+")";
- rowResult.add(messageService.getMessage("error.locale.invalid", args));
- hasError = true;
- } else {
- org.setLocale(locale);
- }
-
- String orgStateText = parseStringCell(row.getCell(ORGANISATION_STATE));
- OrganisationState orgState = getOrganisationState(orgStateText);
- org.setOrganisationState(orgState);
+ results.add(rowResult);
+ updateImportStatus(sessionId, results.size());
+ }
+ }
+ log.debug("Found " + results.size() + " users in spreadsheet.");
+ writeSuccessAuditLog(successful, userDTO, "audit.successful.user.import");
+ return results;
+ }
- org.setOrganisationType((OrganisationType)service.findById(OrganisationType.class,
- parentOrg.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.ROOT_TYPE)
- ? OrganisationType.COURSE_TYPE : OrganisationType.CLASS_TYPE));
+ // use session vars to update browser with import progress so page
+ // won't timeout
+ private void setupImportStatus(String sessionId, int importTotal) {
+ HttpSession ss = SessionManager.getSession(sessionId);
+ ss.setAttribute(STATUS_IMPORT_TOTAL, importTotal);
+ ss.setAttribute(STATUS_IMPORTED, 0);
+ }
- org.setParentOrganisation(parentOrg);
- org.setCourseAdminCanAddNewUsers(parseBooleanCell(row.getCell(ADMIN_ADD_NEW_USERS)));
- org.setCourseAdminCanBrowseAllUsers(parseBooleanCell(row.getCell(ADMIN_BROWSE_ALL_USERS)));
- org.setCourseAdminCanChangeStatusOfCourse(parseBooleanCell(row.getCell(ADMIN_CHANGE_STATUS)));
-
- return (hasError ? null : org);
- }
-
- private boolean isIntegratedUser(List integPrefixes, String login) {
- int underscore = login.indexOf('_');
- if (underscore >= 0) {
- if (integPrefixes.contains(login.substring(0, underscore))) {
- return true;
- }
+ private void updateImportStatus(String sessionId, int imported) {
+ HttpSession ss = SessionManager.getSession(sessionId);
+ ss.removeAttribute(STATUS_IMPORTED);
+ ss.setAttribute(STATUS_IMPORTED, imported);
+ }
+
+ @Override
+ public List parseRolesSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
+ results = new ArrayList();
+ HSSFSheet sheet = getSheet(fileItem);
+ int startRow = sheet.getFirstRowNum();
+ int endRow = sheet.getLastRowNum();
+
+ log.debug("Parsing spreadsheet rows " + startRow + " through " + endRow);
+
+ setupImportStatus(sessionId, endRow - startRow);
+ UserDTO userDTO = (UserDTO) SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
+
+ HSSFRow row;
+ List roles;
+ int successful = 0;
+ for (int i = startRow + 1; i < endRow + 1; i++) {
+ emptyRow = true;
+ hasError = false;
+ rowResult = new ArrayList();
+ row = sheet.getRow(i);
+
+ String login = parseStringCell(row.getCell(LOGIN));
+ String orgId = parseStringCell(row.getCell(ORGANISATION));
+ roles = parseRolesCell(row.getCell(ROLES));
+
+ if (emptyRow) {
+ log.debug("Row " + i + " is empty.");
+ break;
+ }
+ if (hasError) {
+ log.debug("Row " + i + " has an error which has been sent to the browser.");
+ results.add(rowResult);
+ writeErrorsAuditLog(i + 1, rowResult, userDTO);
+ updateImportStatus(sessionId, results.size());
+ continue;
+ } else {
+ try {
+ saveUserRoles(isSysadmin(sessionId), login, orgId, roles, row);
+ successful++;
+ } catch (Exception e) {
+ log.error("Unable to assign roles to user: " + login, e);
+ rowResult.add(messageService.getMessage("error.fail.add"));
}
- return false;
- }
-
- public int getNumRows(FormFile fileItem) throws IOException {
- HSSFSheet sheet = getSheet(fileItem);
- int startRow = sheet.getFirstRowNum();
- int endRow = sheet.getLastRowNum();
- return endRow - startRow;
- }
-
- public List parseUserSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- results = new ArrayList();
- HSSFSheet sheet = getSheet(fileItem);
- int startRow = sheet.getFirstRowNum();
- int endRow = sheet.getLastRowNum();
-
- setupImportStatus(sessionId, endRow-startRow);
- UserDTO userDTO = (UserDTO)SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
-
- log.debug("Parsing spreadsheet rows "+startRow+" through "+endRow);
-
- HSSFRow row;
- User user = null;
- int successful = 0;
- for (int i = startRow + 1; i < endRow + 1; i++) {
- emptyRow = true;
- hasError = false;
- rowResult = new ArrayList();
- row = sheet.getRow(i);
- user = parseUser(row, i);
-
- if (emptyRow) {
- log.debug("Row "+i+" is empty.");
- break;
- }
- if (hasError) {
- log.debug("Row "+i+" has an error which has been sent to the browser.");
- results.add(rowResult);
- writeErrorsAuditLog(i+1, rowResult, userDTO);
- updateImportStatus(sessionId, results.size());
- continue;
- } else {
- try {
- service.save(user);
- successful++;
- writeAuditLog(user, userDTO);
- log.debug("Row "+i+" saved user: "+user.getLogin());
- } catch (Exception e) {
- log.debug(e);
- rowResult.add(messageService.getMessage("error.fail.add"));
- }
- if (rowResult.size() > 0) {
- if (log.isDebugEnabled()) log.debug("Row "+i+" has "+rowResult.size() + " messages.");
- writeErrorsAuditLog(i+1, rowResult, userDTO);
- }
- results.add(rowResult);
- updateImportStatus(sessionId, results.size());
- }
+ if (rowResult.size() > 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("Row " + i + " has " + rowResult.size() + " messages.");
+ }
+ writeErrorsAuditLog(i + 1, rowResult, userDTO);
}
- log.debug("Found "+results.size()+" users in spreadsheet.");
- writeSuccessAuditLog(successful, userDTO, "audit.successful.user.import");
- return results;
+ results.add(rowResult);
+ updateImportStatus(sessionId, results.size());
+ }
}
-
- // use session vars to update browser with import progress so page
- // won't timeout
- private void setupImportStatus(String sessionId, int importTotal) {
- HttpSession ss = SessionManager.getSession(sessionId);
- ss.setAttribute(STATUS_IMPORT_TOTAL, importTotal);
- ss.setAttribute(STATUS_IMPORTED, 0);
+ log.debug("Found " + results.size() + " users in spreadsheet.");
+ writeSuccessAuditLog(successful, userDTO, "audit.successful.role.import");
+ return results;
+ }
+
+ private void setError(String message, String arg) {
+ if (StringUtils.isBlank(arg)) {
+ rowResult.add(messageService.getMessage(message));
+ } else {
+ String[] args = new String[1];
+ args[0] = arg;
+ rowResult.add(messageService.getMessage(message, args));
}
-
- private void updateImportStatus(String sessionId, int imported) {
- HttpSession ss = SessionManager.getSession(sessionId);
- ss.removeAttribute(STATUS_IMPORTED);
- ss.setAttribute(STATUS_IMPORTED, imported);
+ hasError = true;
+ }
+
+ // used when importing in a separate thread that doesn't have the user's DTO in session
+ private boolean isSysadmin(String sessionId) {
+ UserDTO userDTO = (UserDTO) SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
+ return service.isUserInRole(userDTO.getUserID(), service.getRootOrganisation().getOrganisationId(),
+ Role.SYSADMIN);
+ }
+
+ /*
+ * user must already exist
+ */
+ private void saveUserRoles(boolean isSysadmin, String login, String orgId, List roles, HSSFRow row) {
+ User user = null;
+ if (StringUtils.isNotBlank(login)) {
+ user = service.getUserByLogin(login);
+ } else if (StringUtils.isBlank(login)) {
+ setError("error.login.required", "");
}
-
- public List parseRolesSpreadsheet(FormFile fileItem, String sessionId) throws IOException {
- results = new ArrayList();
- HSSFSheet sheet = getSheet(fileItem);
- int startRow = sheet.getFirstRowNum();
- int endRow = sheet.getLastRowNum();
-
- log.debug("Parsing spreadsheet rows "+startRow+" through "+endRow);
-
- setupImportStatus(sessionId, endRow-startRow);
- UserDTO userDTO = (UserDTO)SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
-
- HSSFRow row;
- List roles;
- int successful = 0;
- for (int i = startRow + 1; i < endRow + 1; i++) {
- emptyRow = true;
- hasError = false;
- rowResult = new ArrayList();
- row = sheet.getRow(i);
-
- String login = parseStringCell(row.getCell(LOGIN));
- String orgId = parseStringCell(row.getCell(ORGANISATION));
- roles = parseRolesCell(row.getCell(ROLES));
-
- if (emptyRow) {
- log.debug("Row "+i+" is empty.");
- break;
- }
- if (hasError) {
- log.debug("Row "+i+" has an error which has been sent to the browser.");
- results.add(rowResult);
- writeErrorsAuditLog(i+1, rowResult, userDTO);
- updateImportStatus(sessionId, results.size());
- continue;
- } else {
- try {
- saveUserRoles(isSysadmin(sessionId), login, orgId, roles, row);
- successful++;
- } catch (Exception e) {
- log.error("Unable to assign roles to user: "+login, e);
- rowResult.add(messageService.getMessage("error.fail.add"));
- }
- if (rowResult.size() > 0) {
- if (log.isDebugEnabled()) log.debug("Row "+i+" has "+rowResult.size() + " messages.");
- writeErrorsAuditLog(i+1, rowResult, userDTO);
- }
- results.add(rowResult);
- updateImportStatus(sessionId, results.size());
- }
- }
- log.debug("Found "+results.size()+" users in spreadsheet.");
- writeSuccessAuditLog(successful, userDTO, "audit.successful.role.import");
- return results;
+ if (user == null) {
+ setError("error.user.does.not.exist", "(" + login + ")");
}
-
- private void setError(String message, String arg) {
- if (StringUtils.isBlank(arg)) {
- rowResult.add(messageService.getMessage(message));
- } else {
- String[] args = new String[1];
- args[0] = arg;
- rowResult.add(messageService.getMessage(message, args));
- }
- hasError = true;
+
+ Organisation org = null;
+ if (StringUtils.isNotBlank(orgId)) {
+ org = (Organisation) service.findById(Organisation.class, new Integer(orgId));
}
-
- // used when importing in a separate thread that doesn't have the user's DTO in session
- private boolean isSysadmin(String sessionId) {
- UserDTO userDTO = (UserDTO)SessionManager.getSession(sessionId).getAttribute(AttributeNames.USER);
- return service.isUserInRole(userDTO.getUserID(), service.getRootOrganisation().getOrganisationId(), Role.SYSADMIN);
+ if (StringUtils.isBlank(orgId) || org == null) {
+ setError("error.org.invalid", "(" + orgId + ")");
+ } else {
+ if (roles == null || !checkValidRoles(roles, isSysadmin, org.getOrganisationType())) {
+ setError("error.roles.invalid", "(" + parseStringCell(row.getCell(ROLES)) + ")");
+ }
}
-
- /*
- * user must already exist
- */
- private void saveUserRoles(boolean isSysadmin, String login, String orgId, List roles, HSSFRow row) {
- User user = null;
- if (StringUtils.isNotBlank(login)) {
- user = service.getUserByLogin(login);
- } else if (StringUtils.isBlank(login)) {
- setError("error.login.required", "");
- }
- if (user==null) {
- setError("error.user.does.not.exist", "("+login+")");
- }
-
- Organisation org = null;
- if (StringUtils.isNotBlank(orgId)) {
- org = (Organisation)service.findById(Organisation.class, new Integer(orgId));
- }
- if (StringUtils.isBlank(orgId) || org==null){
- setError("error.org.invalid", "("+orgId+")");
- } else {
- if (roles==null || !checkValidRoles(roles, isSysadmin, org.getOrganisationType())) {
- setError("error.roles.invalid", "("+parseStringCell(row.getCell(ROLES))+")");
- }
- }
-
- if (!hasError) {
- service.setRolesForUserOrganisation(user, org.getOrganisationId(), roles);
- if (log.isDebugEnabled()) {
- log.debug("added: "+login+" to: "+org.getName()+" with roles: "+roles);
- }
- }
+
+ if (!hasError) {
+ service.setRolesForUserOrganisation(user, org.getOrganisationId(), roles);
+ if (log.isDebugEnabled()) {
+ log.debug("added: " + login + " to: " + org.getName() + " with roles: " + roles);
+ }
}
-
+ }
+
/*
* gathers error messages for each cell as required, unless it's the login field in which case, flags whole row as
* empty.
@@ -493,12 +499,12 @@
rowResult.add(messageService.getMessage("error.login.required"));
hasError = true;
return null;
-
+
} else if (!ValidationUtil.isUserNameValid(login)) {
rowResult.add(messageService.getMessage("error.username.invalid.characters"));
hasError = true;
return null;
-
+
} else if (service.getUserByLogin(login) != null) {
args[0] = "(" + login + ")";
rowResult.add(messageService.getMessage("error.login.unique", args));
@@ -523,11 +529,11 @@
if (StringUtils.isBlank(firstName)) {
rowResult.add(messageService.getMessage("error.firstname.required"));
hasError = true;
-
+
} else if (!ValidationUtil.isFirstLastNameValid(firstName)) {
rowResult.add(messageService.getMessage("error.firstname.invalid.characters"));
- hasError = true;
-
+ hasError = true;
+
} else {
user.setFirstName(firstName);
}
@@ -537,11 +543,11 @@
if (StringUtils.isBlank(lastName)) {
rowResult.add(messageService.getMessage("error.lastname.required"));
hasError = true;
-
+
} else if (!ValidationUtil.isFirstLastNameValid(lastName)) {
rowResult.add(messageService.getMessage("error.lastname.invalid.characters"));
hasError = true;
-
+
} else {
user.setLastName(lastName);
}
@@ -553,7 +559,7 @@
args[0] = "(" + authMethodName + ")";
rowResult.add(messageService.getMessage("error.authmethod.invalid", args));
hasError = true;
-
+
} else {
user.setAuthenticationMethod(authMethod);
}
@@ -563,11 +569,11 @@
if (StringUtils.isBlank(email)) {
rowResult.add(messageService.getMessage("error.email.required"));
hasError = true;
-
+
} else if (!ValidationUtil.isEmailValid(email)) {
rowResult.add(messageService.getMessage("error.valid.email.required"));
hasError = true;
-
+
} else {
user.setEmail(email);
}
@@ -621,237 +627,236 @@
return (hasError ? null : user);
}
-
- /*
- * the methods below return legible data from individual cells
- */
- private boolean parseBooleanCell(HSSFCell cell){
- if (cell!=null) {
- String value;
- try {
- cell.setCellType(HSSFCell.CELL_TYPE_STRING);
- if (cell.getStringCellValue()!= null) {
- if (cell.getStringCellValue().trim().length()!= 0) {
- emptyRow = false;
- }
- } else {
- return false;
- }
- value = cell.getStringCellValue().trim();
- } catch(Exception e) {
- cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- double d = cell.getNumericCellValue();
- emptyRow = false;
- value = new Long(new Double(d).longValue()).toString();
- }
- if (StringUtils.equals(value, "1") || StringUtils.equalsIgnoreCase(value, "true")) {
- return true;
- }
- }
- return false;
- }
-
- private String parseStringCell(HSSFCell cell){
- if (cell!=null) {
- try {
- cell.setCellType(HSSFCell.CELL_TYPE_STRING);
- if (cell.getStringCellValue()!= null) {
- if (cell.getStringCellValue().trim().length()!= 0) {
- emptyRow = false;
- }
- } else {
- return null;
- }
- // log.debug("string cell value: '"+cell.getStringCellValue().trim()+"'");
- return cell.getStringCellValue().trim();
- } catch(Exception e) {
- cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
- double d = cell.getNumericCellValue();
- emptyRow = false;
- // log.debug("numeric cell value: '"+d+"'");
- return (new Long(new Double(d).longValue()).toString());
- }
- }
- return null;
- }
-
- private AuthenticationMethod getAuthMethod(String authMethodName){
- List list;
- if (authMethodName==null || authMethodName=="") {
- return (AuthenticationMethod)service.findById(AuthenticationMethod.class, AuthenticationMethod.DB);
+
+ /*
+ * the methods below return legible data from individual cells
+ */
+ private boolean parseBooleanCell(HSSFCell cell) {
+ if (cell != null) {
+ String value;
+ try {
+ cell.setCellType(Cell.CELL_TYPE_STRING);
+ if (cell.getStringCellValue() != null) {
+ if (cell.getStringCellValue().trim().length() != 0) {
+ emptyRow = false;
+ }
} else {
- try {
- Integer authMethodId = new Integer(authMethodName);
- return (AuthenticationMethod)service.findById(AuthenticationMethod.class, authMethodId);
- } catch (NumberFormatException e) {
- list = service.findByProperty(AuthenticationMethod.class, "authenticationMethodName", authMethodName);
- return ( list==null || list.isEmpty() ? null : (AuthenticationMethod)list.get(0));
- }
+ return false;
}
+ value = cell.getStringCellValue().trim();
+ } catch (Exception e) {
+ cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ double d = cell.getNumericCellValue();
+ emptyRow = false;
+ value = new Long(new Double(d).longValue()).toString();
+ }
+ if (StringUtils.equals(value, "1") || StringUtils.equalsIgnoreCase(value, "true")) {
+ return true;
+ }
}
-
- private List parseRolesCell(HSSFCell cell)
- {
- String roleDescription = "";
- if (cell!=null) {
- try {
- cell.setCellType(HSSFCell.CELL_TYPE_STRING);
- if (cell.getStringCellValue()!= null || cell.getStringCellValue().trim().length()!= 0) {
- emptyRow = false;
- } else {
- log.debug("Couldn't find any roles in spreadsheet column index " + ROLES);
- return null;
- }
- roleDescription = cell.getStringCellValue().trim();
- } catch(Exception e) {
- log.error("Caught exception when reading roles in spreadsheet: " + e.getMessage());
- return null;
- }
- List roles = new ArrayList();
- int fromIndex = 0;
- int index = roleDescription.indexOf(SEPARATOR, fromIndex);
- while (index != -1) {
- String role = addRoleId(roleDescription, fromIndex, index);
- log.debug("Found role: "+role);
- if (role==null) {
- return null;
- } else {
- roles.add(role);
- }
- fromIndex = index + 1;
- index = roleDescription.indexOf(SEPARATOR, fromIndex);
- }
- String role = addRoleId(roleDescription, fromIndex, roleDescription.length());
- log.debug("Found last role: "+role);
- if (role==null) {
- return null;
- } else {
- roles.add(role);
- }
- return roles;
- }
- return null;
- }
-
- // return id of role name in given role description
- private String addRoleId(String roleDescription, int fromIndex, int index) {
- List list = service.findByProperty(Role.class, "name", roleDescription.substring(fromIndex, index));
- Role role = (list==null || list.isEmpty() ? null : (Role)list.get(0));
- if (role!=null) {
- return role.getRoleId().toString();
+ return false;
+ }
+
+ private String parseStringCell(HSSFCell cell) {
+ if (cell != null) {
+ try {
+ cell.setCellType(Cell.CELL_TYPE_STRING);
+ if (cell.getStringCellValue() != null) {
+ if (cell.getStringCellValue().trim().length() != 0) {
+ emptyRow = false;
+ }
} else {
- return null; // if we can't translate the name to a role, return null
+ return null;
}
+ // log.debug("string cell value: '"+cell.getStringCellValue().trim()+"'");
+ return cell.getStringCellValue().trim();
+ } catch (Exception e) {
+ cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+ double d = cell.getNumericCellValue();
+ emptyRow = false;
+ // log.debug("numeric cell value: '"+d+"'");
+ return (new Long(new Double(d).longValue()).toString());
+ }
}
-
- // 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();
- for (String id : idList) {
- Role role = (Role)service.findById(Role.class, Integer.parseInt(id));
- if (role!=null) {
- roleList.add(role);
- } else {
- return false;
- }
- }
-
- // check they are valid
- List validRoles = service.filterRoles(roleList, isSysadmin, orgType);
- for (Role r : roleList) {
- if (!validRoles.contains(r)) {
- return false;
- }
- }
- return true;
+ return null;
+ }
+
+ private AuthenticationMethod getAuthMethod(String authMethodName) {
+ List list;
+ if (authMethodName == null || authMethodName == "") {
+ return (AuthenticationMethod) service.findById(AuthenticationMethod.class, AuthenticationMethod.DB);
+ } else {
+ try {
+ Integer authMethodId = new Integer(authMethodName);
+ return (AuthenticationMethod) service.findById(AuthenticationMethod.class, authMethodId);
+ } catch (NumberFormatException e) {
+ list = service.findByProperty(AuthenticationMethod.class, "authenticationMethodName", authMethodName);
+ return (list == null || list.isEmpty() ? null : (AuthenticationMethod) list.get(0));
+ }
}
+ }
- // set Theme to default flash theme if cell is empty
- private Theme getFlashTheme(String flashId){
- if (flashId==null || flashId=="") {
- return service.getDefaultFlashTheme();
+ private List parseRolesCell(HSSFCell cell) {
+ String roleDescription = "";
+ if (cell != null) {
+ try {
+ cell.setCellType(Cell.CELL_TYPE_STRING);
+ if (cell.getStringCellValue() != null || cell.getStringCellValue().trim().length() != 0) {
+ emptyRow = false;
} else {
- try {
- return (Theme)service.findById(Theme.class, new Long(flashId));
- } catch (Exception e) {
- return null;
- }
+ log.debug("Couldn't find any roles in spreadsheet column index " + ROLES);
+ return null;
}
- }
-
- // set Theme to default html theme if cell is empty
- private Theme getHtmlTheme(String htmlId){
- if (htmlId==null || htmlId=="") {
- return service.getDefaultHtmlTheme();
+ roleDescription = cell.getStringCellValue().trim();
+ } catch (Exception e) {
+ log.error("Caught exception when reading roles in spreadsheet: " + e.getMessage());
+ return null;
+ }
+ List roles = new ArrayList();
+ int fromIndex = 0;
+ int index = roleDescription.indexOf(SEPARATOR, fromIndex);
+ while (index != -1) {
+ String role = addRoleId(roleDescription, fromIndex, index);
+ log.debug("Found role: " + role);
+ if (role == null) {
+ return null;
} else {
- try {
- return (Theme)service.findById(Theme.class, new Long(htmlId));
- } catch (Exception e) {
- return null;
- }
+ roles.add(role);
}
+ fromIndex = index + 1;
+ index = roleDescription.indexOf(SEPARATOR, fromIndex);
+ }
+ String role = addRoleId(roleDescription, fromIndex, roleDescription.length());
+ log.debug("Found last role: " + role);
+ if (role == null) {
+ return null;
+ } else {
+ roles.add(role);
+ }
+ return roles;
}
-
- // set locale to default system locale if cell is empty
- private SupportedLocale getLocale(String localeId){
- if (localeId==null || localeId=="") {
- return LanguageUtil.getDefaultLocale();
- } else {
- try {
- return (SupportedLocale)service.findById(SupportedLocale.class, new Integer(localeId));
- } catch (Exception e) {
- return null;
- }
- }
+ return null;
+ }
+
+ // return id of role name in given role description
+ private String addRoleId(String roleDescription, int fromIndex, int index) {
+ List list = service.findByProperty(Role.class, "name", roleDescription.substring(fromIndex, index));
+ Role role = (list == null || list.isEmpty() ? null : (Role) list.get(0));
+ if (role != null) {
+ return role.getRoleId().toString();
+ } else {
+ return null; // if we can't translate the name to a role, return null
}
-
- // set organisation state to active if cell is empty
- private OrganisationState getOrganisationState(String orgStateText) {
- if (StringUtils.equals(orgStateText, "hidden")) {
- return (OrganisationState)service.findById(OrganisationState.class, OrganisationState.HIDDEN);
- } else if (StringUtils.equals(orgStateText, "archived")) {
- return (OrganisationState)service.findById(OrganisationState.class, OrganisationState.ARCHIVED);
- } else {
- return (OrganisationState)service.findById(OrganisationState.class, OrganisationState.ACTIVE);
- }
+ }
+
+ // 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();
+ for (String id : idList) {
+ Role role = (Role) service.findById(Role.class, Integer.parseInt(id));
+ if (role != null) {
+ roleList.add(role);
+ } else {
+ return false;
+ }
}
-
- private void writeAuditLog(User user, UserDTO userDTO) {
- String[] args = new String[2];
- args[0] = user.getLogin()+"("+user.getUserId()+")";
- args[1] = user.getFullName();
- String message = messageService.getMessage("audit.user.create", args);
- auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
+
+ // check they are valid
+ List validRoles = service.filterRoles(roleList, isSysadmin, orgType);
+ for (Role r : roleList) {
+ if (!validRoles.contains(r)) {
+ return false;
+ }
}
-
- private void writeOrgAuditLog(Organisation org) {
- String[] args = new String[2];
- args[0] = org.getName()+"("+org.getOrganisationId()+")";
- args[1] = org.getOrganisationType().getName();
- String message = messageService.getMessage("audit.organisation.create", args);
- auditService.log(AdminConstants.MODULE_NAME, message);
+ return true;
+ }
+
+ // set Theme to default flash theme if cell is empty
+ private Theme getFlashTheme(String flashId) {
+ if (flashId == null || flashId == "") {
+ return service.getDefaultFlashTheme();
+ } else {
+ try {
+ return (Theme) service.findById(Theme.class, new Long(flashId));
+ } catch (Exception e) {
+ return null;
+ }
}
-
- private void writeErrorsAuditLog(int row, List list, UserDTO userDTO) {
- for (String s : list) {
- writeErrorAuditLog(row, s, userDTO);
- }
+ }
+
+ // set Theme to default html theme if cell is empty
+ private Theme getHtmlTheme(String htmlId) {
+ if (htmlId == null || htmlId == "") {
+ return service.getDefaultHtmlTheme();
+ } else {
+ try {
+ return (Theme) service.findById(Theme.class, new Long(htmlId));
+ } catch (Exception e) {
+ return null;
+ }
}
-
- private void writeErrorAuditLog(int row, String error, UserDTO userDTO) {
- String[] args = { Integer.toString(row), error };
- String message = messageService.getMessage("audit.spreadsheet.error", args);
- auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
+ }
+
+ // set locale to default system locale if cell is empty
+ private SupportedLocale getLocale(String localeId) {
+ if (localeId == null || localeId == "") {
+ return LanguageUtil.getDefaultLocale();
+ } else {
+ try {
+ return (SupportedLocale) service.findById(SupportedLocale.class, new Integer(localeId));
+ } catch (Exception e) {
+ return null;
+ }
}
-
- private void writeSuccessAuditLog(int successful, UserDTO userDTO, String key) {
- String[] args = { Integer.toString(successful) };
- String message = messageService.getMessage(key, args);
- if (userDTO == null) {
- auditService.log(AdminConstants.MODULE_NAME, message);
- } else {
- auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
- }
+ }
+
+ // set organisation state to active if cell is empty
+ private OrganisationState getOrganisationState(String orgStateText) {
+ if (StringUtils.equals(orgStateText, "hidden")) {
+ return (OrganisationState) service.findById(OrganisationState.class, OrganisationState.HIDDEN);
+ } else if (StringUtils.equals(orgStateText, "archived")) {
+ return (OrganisationState) service.findById(OrganisationState.class, OrganisationState.ARCHIVED);
+ } else {
+ return (OrganisationState) service.findById(OrganisationState.class, OrganisationState.ACTIVE);
}
+ }
+
+ private void writeAuditLog(User user, UserDTO userDTO) {
+ String[] args = new String[2];
+ args[0] = user.getLogin() + "(" + user.getUserId() + ")";
+ args[1] = user.getFullName();
+ String message = messageService.getMessage("audit.user.create", args);
+ auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
+ }
+
+ private void writeOrgAuditLog(Organisation org) {
+ String[] args = new String[2];
+ args[0] = org.getName() + "(" + org.getOrganisationId() + ")";
+ args[1] = org.getOrganisationType().getName();
+ String message = messageService.getMessage("audit.organisation.create", args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+
+ private void writeErrorsAuditLog(int row, List list, UserDTO userDTO) {
+ for (String s : list) {
+ writeErrorAuditLog(row, s, userDTO);
+ }
+ }
+
+ private void writeErrorAuditLog(int row, String error, UserDTO userDTO) {
+ String[] args = { Integer.toString(row), error };
+ String message = messageService.getMessage("audit.spreadsheet.error", args);
+ auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
+ }
+
+ private void writeSuccessAuditLog(int successful, UserDTO userDTO, String key) {
+ String[] args = { Integer.toString(successful) };
+ String message = messageService.getMessage(key, args);
+ if (userDTO == null) {
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ } else {
+ auditService.log(userDTO, AdminConstants.MODULE_NAME, message);
+ }
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheAction.java
===================================================================
diff -u -r4f40b2a39d2e2a4fcaeebe3568eb91858732fb8f -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheAction.java (.../CacheAction.java) (revision 4f40b2a39d2e2a4fcaeebe3568eb91858732fb8f)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheAction.java (.../CacheAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,29 +2,28 @@
* 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
+ * 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
* ****************************************************************
*/
/* $CacheAction.java,v 1.3 2006/04/03 23:20:58 fmalikoff Exp$ */
package org.lamsfoundation.lams.admin.web;
import java.io.IOException;
-import java.util.Map;
import java.util.Set;
import javax.servlet.ServletException;
@@ -42,101 +41,103 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
-
/**
* This is an action where all lams client environments launch.
* Initial configuration of the individual environment setting is done here.
- *
+ *
* @struts:action name="CacheActionForm"
- * path="/cache"
- * parameter="method"
- * validate="false"
+ * path="/cache"
+ * parameter="method"
+ * validate="false"
* @struts:action-forward name="cache" path=".cache"
*
*/
public class CacheAction extends LamsDispatchAction {
-
- public static final String CACHE_ENTRIES = "cache";
- public static final String NODE_KEY = "node";
-
- private static Logger log = Logger.getLogger(CacheAction.class);
- private static ICacheManager cacheManager;
+
+ public static final String CACHE_ENTRIES = "cache";
+ public static final String NODE_KEY = "node";
+
+ private static Logger log = Logger.getLogger(CacheAction.class);
+ private static ICacheManager cacheManager;
+
/**
- * request for sysadmin environment
- */
- public ActionForward unspecified(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws IOException, ServletException {
+ * request for sysadmin environment
+ */
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest req,
+ HttpServletResponse res) throws IOException, ServletException {
- try {
- if (log.isDebugEnabled()) {
- log.debug("Cache lookup");
- }
-
- // todo restrict access to admin only. Can't do at present as don't know orgID
- log.warn("CacheAction should be restricted to admin only. No check being done. Please implement.");
- /*String login = req.getRemoteUser();
- int orgId = new Integer(req.getParameter("orgId")).intValue();
-
- if ( isUserInRole(login,orgId,Role.ADMIN))
- {
- log.debug("user is admin");
- Organisation org = service.getOrganisationById(new Integer(orgId));
- AdminPreparer.prepare(org,req,service);
- return mapping.findForward("admin");
- }
- else
- {
- log.error("User "+login+" tried to get cache admin screen but isn't admin in organisation: "+orgId);
- return mapping.findForward("error");
- } */
-
- Set items = getCacheManager().getCachedClasses();
- req.setAttribute(CACHE_ENTRIES, items);
- return mapping.findForward("cache");
-
- } catch (Exception e) {
- e.printStackTrace();
- return mapping.findForward("error");
- }
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug("Cache lookup");
+ }
+
+ // todo restrict access to admin only. Can't do at present as don't know orgID
+ log.warn("CacheAction should be restricted to admin only. No check being done. Please implement.");
+ /*
+ * String login = req.getRemoteUser();
+ * int orgId = new Integer(req.getParameter("orgId")).intValue();
+ *
+ * if ( isUserInRole(login,orgId,Role.ADMIN))
+ * {
+ * log.debug("user is admin");
+ * Organisation org = service.getOrganisationById(new Integer(orgId));
+ * AdminPreparer.prepare(org,req,service);
+ * return mapping.findForward("admin");
+ * }
+ * else
+ * {
+ * log.error("User "+login+" tried to get cache admin screen but isn't admin in organisation: "+orgId);
+ * return mapping.findForward("error");
+ * }
+ */
+
+ Set items = getCacheManager().getCachedClasses();
+ req.setAttribute(CACHE_ENTRIES, items);
+ return mapping.findForward("cache");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return mapping.findForward("error");
}
-
- /**
- * request for sysadmin environment
- */
- public ActionForward remove(ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws IOException, ServletException {
+ }
- try {
- // todo restrict access to admin only. Can't do at present as don't know orgID
-
- if (log.isDebugEnabled()) {
- log.debug("Remove entity from cache");
- }
- String node = WebUtil.readStrParam(req, NODE_KEY);
+ /**
+ * request for sysadmin environment
+ */
+ public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException {
- // if node = ALL, remove all cache
- getCacheManager().clearCachedClass(node.equalsIgnoreCase("ALL") ? null : node);
-
- // so we know what entity has been removed
- req.setAttribute(NODE_KEY, node);
-
- // display the list again
- return unspecified(mapping,form,req,res);
-
- } catch (Exception e) {
- e.printStackTrace();
- return mapping.findForward("error");
- }
+ try {
+ // todo restrict access to admin only. Can't do at present as don't know orgID
+
+ if (log.isDebugEnabled()) {
+ log.debug("Remove entity from cache");
+ }
+ String node = WebUtil.readStrParam(req, NODE_KEY);
+
+ // if node = ALL, remove all cache
+ getCacheManager().clearCachedClass(node.equalsIgnoreCase("ALL") ? null : node);
+
+ // so we know what entity has been removed
+ req.setAttribute(NODE_KEY, node);
+
+ // display the list again
+ return unspecified(mapping, form, req, res);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ return mapping.findForward("error");
}
-
- private ICacheManager getCacheManager(){
- if(cacheManager==null){
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
- cacheManager = (CacheManager) ctx.getBean("cacheManager");
- }
- return cacheManager;
+ }
+
+ private ICacheManager getCacheManager() {
+ if (cacheManager == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ cacheManager = (CacheManager) ctx.getBean("cacheManager");
}
+ return cacheManager;
+ }
}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheActionForm.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheActionForm.java (.../CacheActionForm.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/CacheActionForm.java (.../CacheActionForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -30,37 +30,37 @@
/**
* @author fmalikoff
- *
+ *
* @struts:form name="CacheActionForm"
*/
public class CacheActionForm extends ActionForm {
- public static final String formName = "CacheActionForm"; // must match name in @struts:action section above
+ public static final String formName = "CacheActionForm"; // must match name in @struts:action section above
- private String node;
+ private String node;
- public CacheActionForm() {
- }
+ public CacheActionForm() {
+ }
+ /**
+ * Reset all properties to their default values.
+ *
+ * @param mapping
+ * The mapping used to select this instance
+ * @param request
+ * The servlet request we are processing
+ */
+ @Override
+ public void reset(ActionMapping mapping, HttpServletRequest request) {
+ setNode(null);
+ }
- /**
- * Reset all properties to their default values.
- *
- * @param mapping The mapping used to select this instance
- * @param request The servlet request we are processing
- */
- public void reset(ActionMapping mapping, HttpServletRequest request) {
- setNode(null);
- }
+ public String getNode() {
+ return node;
+ }
+ public void setNode(String node) {
+ this.node = node;
+ }
- public String getNode() {
- return node;
- }
-
-
- public void setNode(String node) {
- this.node = node;
- }
-
}
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java
===================================================================
diff -u -r7b9b1931a178ac9bac070531b53731383df0a187 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (.../ConfigAction.java) (revision 7b9b1931a178ac9bac070531b53731383df0a187)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (.../ConfigAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -43,100 +43,98 @@
*/
/**
* struts doclets
- *
- * @struts.action path="/config" parameter="method" name="ConfigForm" input=".editconfig" scope="request" validate="false"
+ *
+ * @struts.action path="/config" parameter="method" name="ConfigForm" input=".editconfig" scope="request"
+ * validate="false"
* @struts.action-forward name="config" path=".editconfig"
* @struts.action-forward name="ldap" path=".ldap"
* @struts.action-forward name="sysadmin" path="/sysadminstart.do"
*/
public class ConfigAction extends LamsDispatchAction {
- private static Configuration configurationService;
- private static MessageService messageService;
+ private static Configuration configurationService;
+ private static MessageService messageService;
- private Configuration getConfiguration() {
- if (configurationService == null) {
- configurationService = AdminServiceProxy.getConfiguration(getServlet().getServletContext());
- }
- return configurationService;
+ private Configuration getConfiguration() {
+ if (configurationService == null) {
+ configurationService = AdminServiceProxy.getConfiguration(getServlet().getServletContext());
}
-
- private MessageService getMessageService() {
- if (messageService == null) {
- messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
- }
- return messageService;
+ return configurationService;
+ }
+
+ private MessageService getMessageService() {
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
}
+ return messageService;
+ }
- public ActionForward unspecified(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
-
- request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
-
- return mapping.findForward("config");
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ request.setAttribute("config", getConfiguration().arrangeItems(Configuration.ITEMS_NON_LDAP));
+
+ return mapping.findForward("config");
+ }
+
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
}
-
- public ActionForward save(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
-
- if (isCancelled(request)) {
- return mapping.findForward("sysadmin");
+
+ DynaActionForm configForm = (DynaActionForm) form;
+ String[] keys = (String[]) configForm.get("key");
+ String[] values = (String[]) configForm.get("value");
+
+ String errorForward = "config";
+
+ for (int i = 0; i < keys.length; i++) {
+ ConfigurationItem item = getConfiguration().getConfigItemByKey(keys[i]);
+
+ // return to ldap page if that's where we came from
+ if (StringUtils.contains(item.getHeaderName(), "config.header.ldap")) {
+ errorForward = "ldap";
+ }
+
+ if (item != null) {
+ 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);
+ }
}
-
- DynaActionForm configForm = (DynaActionForm) form;
- String[] keys = (String[])configForm.get("key");
- String[] values = (String[])configForm.get("value");
-
- String errorForward = "config";
-
- for(int i=0; i0)) {
- 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]);
- }
+ 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);
+ }
}
- getConfiguration().persistUpdate();
-
- return mapping.findForward("sysadmin");
+ Configuration.updateItem(keys[i], values[i]);
+ }
}
-
- private String getRequiredError(String arg) {
- String[] args = new String[1];
- args[0] = getMessageService().getMessage(arg);
- return getMessageService().getMessage("error.required", args);
- }
-
- private String getNumericError(String arg) {
- String[] args = new String[1];
- args[0] = getMessageService().getMessage(arg);
- return getMessageService().getMessage("error.numeric", args);
- }
-
+ getConfiguration().persistUpdate();
+
+ return mapping.findForward("sysadmin");
+ }
+
+ private String getRequiredError(String arg) {
+ String[] args = new String[1];
+ args[0] = getMessageService().getMessage(arg);
+ return getMessageService().getMessage("error.required", args);
+ }
+
+ private String getNumericError(String arg) {
+ String[] args = new String[1];
+ args[0] = getMessageService().getMessage(arg);
+ return getMessageService().getMessage("error.numeric", args);
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/DisabledUserManageAction.java
===================================================================
diff -u -r91867eded7ee20f399144d4d9061d92723b70368 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/DisabledUserManageAction.java (.../DisabledUserManageAction.java) (revision 91867eded7ee20f399144d4d9061d92723b70368)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/DisabledUserManageAction.java (.../DisabledUserManageAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -41,35 +41,33 @@
/**
* @author jliew
- *
+ *
* @struts:action path="/disabledmanage" validate="false"
*
* @struts:action-forward name="disabledlist" path=".disabledlist"
*/
public class DisabledUserManageAction extends Action {
-
- private static final Logger log = Logger.getLogger(DisabledUserManageAction.class);
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- IUserManagementService service = AdminServiceProxy.getService(getServlet().getServletContext());
-
- if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
- request.setAttribute("errorName","DisabledUserManageAction");
- request.setAttribute("errorMessage",AdminServiceProxy
- .getMessageService(getServlet().getServletContext())
- .getMessage("error.need.sysadmin"));
- return mapping.findForward("error");
- }
-
- List users = service.findByProperty(User.class, "disabledFlag", true);
- log.debug("got "+users.size()+" disabled users");
- request.setAttribute("users", users);
-
- return mapping.findForward("disabledlist");
+
+ private static final Logger log = Logger.getLogger(DisabledUserManageAction.class);
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ IUserManagementService service = AdminServiceProxy.getService(getServlet().getServletContext());
+
+ if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) {
+ request.setAttribute("errorName", "DisabledUserManageAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.need.sysadmin"));
+ return mapping.findForward("error");
}
+ List users = service.findByProperty(User.class, "disabledFlag", true);
+ log.debug("got " + users.size() + " disabled users");
+ request.setAttribute("users", users);
+
+ return mapping.findForward("disabledlist");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelAction.java
===================================================================
diff -u -r0892350e28ca67031ad97e624f167dccd6272871 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelAction.java (.../ImportExcelAction.java) (revision 0892350e28ca67031ad97e624f167dccd6272871)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelAction.java (.../ImportExcelAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -36,26 +36,25 @@
* @author jliew
*
* @struts:action path="/importexcel"
- * name="ImportExcelForm"
- * scope="request"
- * validate="false"
- *
+ * name="ImportExcelForm"
+ * scope="request"
+ * validate="false"
+ *
* @struts:action-forward name="importexcel" path=".importexcel"
*/
public class ImportExcelAction extends Action {
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- Integer orgId = WebUtil.readIntParam(request,"orgId",true);
- //if (orgId==null) orgId = (Integer)request.getAttribute("orgId");
-
- ImportExcelForm importExcelForm = (ImportExcelForm)form;
- importExcelForm.setOrgId(orgId);
-
- return mapping.findForward("importexcel");
- }
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ //if (orgId==null) orgId = (Integer)request.getAttribute("orgId");
+
+ ImportExcelForm importExcelForm = (ImportExcelForm) form;
+ importExcelForm.setOrgId(orgId);
+
+ return mapping.findForward("importexcel");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelForm.java
===================================================================
diff -u -r0892350e28ca67031ad97e624f167dccd6272871 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelForm.java (.../ImportExcelForm.java) (revision 0892350e28ca67031ad97e624f167dccd6272871)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelForm.java (.../ImportExcelForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -32,24 +32,24 @@
* @struts.form name="ImportExcelForm"
*/
public class ImportExcelForm extends ActionForm {
-
- private Integer orgId;
- private FormFile file;
-
- public Integer getOrgId() {
- return orgId;
- }
-
- public void setOrgId(Integer orgId) {
- this.orgId = orgId;
- }
-
- public FormFile getFile() {
- return file;
- }
-
- public void setFile(FormFile file) {
- this.file = file;
- }
+ private Integer orgId;
+ private FormFile file;
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public FormFile getFile() {
+ return file;
+ }
+
+ public void setFile(FormFile file) {
+ this.file = file;
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelSaveAction.java
===================================================================
diff -u -r37f6755a9242e00ef1216aa86dc147efaeb02f75 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelSaveAction.java (.../ImportExcelSaveAction.java) (revision 37f6755a9242e00ef1216aa86dc147efaeb02f75)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelSaveAction.java (.../ImportExcelSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -41,67 +41,68 @@
* @author jliew
*
* @struts:action path="/importexcelsave"
- * name="ImportExcelForm"
- * input=".importexcel"
- * scope="request"
- * validate="false"
- *
+ * name="ImportExcelForm"
+ * input=".importexcel"
+ * scope="request"
+ * validate="false"
+ *
* @struts:action-forward name="importresult" path=".importresult"
* @struts:action-forward name="sysadmin" path="/sysadminstart.do"
* @struts:action-forward name="import" path="/importexcel.do"
* @struts:action-forward name="status" path="/import/status.jsp"
* @struts:action-forward name="results" path="/importuserresult.do"
*/
public class ImportExcelSaveAction extends Action {
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- if (isCancelled(request)) {
- return mapping.findForward("sysadmin");
- }
-
- IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
- ImportExcelForm importExcelForm = (ImportExcelForm)form;
- FormFile file = importExcelForm.getFile();
-
- // validation
- if (file==null || file.getFileSize()<=0) {
- return mapping.findForward("import");
- }
-
- String sessionId = (String)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 mapping.findForward("results");
- } else {
- Thread t = new Thread(new ImportExcelThread(sessionId));
- t.start();
- return mapping.findForward("status");
- }
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
}
-
-
- private class ImportExcelThread implements Runnable {
- private String sessionId;
-
- public ImportExcelThread(String sessionId) {
- this.sessionId = sessionId;
- }
-
- public void run() {
- IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
- try {
- FormFile file = (FormFile)SessionManager.getSession(sessionId).getAttribute(IImportService.IMPORT_FILE);
- List results = importService.parseSpreadsheet(file, sessionId);
- SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
- } catch (Exception e) {}
- }
+
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ ImportExcelForm importExcelForm = (ImportExcelForm) form;
+ FormFile file = importExcelForm.getFile();
+
+ // validation
+ if (file == null || file.getFileSize() <= 0) {
+ return mapping.findForward("import");
}
+ 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 mapping.findForward("results");
+ } else {
+ Thread t = new Thread(new ImportExcelThread(sessionId));
+ t.start();
+ return mapping.findForward("status");
+ }
+ }
+
+ private class ImportExcelThread implements Runnable {
+ private String sessionId;
+
+ public ImportExcelThread(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ @Override
+ public void run() {
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ try {
+ FormFile file = (FormFile) SessionManager.getSession(sessionId)
+ .getAttribute(IImportService.IMPORT_FILE);
+ List results = importService.parseSpreadsheet(file, sessionId);
+ SessionManager.getSession(sessionId).setAttribute(IImportService.IMPORT_RESULTS, results);
+ } catch (Exception e) {
+ }
+ }
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginMaintainAction.java
===================================================================
diff -u -r9cce145a8f0bd7a8148ebaac0c73ce5ad69da1cc -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginMaintainAction.java (.../LoginMaintainAction.java) (revision 9cce145a8f0bd7a8148ebaac0c73ce5ad69da1cc)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginMaintainAction.java (.../LoginMaintainAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -44,52 +44,52 @@
*
* View Source
*
- *
+ *
* @author Fei Yang
*/
/**
* struts doclets
- *
+ *
* @struts:action path="/loginmaintain" name = "LoginMaintainForm" scope =
* "request" validate="false"
- *
+ *
* @struts:action-forward name="loginmaintain" path=".loginmaintain"
- *
+ *
*/
public class LoginMaintainAction extends Action {
- private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar
- + "lams-www.war" + File.separatorChar + "news.html";
+ private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar + "lams-www.war" + File.separatorChar
+ + "news.html";
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
- DynaActionForm loginMaintainForm = (DynaActionForm) form;
- loginMaintainForm.set("news", loadNews());
- return mapping.findForward("loginmaintain");
- }
+ DynaActionForm loginMaintainForm = (DynaActionForm) form;
+ loginMaintainForm.set("news", loadNews());
+ return mapping.findForward("loginmaintain");
+ }
- private String loadNews() throws IOException {
- BufferedReader bReader = null;
- try {
- InputStreamReader ir = new InputStreamReader(new FileInputStream(
- Configuration.get(ConfigurationKeys.LAMS_EAR_DIR)+NEWS_PAGE_PATH_SUFFIX),
- Charset.forName("UTF-8"));
- bReader = new BufferedReader(ir);
- StringBuilder news = new StringBuilder();
- String line = bReader.readLine();
- while (line != null) {
- news.append(line).append('\n');
- line = bReader.readLine();
- }
- return news.toString();
- } finally {
- if (bReader != null) {
- bReader.close();
- }
- }
+ private String loadNews() throws IOException {
+ BufferedReader bReader = null;
+ try {
+ InputStreamReader ir = new InputStreamReader(
+ new FileInputStream(Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + NEWS_PAGE_PATH_SUFFIX),
+ Charset.forName("UTF-8"));
+ bReader = new BufferedReader(ir);
+ StringBuilder news = new StringBuilder();
+ String line = bReader.readLine();
+ while (line != null) {
+ news.append(line).append('\n');
+ line = bReader.readLine();
+ }
+ return news.toString();
+ } finally {
+ if (bReader != null) {
+ bReader.close();
+ }
}
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java
===================================================================
diff -u -rb2e058b1b893e12c1e679d2fe5e1a0462d7b6ec7 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java (.../LoginSaveAction.java) (revision b2e058b1b893e12c1e679d2fe5e1a0462d7b6ec7)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java (.../LoginSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,38 +2,33 @@
* 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
+ * 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;
-import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
-import java.util.Random;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -53,104 +48,102 @@
*
* View Source
*
- *
+ *
* Use DispatchAction for future extension convenience, e.g. add preview feature
- *
+ *
* @author Fei Yang
*/
/**
* struts doclet
- *
+ *
* @struts.action path = "/loginsave" name = "LoginMaintainForm" parameter =
* "method" scope = "request" input = ".loginmaintian" validate =
* "false"
- *
+ *
* @struts.action-forward name="sysadmin" path="/sysadminstart.do"
* @struts.action-forward name="loginmaintain" path=".loginmaintain"
*/
public class LoginSaveAction extends LamsDispatchAction {
- private static final String IMAGE_FOLDER_SUFFIX = File.separatorChar
- + "lams-www.war" + File.separatorChar + "images";
+ private static final String IMAGE_FOLDER_SUFFIX = File.separatorChar + "lams-www.war" + File.separatorChar
+ + "images";
- private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar
- + "lams-www.war" + File.separatorChar + "news.html";
-
- private static final String LOGO_FILENAME = "lams_login.gif";
+ private static final String NEWS_PAGE_PATH_SUFFIX = File.separatorChar + "lams-www.war" + File.separatorChar
+ + "news.html";
- public ActionForward save(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
+ private static final String LOGO_FILENAME = "lams_login.gif";
- if (isCancelled(request)) {
- return mapping.findForward("sysadmin");
- }
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
- DynaActionForm loginMaintainForm = (DynaActionForm) form;
- ActionMessages errors = new ActionMessages();
- FormFile file = (FormFile) loginMaintainForm.get("logo");
- if ((file != null) && (file.getFileSize() != 0)) {
- checkFile(errors, file);
- }
- if (errors.isEmpty()) {
- if ((file != null) && (file.getFileSize() != 0)) {
- updateImageFile(file, LOGO_FILENAME);
-
- }
- updateNewsPage(loginMaintainForm.getString("news"));
- } else {
- saveErrors(request, errors);
- return mapping.findForward("loginmaintain");
- }
- return mapping.findForward("sysadmin");
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
}
- private void updateNewsPage(String news) throws IOException {
- BufferedWriter bWriter = null;
- try {
- OutputStreamWriter ow = new OutputStreamWriter(new FileOutputStream(
- Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + NEWS_PAGE_PATH_SUFFIX),
- Charset.forName("UTF-8"));
- bWriter = new BufferedWriter(ow);
- bWriter.write(news);
- bWriter.flush();
- } finally {
- if (bWriter != null)
- bWriter.close();
- }
+ DynaActionForm loginMaintainForm = (DynaActionForm) form;
+ ActionMessages errors = new ActionMessages();
+ FormFile file = (FormFile) loginMaintainForm.get("logo");
+ if ((file != null) && (file.getFileSize() != 0)) {
+ checkFile(errors, file);
}
+ if (errors.isEmpty()) {
+ if ((file != null) && (file.getFileSize() != 0)) {
+ updateImageFile(file, LOGO_FILENAME);
+ }
+ updateNewsPage(loginMaintainForm.getString("news"));
+ } else {
+ saveErrors(request, errors);
+ return mapping.findForward("loginmaintain");
+ }
+ return mapping.findForward("sysadmin");
+ }
- private void updateImageFile(FormFile file, String fileName)
- throws IOException {
- File imagesFolder = new File(
- Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + IMAGE_FOLDER_SUFFIX);
- if (!imagesFolder.exists()) {
- imagesFolder.mkdir();
- }
- String imageFilePath = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR)
- + IMAGE_FOLDER_SUFFIX + File.separatorChar + fileName;
- FileOutputStream out = null;
- try {
- out = new FileOutputStream(imageFilePath);
- out.write(file.getFileData());
- out.flush();
- } finally {
- if (out != null)
- out.close();
- }
+ private void updateNewsPage(String news) throws IOException {
+ BufferedWriter bWriter = null;
+ try {
+ OutputStreamWriter ow = new OutputStreamWriter(
+ new FileOutputStream(Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + NEWS_PAGE_PATH_SUFFIX),
+ Charset.forName("UTF-8"));
+ bWriter = new BufferedWriter(ow);
+ bWriter.write(news);
+ bWriter.flush();
+ } finally {
+ if (bWriter != null) {
+ bWriter.close();
+ }
+ }
+ }
+ private void updateImageFile(FormFile file, String fileName) throws IOException {
+ File imagesFolder = new File(Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + IMAGE_FOLDER_SUFFIX);
+ if (!imagesFolder.exists()) {
+ imagesFolder.mkdir();
}
+ String imageFilePath = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + IMAGE_FOLDER_SUFFIX
+ + File.separatorChar + fileName;
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(imageFilePath);
+ out.write(file.getFileData());
+ out.flush();
+ } finally {
+ if (out != null) {
+ out.close();
+ }
+ }
- private void checkFile(ActionMessages errors, FormFile file) {
- boolean imgFormat = file.getContentType().contains("image");
- if (!imgFormat) {
- errors.add("format", new ActionMessage("error.img.format"));
- }
- if (file.getFileSize() > 4096 * 1024) {
- errors.add("size", new ActionMessage("error.img.size"));
- }
+ }
+
+ private void checkFile(ActionMessages errors, FormFile file) {
+ boolean imgFormat = file.getContentType().contains("image");
+ if (!imgFormat) {
+ errors.add("format", new ActionMessage("error.img.format"));
}
+ if (file.getFileSize() > 4096 * 1024) {
+ errors.add("size", new ActionMessage("error.img.size"));
+ }
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigAction.java
===================================================================
diff -u -rab19db088359a46353cc92e806c40ff5cff818b9 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigAction.java (.../OpenIDConfigAction.java) (revision ab19db088359a46353cc92e806c40ff5cff818b9)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigAction.java (.../OpenIDConfigAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -35,78 +35,81 @@
/**
* openIDConfig
- *
+ *
* @author lfoxton
- *
+ *
* @struts.action path="/openIDConfig" parameter="method" name="openIDForm" scope="request" validate="false"
* @struts.action-forward name="config" path="/openidConfig.jsp"
* @struts.action-forward name="sysadmin" path="/sysadminstart.do"
*/
public class OpenIDConfigAction extends LamsDispatchAction {
-
- IUserManagementService userService;
- public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
+ IUserManagementService userService;
- setService();
- OpenIDConfigForm configForm = (OpenIDConfigForm) form;
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
- OpenIDConfig openIDEnabled = (OpenIDConfig)userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
- OpenIDConfig portalURL = (OpenIDConfig)userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_PORTAL_URL);
- OpenIDConfig trustedIDPs = (OpenIDConfig)userService.findById(OpenIDConfig.class,OpenIDConfig.KEY_TRUSTED_IDPS);
+ setService();
+ OpenIDConfigForm configForm = (OpenIDConfigForm) form;
- if (openIDEnabled != null) {
- configForm.setOpenIDEnabled(Boolean.parseBoolean(openIDEnabled.getConfigValue()));
- } else {
- configForm.setOpenIDEnabled(Boolean.FALSE);
- }
+ OpenIDConfig openIDEnabled = (OpenIDConfig) userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
+ OpenIDConfig portalURL = (OpenIDConfig) userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_PORTAL_URL);
+ OpenIDConfig trustedIDPs = (OpenIDConfig) userService.findById(OpenIDConfig.class,
+ OpenIDConfig.KEY_TRUSTED_IDPS);
- if (portalURL != null) {
- configForm.setPortalURL(portalURL.getConfigValue());
- }
+ if (openIDEnabled != null) {
+ configForm.setOpenIDEnabled(Boolean.parseBoolean(openIDEnabled.getConfigValue()));
+ } else {
+ configForm.setOpenIDEnabled(Boolean.FALSE);
+ }
- if (trustedIDPs != null) {
- configForm.setTrustedIDPs(trustedIDPs.getConfigValue());
- }
+ if (portalURL != null) {
+ configForm.setPortalURL(portalURL.getConfigValue());
+ }
- return mapping.findForward("config");
+ if (trustedIDPs != null) {
+ configForm.setTrustedIDPs(trustedIDPs.getConfigValue());
}
- public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- setService();
- OpenIDConfigForm configForm = (OpenIDConfigForm) form;
-
- OpenIDConfig openIDEnabled = (OpenIDConfig)userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
- OpenIDConfig portalURL = (OpenIDConfig)userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_PORTAL_URL);
- OpenIDConfig trustedIDPs = (OpenIDConfig)userService.findById(OpenIDConfig.class,OpenIDConfig.KEY_TRUSTED_IDPS);
+ return mapping.findForward("config");
+ }
- if (openIDEnabled != null) {
- openIDEnabled.setConfigValue(configForm.getOpenIDEnabled().toString());
- }
-
- if (portalURL != null) {
- portalURL.setConfigValue(configForm.getPortalURL());
- }
-
- if (trustedIDPs != null) {
- trustedIDPs.setConfigValue(configForm.getTrustedIDPs());
- }
-
- userService.save(openIDEnabled);
- userService.save(portalURL);
- userService.save(trustedIDPs);
-
- request.setAttribute("success", true);
-
- return mapping.findForward("config");
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ setService();
+ OpenIDConfigForm configForm = (OpenIDConfigForm) form;
+
+ OpenIDConfig openIDEnabled = (OpenIDConfig) userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
+ OpenIDConfig portalURL = (OpenIDConfig) userService.findById(OpenIDConfig.class, OpenIDConfig.KEY_PORTAL_URL);
+ OpenIDConfig trustedIDPs = (OpenIDConfig) userService.findById(OpenIDConfig.class,
+ OpenIDConfig.KEY_TRUSTED_IDPS);
+
+ if (openIDEnabled != null) {
+ openIDEnabled.setConfigValue(configForm.getOpenIDEnabled().toString());
}
- private void setService() {
- if (userService == null) {
- userService = AdminServiceProxy.getService(getServlet().getServletContext());
- }
+ if (portalURL != null) {
+ portalURL.setConfigValue(configForm.getPortalURL());
}
+ if (trustedIDPs != null) {
+ trustedIDPs.setConfigValue(configForm.getTrustedIDPs());
+ }
+
+ userService.save(openIDEnabled);
+ userService.save(portalURL);
+ userService.save(trustedIDPs);
+
+ request.setAttribute("success", true);
+
+ return mapping.findForward("config");
+ }
+
+ private void setService() {
+ if (userService == null) {
+ userService = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigForm.java
===================================================================
diff -u -rab19db088359a46353cc92e806c40ff5cff818b9 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigForm.java (.../OpenIDConfigForm.java) (revision ab19db088359a46353cc92e806c40ff5cff818b9)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OpenIDConfigForm.java (.../OpenIDConfigForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -3,41 +3,42 @@
import org.apache.struts.action.ActionForm;
/**
- *
+ *
* @author lfoxton
* @struts.form name="openIDForm"
*/
public class OpenIDConfigForm extends ActionForm {
- private static final long serialVersionUID = 1453453453463790L;
-
- private Boolean openIDEnabled;
- private String portalURL;
- private String trustedIDPs;
-
- public OpenIDConfigForm() {}
+ private static final long serialVersionUID = 1453453453463790L;
- public Boolean getOpenIDEnabled() {
- return openIDEnabled;
- }
+ private Boolean openIDEnabled;
+ private String portalURL;
+ private String trustedIDPs;
- public void setOpenIDEnabled(Boolean openIDEnabled) {
- this.openIDEnabled = openIDEnabled;
- }
+ public OpenIDConfigForm() {
+ }
- public String getPortalURL() {
- return portalURL;
- }
+ public Boolean getOpenIDEnabled() {
+ return openIDEnabled;
+ }
- public void setPortalURL(String portalURL) {
- this.portalURL = portalURL;
- }
+ public void setOpenIDEnabled(Boolean openIDEnabled) {
+ this.openIDEnabled = openIDEnabled;
+ }
- public String getTrustedIDPs() {
- return trustedIDPs;
- }
+ public String getPortalURL() {
+ return portalURL;
+ }
- public void setTrustedIDPs(String trustedIDPs) {
- this.trustedIDPs = trustedIDPs;
- }
+ public void setPortalURL(String portalURL) {
+ this.portalURL = portalURL;
+ }
+
+ public String getTrustedIDPs() {
+ return trustedIDPs;
+ }
+
+ public void setTrustedIDPs(String trustedIDPs) {
+ this.trustedIDPs = trustedIDPs;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java
===================================================================
diff -u -rfe5f10765722a7f00b9d5673aef3c48b264384fd -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java (.../OrgManageAction.java) (revision fe5f10765722a7f00b9d5673aef3c48b264384fd)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java (.../OrgManageAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -61,21 +61,22 @@
*
*
* @author Fei Yang
- *
- * @struts:action path="/orgmanage" parameter="dispatch" name="OrgManageForm" input=".orglist" scope="request" validate="false"
*
+ * @struts:action path="/orgmanage" parameter="dispatch" name="OrgManageForm" input=".orglist" scope="request"
+ * validate="false"
+ *
* @struts:action-forward name="orglist" path=".orglist"
*/
public class OrgManageAction extends LamsDispatchAction {
-
+
private static IUserManagementService userManagementService;
@SuppressWarnings("unchecked")
@Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
initServices();
-
+
// Get organisation whose child organisations we will populate the OrgManageForm with
Integer orgId = WebUtil.readIntParam(request, "org", true);
if (orgId == null) {
@@ -156,14 +157,14 @@
request.setAttribute("manageGlobalRoles", request.isUserInRole(Role.SYSADMIN));
return mapping.findForward("orglist");
}
-
+
/**
* Returns list of organisations for .
*/
public ActionForward getOrgs(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse res) throws IOException, ServletException, JSONException {
initServices();
-
+
Integer parentOrgId = WebUtil.readIntParam(request, "parentOrgId");
Integer stateId = WebUtil.readIntParam(request, "stateId");
Integer typeIdParam = WebUtil.readIntParam(request, "type");
@@ -193,7 +194,7 @@
} else if (isSort3 != null) {
sortBy = "code";
sortOrder = isSort3.equals(0) ? "ASC" : "DESC";
-
+
} else if (isSort4 != null) {
sortBy = "description";
sortOrder = isSort4.equals(0) ? "ASC" : "DESC";
@@ -212,11 +213,11 @@
JSONObject responseRow = new JSONObject();
responseRow.put("id", organisation.getOrganisationId());
- String orgName = organisation.getName() == null ? "" : organisation.getName();
+ String orgName = organisation.getName() == null ? "" : organisation.getName();
responseRow.put("name", StringEscapeUtils.escapeHtml(orgName));
- String orgCode = organisation.getCode() == null ? "" : organisation.getCode();
+ String orgCode = organisation.getCode() == null ? "" : organisation.getCode();
responseRow.put("code", StringEscapeUtils.escapeHtml(orgCode));
- String orgDescription = organisation.getDescription() == null ? "" : organisation.getDescription();
+ String orgDescription = organisation.getDescription() == null ? "" : organisation.getDescription();
responseRow.put("description", StringEscapeUtils.escapeHtml(orgDescription));
rows.put(responseRow);
@@ -226,11 +227,11 @@
res.getWriter().print(new String(responcedata.toString()));
return null;
}
-
+
private void initServices() {
if (userManagementService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager
- .getInstance().getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getWebApplicationContext(HttpSessionManager.getInstance().getServletContext());
userManagementService = (UserManagementService) ctx.getBean("userManagementService");
}
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageBean.java
===================================================================
diff -u -ra961e120b9299bd497d18a4a9ee9163882c0a217 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageBean.java (.../OrgManageBean.java) (revision a961e120b9299bd497d18a4a9ee9163882c0a217)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageBean.java (.../OrgManageBean.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,113 +2,129 @@
* 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
+ * 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;
import java.util.Date;
-import org.lamsfoundation.lams.usermanagement.Organisation;
import org.lamsfoundation.lams.usermanagement.SupportedLocale;
/**
* @version
*
- *
- * View Source
- *
+ *
+ * View Source
+ *
*
* @author Fei Yang
*
- * Created at 22:55:01 on 2006-6-6
+ * Created at 22:55:01 on 2006-6-6
*/
public class OrgManageBean implements Comparable {
- /**
- * OrgManageBean Constructor
- *
- * @param
- */
- public OrgManageBean() {
- super();
+ /**
+ * OrgManageBean Constructor
+ *
+ * @param
+ */
+ public OrgManageBean() {
+ super();
- }
+ }
+
private Integer organisationId;
private String name;
private String code;
private String description;
private Date createDate;
private boolean editable;
private String status;
- private SupportedLocale locale;
-
- public String getCode() {
- return code;
- }
- public void setCode(String code) {
- this.code = code;
- }
- public Date getCreateDate() {
- return createDate;
- }
- public void setCreateDate(Date createDate) {
- this.createDate = createDate;
- }
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public SupportedLocale getLocale() {
- return locale;
- }
- public void setLocale(SupportedLocale locale) {
- this.locale = locale;
- }
+ private SupportedLocale locale;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Integer getOrganisationId() {
- return organisationId;
- }
- public void setOrganisationId(Integer organisationId) {
- this.organisationId = organisationId;
- }
- public String getStatus() {
- return status;
- }
- public void setStatus(String status) {
- this.status = status;
- }
- public boolean isEditable() {
- return editable;
- }
- public void setEditable(boolean editable) {
- this.editable = editable;
- }
- public int compareTo(Object o) {
- return name.compareToIgnoreCase(((OrgManageBean)o).getName());
- }
+ public String getCode() {
+ return code;
+ }
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ public Date getCreateDate() {
+ return createDate;
+ }
+
+ public void setCreateDate(Date createDate) {
+ this.createDate = createDate;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public SupportedLocale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(SupportedLocale locale) {
+ this.locale = locale;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getOrganisationId() {
+ return organisationId;
+ }
+
+ public void setOrganisationId(Integer organisationId) {
+ this.organisationId = organisationId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public boolean isEditable() {
+ return editable;
+ }
+
+ public void setEditable(boolean editable) {
+ this.editable = editable;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return name.compareToIgnoreCase(((OrgManageBean) o).getName());
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgSaveAction.java
===================================================================
diff -u -r0d275bf753620ae71aeb4e7589c540c9777532cb -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgSaveAction.java (.../OrgSaveAction.java) (revision 0d275bf753620ae71aeb4e7589c540c9777532cb)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgSaveAction.java (.../OrgSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,29 +2,27 @@
* 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
+ * 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;
import java.util.Date;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -70,184 +68,198 @@
/**
* struts doclets
- *
+ *
* @struts:action path="/orgsave"
* name="OrganisationForm"
* input=".organisation"
* scope="request"
* validate="false"
*
- * @struts:action-forward name="organisation" path="/organisation.do?method=edit"
+ * @struts:action-forward name="organisation" path="/organisation.do?method=edit"
* @struts:action-forward name="orglist" path="/orgmanage.do"
* @struts:action-forward name="userlist" path="/usermanage.do"
*/
public class OrgSaveAction extends Action {
-
- private static Logger log = Logger.getLogger(OrgSaveAction.class);
- private static IUserManagementService service;
- private MessageService messageService;
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
-
- if(service==null) service = AdminServiceProxy.getService(getServlet().getServletContext());
- if(messageService==null) messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
- DynaActionForm orgForm = (DynaActionForm)form;
- Integer orgId = (Integer)orgForm.get("orgId");
- Organisation org;
-
- if(isCancelled(request)){
- if(orgId!=0) {
- request.setAttribute("org",orgId);
- org = (Organisation)service.findById(Organisation.class,orgId);
- if(org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE))
- return mapping.findForward("userlist");
- } else {
- request.setAttribute("org",orgForm.get("parentId"));
- }
- return mapping.findForward("orglist");
- }
-
- ActionMessages errors = new ActionMessages();
-
- //organisation name validation
- String orgName = (orgForm.get("name") == null) ? null : (String) orgForm.get("name");
- if (StringUtils.isBlank(orgName)) {
- errors.add("name",new ActionMessage("error.name.required"));
- } else if (!ValidationUtil.isOrgNameValid(orgName)) {
- errors.add("name", new ActionMessage("error.name.invalid.characters"));
- }
+ private static Logger log = Logger.getLogger(OrgSaveAction.class);
+ private static IUserManagementService service;
+ private MessageService messageService;
- if(errors.isEmpty()){
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- SupportedLocale locale = (SupportedLocale)service.findById(SupportedLocale.class,(Integer)orgForm.get("localeId"));
- OrganisationState state = (OrganisationState)service.findById(OrganisationState.class,(Integer)orgForm.get("stateId"));
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
- if(orgId!=0){
- if(service.canEditGroup(user.getUserID(), orgId)) {
- org = (Organisation)service.findById(Organisation.class,orgId);
- // set archived date only when it first changes to become archived
- if (state.getOrganisationStateId().equals(OrganisationState.ARCHIVED)
- && !org.getOrganisationState().getOrganisationStateId().equals(OrganisationState.ARCHIVED)) {
- org.setArchivedDate(new Date());
- }
- writeAuditLog(org, orgForm, state, locale);
- BeanUtils.copyProperties(org,orgForm);
- } else {
- request.setAttribute("errorName", "UserAction");
- request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
- return mapping.findForward("error");
- }
- }else{
- org = new Organisation();
- BeanUtils.copyProperties(org,orgForm);
- org.setParentOrganisation((Organisation)service.findById(Organisation.class,(Integer)orgForm.get("parentId")));
- org.setOrganisationType((OrganisationType)service.findById(OrganisationType.class,(Integer)orgForm.get("typeId")));
- writeAuditLog(org, orgForm, org.getOrganisationState(), org.getLocale());
- }
- org.setLocale(locale);
- org.setOrganisationState(state);
- if (log.isDebugEnabled()) {
- log.debug("orgId: "+org.getOrganisationId()+" create date: "+org.getCreateDate());
- }
- org = service.saveOrganisation(org, user.getUserID());
-
- request.setAttribute("org",orgForm.get("parentId"));
- return mapping.findForward("orglist");
- }else{
- saveErrors(request,errors);
- return mapping.findForward("organisation");
+ if (service == null) {
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ }
+ if (messageService == null) {
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ }
+ DynaActionForm orgForm = (DynaActionForm) form;
+ Integer orgId = (Integer) orgForm.get("orgId");
+ Organisation org;
+
+ if (isCancelled(request)) {
+ if (orgId != 0) {
+ request.setAttribute("org", orgId);
+ org = (Organisation) service.findById(Organisation.class, orgId);
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ return mapping.findForward("userlist");
}
+ } else {
+ request.setAttribute("org", orgForm.get("parentId"));
+ }
+ return mapping.findForward("orglist");
}
-
- private void writeAuditLog(Organisation org, DynaActionForm orgForm, OrganisationState newState, SupportedLocale newLocale) {
-
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
- IAuditService auditService = (IAuditService) ctx.getBean("auditService");
- MessageService messageService = (MessageService)ctx.getBean("adminMessageService");
-
- String message;
-
- // audit log entries for organisation attribute changes
- if((Integer)orgForm.get("orgId")!=0) {
- final String key = "audit.organisation.change";
- String[] args = new String[4];
- args[1] = org.getName()+"("+org.getOrganisationId()+")";
- if(!org.getOrganisationState().getOrganisationStateId().equals((Integer)orgForm.get("stateId"))) {
- args[0] = "state";
- args[2] = org.getOrganisationState().getDescription();
- args[3] = newState.getDescription();
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!StringUtils.equals(org.getName(),(String)orgForm.get("name"))) {
- args[0] = "name";
- args[2] = org.getName();
- args[3] = (String)orgForm.get("name");
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!StringUtils.equals(org.getCode(),(String)orgForm.get("code"))) {
- args[0] = "code";
- args[2] = org.getCode();
- args[3] = (String)orgForm.get("code");
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!StringUtils.equals(org.getDescription(),(String)orgForm.getString("description"))) {
- args[0] = "description";
- args[2] = org.getDescription();
- args[3] = (String)orgForm.get("description");
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!org.getCourseAdminCanAddNewUsers().equals((Boolean)orgForm.get("courseAdminCanAddNewUsers"))) {
- args[0] = "courseAdminCanAddNewUsers";
- args[2] = org.getCourseAdminCanAddNewUsers() ? "true" : "false";
- args[3] = (Boolean)orgForm.get("courseAdminCanAddNewUsers") ? "true" : "false";
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!org.getCourseAdminCanBrowseAllUsers().equals((Boolean)orgForm.get("courseAdminCanBrowseAllUsers"))) {
- args[0] = "courseAdminCanBrowseAllUsers";
- args[2] = org.getCourseAdminCanBrowseAllUsers() ? "true" : "false";
- args[3] = (Boolean)orgForm.get("courseAdminCanBrowseAllUsers") ? "true" : "false";
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- if(!org.getCourseAdminCanChangeStatusOfCourse().equals((Boolean)orgForm.get("courseAdminCanChangeStatusOfCourse"))) {
- args[0] = "courseAdminCanChangeStatusOfCourse";
- args[2] = org.getCourseAdminCanChangeStatusOfCourse() ? "true" : "false";
- args[3] = (Boolean)orgForm.get("courseAdminCanChangeStatusOfCourse") ? "true" : "false";
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
- /* this field not set yet
- if(!org.getCourseAdminCanCreateGuestAccounts().equals((Boolean)orgForm.get("courseAdminCanCreateGuestAccounts"))) {
- args[0] = "courseAdminCanCreateGuestAccounts";
- args[2] = org.getCourseAdminCanCreateGuestAccounts() ? "true" : "false";
- args[3] = (Boolean)orgForm.get("courseAdminCanCreateGuestAccounts") ? "true" : "false";
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }*/
- if(!org.getLocale().getLocaleId().equals((Integer)orgForm.get("localeId"))) {
- args[0] = "locale";
- args[2] = org.getLocale().getDescription();
- args[3] = newLocale.getDescription();
- message = messageService.getMessage(key, args);
- auditService.log(AdminConstants.MODULE_NAME, message);
- }
+
+ ActionMessages errors = new ActionMessages();
+
+ //organisation name validation
+ String orgName = (orgForm.get("name") == null) ? null : (String) orgForm.get("name");
+ if (StringUtils.isBlank(orgName)) {
+ errors.add("name", new ActionMessage("error.name.required"));
+ } else if (!ValidationUtil.isOrgNameValid(orgName)) {
+ errors.add("name", new ActionMessage("error.name.invalid.characters"));
+ }
+
+ if (errors.isEmpty()) {
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ SupportedLocale locale = (SupportedLocale) service.findById(SupportedLocale.class,
+ (Integer) orgForm.get("localeId"));
+ OrganisationState state = (OrganisationState) service.findById(OrganisationState.class,
+ (Integer) orgForm.get("stateId"));
+
+ if (orgId != 0) {
+ if (service.canEditGroup(user.getUserID(), orgId)) {
+ org = (Organisation) service.findById(Organisation.class, orgId);
+ // set archived date only when it first changes to become archived
+ if (state.getOrganisationStateId().equals(OrganisationState.ARCHIVED) && !org.getOrganisationState()
+ .getOrganisationStateId().equals(OrganisationState.ARCHIVED)) {
+ org.setArchivedDate(new Date());
+ }
+ writeAuditLog(org, orgForm, state, locale);
+ BeanUtils.copyProperties(org, orgForm);
} else {
- String[] args = new String[2];
- args[0] = org.getName()+"("+org.getOrganisationId()+")";
- args[1] = org.getOrganisationType().getName();
- message = messageService.getMessage("audit.organisation.create", args);
- auditService.log(AdminConstants.MODULE_NAME, message);
+ request.setAttribute("errorName", "UserAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
}
+ } else {
+ org = new Organisation();
+ BeanUtils.copyProperties(org, orgForm);
+ org.setParentOrganisation(
+ (Organisation) service.findById(Organisation.class, (Integer) orgForm.get("parentId")));
+ org.setOrganisationType(
+ (OrganisationType) service.findById(OrganisationType.class, (Integer) orgForm.get("typeId")));
+ writeAuditLog(org, orgForm, org.getOrganisationState(), org.getLocale());
+ }
+ org.setLocale(locale);
+ org.setOrganisationState(state);
+ if (log.isDebugEnabled()) {
+ log.debug("orgId: " + org.getOrganisationId() + " create date: " + org.getCreateDate());
+ }
+ org = service.saveOrganisation(org, user.getUserID());
+
+ request.setAttribute("org", orgForm.get("parentId"));
+ return mapping.findForward("orglist");
+ } else {
+ saveErrors(request, errors);
+ return mapping.findForward("organisation");
}
+ }
+ private void writeAuditLog(Organisation org, DynaActionForm orgForm, OrganisationState newState,
+ SupportedLocale newLocale) {
+
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
+ IAuditService auditService = (IAuditService) ctx.getBean("auditService");
+ MessageService messageService = (MessageService) ctx.getBean("adminMessageService");
+
+ String message;
+
+ // audit log entries for organisation attribute changes
+ if ((Integer) orgForm.get("orgId") != 0) {
+ final String key = "audit.organisation.change";
+ String[] args = new String[4];
+ args[1] = org.getName() + "(" + org.getOrganisationId() + ")";
+ if (!org.getOrganisationState().getOrganisationStateId().equals(orgForm.get("stateId"))) {
+ args[0] = "state";
+ args[2] = org.getOrganisationState().getDescription();
+ args[3] = newState.getDescription();
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!StringUtils.equals(org.getName(), (String) orgForm.get("name"))) {
+ args[0] = "name";
+ args[2] = org.getName();
+ args[3] = (String) orgForm.get("name");
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!StringUtils.equals(org.getCode(), (String) orgForm.get("code"))) {
+ args[0] = "code";
+ args[2] = org.getCode();
+ args[3] = (String) orgForm.get("code");
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!StringUtils.equals(org.getDescription(), orgForm.getString("description"))) {
+ args[0] = "description";
+ args[2] = org.getDescription();
+ args[3] = (String) orgForm.get("description");
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!org.getCourseAdminCanAddNewUsers().equals(orgForm.get("courseAdminCanAddNewUsers"))) {
+ args[0] = "courseAdminCanAddNewUsers";
+ args[2] = org.getCourseAdminCanAddNewUsers() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanAddNewUsers") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!org.getCourseAdminCanBrowseAllUsers().equals(orgForm.get("courseAdminCanBrowseAllUsers"))) {
+ args[0] = "courseAdminCanBrowseAllUsers";
+ args[2] = org.getCourseAdminCanBrowseAllUsers() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanBrowseAllUsers") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ if (!org.getCourseAdminCanChangeStatusOfCourse()
+ .equals(orgForm.get("courseAdminCanChangeStatusOfCourse"))) {
+ args[0] = "courseAdminCanChangeStatusOfCourse";
+ args[2] = org.getCourseAdminCanChangeStatusOfCourse() ? "true" : "false";
+ args[3] = (Boolean) orgForm.get("courseAdminCanChangeStatusOfCourse") ? "true" : "false";
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ /*
+ * this field not set yet
+ * if(!org.getCourseAdminCanCreateGuestAccounts().equals((Boolean)orgForm.get(
+ * "courseAdminCanCreateGuestAccounts"))) {
+ * args[0] = "courseAdminCanCreateGuestAccounts";
+ * args[2] = org.getCourseAdminCanCreateGuestAccounts() ? "true" : "false";
+ * args[3] = (Boolean)orgForm.get("courseAdminCanCreateGuestAccounts") ? "true" : "false";
+ * message = messageService.getMessage(key, args);
+ * auditService.log(AdminConstants.MODULE_NAME, message);
+ * }
+ */
+ if (!org.getLocale().getLocaleId().equals(orgForm.get("localeId"))) {
+ args[0] = "locale";
+ args[2] = org.getLocale().getDescription();
+ args[3] = newLocale.getDescription();
+ message = messageService.getMessage(key, args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ } else {
+ String[] args = new String[2];
+ args[0] = org.getName() + "(" + org.getOrganisationId() + ")";
+ args[1] = org.getOrganisationType().getName();
+ message = messageService.getMessage("audit.organisation.create", args);
+ auditService.log(AdminConstants.MODULE_NAME, message);
+ }
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrganisationAction.java
===================================================================
diff -u -r191931ec7faa9587dd30f97df56c5d86c093e0b2 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrganisationAction.java (.../OrganisationAction.java) (revision 191931ec7faa9587dd30f97df56c5d86c093e0b2)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrganisationAction.java (.../OrganisationAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -54,7 +54,7 @@
* @author Fei Yang
*
* @struts:action path="/organisation" name="OrganisationForm" scope="request" parameter="method" validate="false"
- *
+ *
* @struts:action-forward name="organisation" path=".organisation"
* @struts:action-forward name="organisationCourseAdmin" path=".organisationCourseAdmin"
* @struts:action-forward name="orglist" path="/orgmanage.do"
@@ -156,13 +156,16 @@
return mapping.findForward("error");
}
- /*public ActionForward remove(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){
- Integer orgId = WebUtil.readIntParam(request,"orgId");
- getService().deleteById(Organisation.class,orgId);
- Integer parentId = WebUtil.readIntParam(request,"parentId");
- request.setAttribute("org",parentId);
- return mapping.findForward("orglist");
- }*/
+ /*
+ * public ActionForward remove(ActionMapping mapping, ActionForm form,HttpServletRequest request,
+ * HttpServletResponse response){
+ * Integer orgId = WebUtil.readIntParam(request,"orgId");
+ * getService().deleteById(Organisation.class,orgId);
+ * Integer parentId = WebUtil.readIntParam(request,"parentId");
+ * request.setAttribute("org",parentId);
+ * return mapping.findForward("orglist");
+ * }
+ */
@SuppressWarnings("unchecked")
private void initLocalesAndStatus() {
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java
===================================================================
diff -u -r5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision 5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -35,6 +35,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
@@ -56,17 +57,15 @@
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
-import org.apache.commons.codec.binary.Base64;
-
/**
* ConfigAction
- *
+ *
* @author Mitchell Seaton, edited by Luke Foxton
*/
/**
* struts doclets
- *
+ *
* @struts.action path="/register" parameter="method" name="RegisterForm"
* input=".register" scope="request" validate="false"
* @struts.action-forward name="register" path=".register"
@@ -84,6 +83,7 @@
private static IUserManagementService userManagementService;
private Configuration configurationService;
+ @Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
@@ -101,21 +101,20 @@
configurationService = getConfiguration();
- Registration reg = configurationService.getRegistration();
+ Registration reg = Configuration.getRegistration();
if (reg == null) {
reg = new Registration();
reg.setPublicDirectory(true);
}
updateForm(registerForm, reg);
-
RegisterDTO registerDTO = new RegisterDTO();
- // Get Server statistics for registration
+ // Get Server statistics for registration
List groups = userManagementService.findByProperty(Organisation.class, "organisationType.organisationTypeId",
OrganisationType.COURSE_TYPE);
- List subgroups = userManagementService.findByProperty(Organisation.class,
- "organisationType.organisationTypeId", OrganisationType.CLASS_TYPE);
+ List subgroups = userManagementService.findByProperty(Organisation.class, "organisationType.organisationTypeId",
+ OrganisationType.CLASS_TYPE);
registerDTO.setGroupNumber(Integer.valueOf(groups.size()));
registerDTO.setSubgroupNumber(Integer.valueOf(subgroups.size()));
@@ -131,7 +130,7 @@
registerDTO.setServerBuild(Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER));
registerDTO.setServerLocale(Configuration.get(ConfigurationKeys.SERVER_LANGUAGE));
registerDTO.setServerLanguageDate(Configuration.get(ConfigurationKeys.DICTIONARY_DATE_CREATED));
-
+
request.setAttribute("registerDTO", registerDTO);
return mapping.findForward("register");
@@ -157,7 +156,7 @@
registerForm.setSiteName(reg.getSiteName());
registerForm.setOrganisation(reg.getOrganisation());
registerForm.setServerCountry(reg.getServerCountry());
-
+
registerForm.setPublicDirectory(reg.isPublicDirectory());
registerForm.setEnableLamsCommunityIntegration(reg.isEnableLamsCommunityIntegration());
}
@@ -180,15 +179,15 @@
// get the default registration if there is any
configurationService = getConfiguration();
- Registration reg = configurationService.getRegistration();
+ Registration reg = Configuration.getRegistration();
if (reg == null) {
reg = new Registration();
}
updateRegistration(registerForm, reg);
-
+
if (reg.getServerKey() == null) {
-
+
String url = LAMS_COMMUNITY_REGISTER_URL;
HashMap params = new HashMap();
@@ -198,18 +197,16 @@
params.put("remail", URLEncoder.encode(registerForm.getEmail(), "UTF8"));
params.put("servercountry", URLEncoder.encode(registerForm.getServerCountry(), "UTF8"));
params.put("public", "" + registerForm.isPublicDirectory());
-
-
-
+
params.put("serverurl", URLEncoder.encode(Configuration.get(ConfigurationKeys.SERVER_URL), "UTF8"));
params.put("serverversion", URLEncoder.encode(Configuration.get(ConfigurationKeys.VERSION), "UTF8"));
- params.put("serverbuild", URLEncoder.encode(Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER),
- "UTF8"));
+ params.put("serverbuild",
+ URLEncoder.encode(Configuration.get(ConfigurationKeys.SERVER_VERSION_NUMBER), "UTF8"));
params.put("serverlocale", URLEncoder.encode(Configuration.get(ConfigurationKeys.SERVER_LANGUAGE), "UTF8"));
- params.put("langdate", URLEncoder.encode(Configuration.get(ConfigurationKeys.DICTIONARY_DATE_CREATED),
- "UTF8"));
+ params.put("langdate",
+ URLEncoder.encode(Configuration.get(ConfigurationKeys.DICTIONARY_DATE_CREATED), "UTF8"));
- // Get Server statistics for registration
+ // Get Server statistics for registration
List groups = userManagementService.findByProperty(Organisation.class,
"organisationType.organisationTypeId", OrganisationType.COURSE_TYPE);
List subgroups = userManagementService.findByProperty(Organisation.class,
@@ -230,28 +227,22 @@
BufferedReader isReader = new BufferedReader(new InputStreamReader(is));
String str = isReader.readLine();
log.debug("Response from lamscommunity: " + str);
-
+
// get the serverId,serverKey pair result back from lamscommunity
- if (str!=null)
- {
+ if (str != null) {
String result[] = str.split(",");
-
- if (result.length == 2 && result[0].equals("success"))
- {
- String decrypted = decrypt(result[1], LAMS_COMMUNITY_KEY);
+
+ if (result.length == 2 && result[0].equals("success")) {
+ String decrypted = RegisterAction.decrypt(result[1], LAMS_COMMUNITY_KEY);
String decryptedResult[] = decrypted.split(",");
reg.setServerKey(decryptedResult[0]);
reg.setServerID(decryptedResult[1]);
- configurationService.saveOrUpdateRegistration(reg);
+ Configuration.saveOrUpdateRegistration(reg);
request.setAttribute("successKey", "register.success");
- }
- else
- {
+ } else {
request.setAttribute("errorKey", "register.error.registrationFailed");
}
- }
- else
- {
+ } else {
request.setAttribute("errorKey", "register.error.noResponseFromLamsCommunity");
}
}
@@ -261,29 +252,31 @@
private Configuration getConfiguration() {
if (configurationService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
- .getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
configurationService = (Configuration) ctx.getBean("configurationService");
}
return configurationService;
}
-
- public static String decrypt(String text, String password) throws Exception{
+
+ public static String decrypt(String text, String password) throws Exception {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
-
+
//setup key
- byte[] keyBytes= new byte[16];
- byte[] b= password.getBytes("UTF-8");
- int len= b.length;
- if (len > keyBytes.length) len = keyBytes.length;
+ byte[] keyBytes = new byte[16];
+ byte[] b = password.getBytes("UTF-8");
+ int len = b.length;
+ if (len > keyBytes.length) {
+ len = keyBytes.length;
+ }
System.arraycopy(b, 0, keyBytes, 0, len);
SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
IvParameterSpec ivSpec = new IvParameterSpec(keyBytes);
- cipher.init(Cipher.DECRYPT_MODE,keySpec,ivSpec);
-
- byte [] results = cipher.doFinal(Base64.decodeBase64(text.getBytes()));
- return new String(results,"UTF-8");
+ cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec);
+
+ byte[] results = cipher.doFinal(Base64.decodeBase64(text.getBytes()));
+ return new String(results, "UTF-8");
}
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterForm.java
===================================================================
diff -u -r3bc65f0652b50074ff432112d8e47a6df3728810 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterForm.java (.../RegisterForm.java) (revision 3bc65f0652b50074ff432112d8e47a6df3728810)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterForm.java (.../RegisterForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -28,9 +28,9 @@
/**
* Form for registering a LAMS instance in lamscommunity, also used to get the
* server key for lams community integrations
- *
+ *
* @author lfoxton
- *
+ *
*/
/**
@@ -68,70 +68,69 @@
}
public String getSiteName() {
- return siteName;
+ return siteName;
}
public void setSiteName(String siteName) {
- this.siteName = siteName;
+ this.siteName = siteName;
}
public String getOrganisation() {
- return organisation;
+ return organisation;
}
public void setOrganisation(String organisation) {
- this.organisation = organisation;
+ this.organisation = organisation;
}
public String getName() {
- return name;
+ return name;
}
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
public String getEmail() {
- return email;
+ return email;
}
public void setEmail(String email) {
- this.email = email;
+ this.email = email;
}
public String getServerCountry() {
- return serverCountry;
+ return serverCountry;
}
public void setServerCountry(String serverCountry) {
- this.serverCountry = serverCountry;
+ this.serverCountry = serverCountry;
}
public boolean isPublicDirectory() {
- return publicDirectory;
+ return publicDirectory;
}
public void setPublicDirectory(boolean publicDirectory) {
- this.publicDirectory = publicDirectory;
+ this.publicDirectory = publicDirectory;
}
public boolean isEnableLamsCommunityIntegration() {
- return enableLamsCommunityIntegration;
+ return enableLamsCommunityIntegration;
}
public void setEnableLamsCommunityIntegration(boolean enableLamsCommunityIntegration) {
- this.enableLamsCommunityIntegration = enableLamsCommunityIntegration;
+ this.enableLamsCommunityIntegration = enableLamsCommunityIntegration;
}
public String getMethod() {
- return method;
+ return method;
}
public void setMethod(String method) {
- this.method = method;
+ this.method = method;
}
-
// public int getGroupNumber() {
// return groupNumber;
// }
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobDTO.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobDTO.java (.../ScheduledJobDTO.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobDTO.java (.../ScheduledJobDTO.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,54 +2,61 @@
* 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
+ * 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
* ****************************************************************
*/
/* $$Id$$ */
package org.lamsfoundation.lams.admin.web;
import java.util.Date;
+
/**
* DTO class of quartz job object for displaying on screen.
+ *
* @author Steve.Ni
*/
public class ScheduledJobDTO {
- private String name;
- private Date startDate;
- private String description;
-
- public String getDescription() {
- return description;
- }
- public void setDescription(String description) {
- this.description = description;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public Date getStartDate() {
- return startDate;
- }
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
+ private String name;
+ private Date startDate;
+ private String description;
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobListAction.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobListAction.java (.../ScheduledJobListAction.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobListAction.java (.../ScheduledJobListAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -41,60 +41,68 @@
import org.quartz.Trigger;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
+
/**
- *
+ *
* @author Steve.Ni
* @version $Revision$
- *
+ *
* @struts:action path="/joblist"
- * validate="false"
- *
+ * validate="false"
+ *
* @struts:action-forward name="list" path=".joblist"
*/
-public class ScheduledJobListAction extends Action{
+public class ScheduledJobListAction extends Action {
- private static final Logger log = Logger.getLogger(ScheduledJobListAction.class);
- /**
- * Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and
- * description. The description will be in format "Lesson Name":"the lesson creator", or
+ private static final Logger log = Logger.getLogger(ScheduledJobListAction.class);
+
+ /**
+ * Get all waitting queue jobs scheduled in Quartz table and display job name, job start time and
+ * description. The description will be in format "Lesson Name":"the lesson creator", or
* "The gate name":"The relatived lesson name".
- *
- * @param mapping The ActionMapping used to select this instance
- * @param actionForm The optional ActionForm bean for this request (if any)
- * @param request The HTTP request we are processing
- * @param response The HTTP response we are creating
*
- * @exception IOException if an input/output error occurs
- * @exception ServletException if a servlet exception occurs
- *
+ * @param mapping
+ * The ActionMapping used to select this instance
+ * @param actionForm
+ * The optional ActionForm bean for this request (if any)
+ * @param request
+ * The HTTP request we are processing
+ * @param response
+ * The HTTP response we are creating
+ *
+ * @exception IOException
+ * if an input/output error occurs
+ * @exception ServletException
+ * if a servlet exception occurs
+ *
*/
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
-
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServlet().getServletContext());
- Scheduler scheduler = (Scheduler) ctx.getBean("scheduler");
- ArrayList jobList = new ArrayList();
- try {
- String[] jobNames = scheduler.getJobNames(Scheduler.DEFAULT_GROUP);
- for (String name : jobNames) {
- ScheduledJobDTO jobDto = new ScheduledJobDTO();
- JobDetail detail = scheduler.getJobDetail(name,Scheduler.DEFAULT_GROUP);
- jobDto.setName(name);
- jobDto.setDescription(detail.getDescription());
- Trigger[] triggers = scheduler.getTriggersOfJob(name,Scheduler.DEFAULT_GROUP);
- for (Trigger trigger : triggers) {
- jobDto.setStartDate(trigger.getStartTime());
- jobList.add(jobDto);
- }
- }
- } catch (SchedulerException e) {
- log.equals("Failed get job names:" + e.getMessage());
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getWebApplicationContext(this.getServlet().getServletContext());
+ Scheduler scheduler = (Scheduler) ctx.getBean("scheduler");
+ ArrayList jobList = new ArrayList();
+ try {
+ String[] jobNames = scheduler.getJobNames(Scheduler.DEFAULT_GROUP);
+ for (String name : jobNames) {
+ ScheduledJobDTO jobDto = new ScheduledJobDTO();
+ JobDetail detail = scheduler.getJobDetail(name, Scheduler.DEFAULT_GROUP);
+ jobDto.setName(name);
+ jobDto.setDescription(detail.getDescription());
+ Trigger[] triggers = scheduler.getTriggersOfJob(name, Scheduler.DEFAULT_GROUP);
+ for (Trigger trigger : triggers) {
+ jobDto.setStartDate(trigger.getStartTime());
+ jobList.add(jobDto);
}
-
- request.setAttribute("jobList",jobList);
- return mapping.findForward("list");
+ }
+ } catch (SchedulerException e) {
+ log.equals("Failed get job names:" + e.getMessage());
+ }
+
+ request.setAttribute("jobList", jobList);
+ return mapping.findForward("list");
}
-
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java
===================================================================
diff -u -r622101803252450b96cc9882a17ae20de4f6e431 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java (.../ServerListAction.java) (revision 622101803252450b96cc9882a17ae20de4f6e431)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java (.../ServerListAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -45,24 +45,22 @@
/**
* struts doclets
- *
+ *
* @struts.action path="/serverlist" validate="false"
- *
+ *
* @struts.action-forward name="serverlist" path=".serverlist"
*/
public class ServerListAction extends Action {
-
- @SuppressWarnings("unchecked")
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
- List list = AdminServiceProxy
- .getIntegrationService(getServlet().getServletContext())
- .getAllExtServerOrgMaps();
- Collections.sort(list);
- request.setAttribute("servers", list);
- return mapping.findForward("serverlist");
- }
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ List list = AdminServiceProxy.getIntegrationService(getServlet().getServletContext())
+ .getAllExtServerOrgMaps();
+ Collections.sort(list);
+ request.setAttribute("servers", list);
+ return mapping.findForward("serverlist");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerMaintainAction.java
===================================================================
diff -u -rda8739aacc8241083e733f4915dd3176a6d28ef0 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerMaintainAction.java (.../ServerMaintainAction.java) (revision da8739aacc8241083e733f4915dd3176a6d28ef0)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerMaintainAction.java (.../ServerMaintainAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -54,77 +54,69 @@
*/
/**
* struts doclets
- *
+ *
* @struts.action path="/servermaintain" parameter="method" name="ServerOrgMapForm" scope="request" validate="false"
* @struts.action-forward name="servermaintain" path=".servermaintain"
* @struts.action-forward name="serverlist" path="/serverlist.do"
*/
public class ServerMaintainAction extends LamsDispatchAction {
- @SuppressWarnings("unchecked")
- public ActionForward edit(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
- Map properties = new HashMap();
- properties.put("organisationType.organisationTypeId", OrganisationType.COURSE_TYPE);
- properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE);
- List list = AdminServiceProxy.getService(getServlet().getServletContext())
- .findByProperties(Organisation.class, properties);
- Organisation dummy = new Organisation();
- dummy.setOrganisationId(-1);
- dummy.setName(AdminServiceProxy.getMessageService(getServlet().getServletContext())
- .getMessage("sysadmin.organisation.select"));
- if(list == null){
- list = new ArrayList();
- }
- Collections.sort(list);
- list.add(0,dummy);
- request.setAttribute("orgs", list);
- DynaActionForm serverOrgMapForm = (DynaActionForm)form;
- Integer sid = WebUtil.readIntParam(request,"sid",true);
- if(sid != null){
- ExtServerOrgMap map = AdminServiceProxy.getIntegrationService(getServlet().getServletContext())
- .getExtServerOrgMap(sid);
- BeanUtils.copyProperties(serverOrgMapForm,map);
- if (map.getOrganisation() != null) {
- serverOrgMapForm.set("orgId", map.getOrganisation().getOrganisationId());
- }
- }
- return mapping.findForward("servermaintain");
+ @SuppressWarnings("unchecked")
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ Map properties = new HashMap();
+ properties.put("organisationType.organisationTypeId", OrganisationType.COURSE_TYPE);
+ properties.put("organisationState.organisationStateId", OrganisationState.ACTIVE);
+ List list = AdminServiceProxy.getService(getServlet().getServletContext())
+ .findByProperties(Organisation.class, properties);
+ Organisation dummy = new Organisation();
+ dummy.setOrganisationId(-1);
+ dummy.setName(AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("sysadmin.organisation.select"));
+ if (list == null) {
+ list = new ArrayList();
}
-
- public ActionForward disable(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
- IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
- Integer sid = WebUtil.readIntParam(request, "sid", false);
- ExtServerOrgMap map = service.getExtServerOrgMap(sid);
- map.setDisabled(true);
- service.saveExtServerOrgMap(map);
- return mapping.findForward("serverlist");
+ Collections.sort(list);
+ list.add(0, dummy);
+ request.setAttribute("orgs", list);
+ DynaActionForm serverOrgMapForm = (DynaActionForm) form;
+ Integer sid = WebUtil.readIntParam(request, "sid", true);
+ if (sid != null) {
+ ExtServerOrgMap map = AdminServiceProxy.getIntegrationService(getServlet().getServletContext())
+ .getExtServerOrgMap(sid);
+ BeanUtils.copyProperties(serverOrgMapForm, map);
+ if (map.getOrganisation() != null) {
+ serverOrgMapForm.set("orgId", map.getOrganisation().getOrganisationId());
+ }
}
+ return mapping.findForward("servermaintain");
+ }
- public ActionForward enable(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
- IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
- Integer sid = WebUtil.readIntParam(request, "sid", false);
- ExtServerOrgMap map = service.getExtServerOrgMap(sid);
- map.setDisabled(false);
- service.saveExtServerOrgMap(map);
- return mapping.findForward("serverlist");
- }
+ public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ ExtServerOrgMap map = service.getExtServerOrgMap(sid);
+ map.setDisabled(true);
+ service.saveExtServerOrgMap(map);
+ return mapping.findForward("serverlist");
+ }
- public ActionForward delete(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception{
- Integer sid = WebUtil.readIntParam(request, "sid", false);
- AdminServiceProxy.getService(getServlet().getServletContext()).deleteById(ExtServerOrgMap.class,sid);
- return mapping.findForward("serverlist");
- }
-
+ public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ IIntegrationService service = AdminServiceProxy.getIntegrationService(getServlet().getServletContext());
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ ExtServerOrgMap map = service.getExtServerOrgMap(sid);
+ map.setDisabled(false);
+ service.saveExtServerOrgMap(map);
+ return mapping.findForward("serverlist");
+ }
+
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+ Integer sid = WebUtil.readIntParam(request, "sid", false);
+ AdminServiceProxy.getService(getServlet().getServletContext()).deleteById(ExtServerOrgMap.class, sid);
+ return mapping.findForward("serverlist");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerSaveAction.java
===================================================================
diff -u -r154dd0c76d055576f3eadb915647183afef0486c -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerSaveAction.java (.../ServerSaveAction.java) (revision 154dd0c76d055576f3eadb915647183afef0486c)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerSaveAction.java (.../ServerSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -58,9 +58,9 @@
*
* View Source
*
- *
+ *
* @author Fei Yang
- *
+ *
* @struts.action path="/serversave" input=".servermaintain" name="ServerOrgMapForm" scope="request" validate="false"
* @struts.action-forward name="success" path="/serverlist.do"
*/
@@ -70,6 +70,7 @@
private static IUserManagementService userService;
private static MessageService messageService;
+ @Override
@SuppressWarnings("unchecked")
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
@@ -87,39 +88,39 @@
String[] requiredFields = { "serverid", "serverkey", "servername", "prefix", "userinfoUrl", "timeoutUrl" };
for (String requiredField : requiredFields) {
if (StringUtils.trimToNull(serverOrgMapForm.getString(requiredField)) == null) {
- errors.add(requiredField, new ActionMessage("error.required", messageService.getMessage("sysadmin."
- + requiredField)));
+ errors.add(requiredField,
+ new ActionMessage("error.required", messageService.getMessage("sysadmin." + requiredField)));
}
}
Organisation org = null;
UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
if ((Boolean) serverOrgMapForm.get("newOrg")) {
-
+
String orgName = serverOrgMapForm.getString("orgName");
if (StringUtils.trimToNull(orgName) == null) {
errors.add("orgId",
new ActionMessage("error.required", messageService.getMessage("sysadmin.organisation")));
-
+
} else if (!ValidationUtil.isOrgNameValid(orgName)) {
errors.add("orgId", new ActionMessage("error.name.invalid.characters"));
-
+
} else {
-
+
org = new Organisation();
org.setName(orgName);
org.setParentOrganisation(userService.getRootOrganisation());
- org.setOrganisationType((OrganisationType) userService.findById(OrganisationType.class,
- OrganisationType.COURSE_TYPE));
- org.setOrganisationState((OrganisationState) userService.findById(OrganisationState.class,
- OrganisationState.ACTIVE));
+ org.setOrganisationType(
+ (OrganisationType) userService.findById(OrganisationType.class, OrganisationType.COURSE_TYPE));
+ org.setOrganisationState(
+ (OrganisationState) userService.findById(OrganisationState.class, OrganisationState.ACTIVE));
SupportedLocale locale = LanguageUtil.getDefaultLocale();
org.setLocale(locale);
userService.saveOrganisation(org, user.getUserID());
serverOrgMapForm.set("orgId", org.getOrganisationId());
serverOrgMapForm.set("newOrg", false);
serverOrgMapForm.set("orgName", null);
}
-
+
} else {
Integer orgId = (Integer) serverOrgMapForm.get("orgId");
if (orgId.equals(-1)) {
@@ -130,20 +131,20 @@
}
}
Integer sid = (Integer) serverOrgMapForm.get("sid");
- if (errors.isEmpty()) {//check duplication
+ if (errors.isEmpty()) {//check duplication
String[] uniqueFields = { "serverid", "prefix" };
for (String uniqueField : uniqueFields) {
- List list = userService.findByProperty(ExtServerOrgMap.class, uniqueField, serverOrgMapForm
- .get(uniqueField));
+ List list = userService.findByProperty(ExtServerOrgMap.class, uniqueField,
+ serverOrgMapForm.get(uniqueField));
if (list != null && list.size() > 0) {
if (sid.equals(-1)) {//new map
- errors.add(uniqueField, new ActionMessage("error.not.unique", messageService
- .getMessage("sysadmin." + uniqueField)));
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
} else {
ExtServerOrgMap map = (ExtServerOrgMap) list.get(0);
if (!map.getSid().equals(sid)) {
- errors.add(uniqueField, new ActionMessage("error.not.unique", messageService
- .getMessage("sysadmin." + uniqueField)));
+ errors.add(uniqueField, new ActionMessage("error.not.unique",
+ messageService.getMessage("sysadmin." + uniqueField)));
}
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java
===================================================================
diff -u -r5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision 5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -63,9 +63,9 @@
/**
* @author jliew
- *
+ *
* @struts:action path="/toolcontentlist" scope="request" validate="false"
- *
+ *
* @struts:action-forward name="toolcontentlist" path=".toolcontentlist"
* @struts:action-forward name="groups" path="/toolcontent/learningLibraryGroup.jsp"
* @struts.action-forward name="error" path=".error"
@@ -104,10 +104,8 @@
// check permission
if (!(request.isUserInRole(Role.SYSADMIN))) {
request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_NAME, "ToolContentListAction");
- request.setAttribute(
- ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE,
- AdminServiceProxy.getMessageService(getServlet().getServletContext()).getMessage(
- "error.authorisation"));
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE, AdminServiceProxy
+ .getMessageService(getServlet().getServletContext()).getMessage("error.authorisation"));
return mapping.findForward(ToolContentListAction.FORWARD_ERROR);
}
@@ -211,10 +209,8 @@
private boolean checkPriviledge(HttpServletRequest request) {
if (!getUserManagementService().isUserSysAdmin()) {
request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_NAME, "ToolContentListAction");
- request.setAttribute(
- ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE,
- AdminServiceProxy.getMessageService(getServlet().getServletContext()).getMessage(
- "error.no.sysadmin.priviledge"));
+ request.setAttribute(ToolContentListAction.ATTRIBUTE_ERROR_MESSAGE, AdminServiceProxy
+ .getMessageService(getServlet().getServletContext()).getMessage("error.no.sysadmin.priviledge"));
return false;
}
return true;
@@ -241,8 +237,8 @@
private ActionForward openLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws JSONException, IOException {
// build full list of available learning libraries
- List learningLibraries = getLearningDesignService().getAllLearningLibraryDetails(
- getUserLanguage());
+ List learningLibraries = getLearningDesignService()
+ .getAllLearningLibraryDetails(getUserLanguage());
JSONArray learningLibrariesJSON = new JSONArray();
for (LearningLibraryDTO learningLibrary : learningLibraries) {
JSONObject learningLibraryJSON = new JSONObject();
@@ -272,7 +268,6 @@
return mapping.findForward(ToolContentListAction.FORWARD_GROUPS);
}
-
private void saveLearningLibraryGroups(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws JSONException, IOException {
// extract groups from JSON and persist them
@@ -292,38 +287,39 @@
group.setLearningLibraries(new HashSet());
JSONArray learningLibrariesJSON = groupJSON.getJSONArray("learningLibraries");
- for (int learningLibraryIndex = 0; learningLibraryIndex < learningLibrariesJSON.length(); learningLibraryIndex++) {
+ for (int learningLibraryIndex = 0; learningLibraryIndex < learningLibrariesJSON
+ .length(); learningLibraryIndex++) {
long learningLibraryId = learningLibrariesJSON.getLong(learningLibraryIndex);
LearningLibrary learningLibrary = getLearningDesignService().getLearningLibrary(learningLibraryId);
group.getLearningLibraries().add(learningLibrary);
}
}
-
+
getLearningDesignService().saveLearningLibraryGroups(groups);
}
private ILearningDesignService getLearningDesignService() {
if (ToolContentListAction.learningDesignService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
- .getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
ToolContentListAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService");
}
return ToolContentListAction.learningDesignService;
}
private IUserManagementService getUserManagementService() {
if (ToolContentListAction.userManagementService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
- .getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
ToolContentListAction.userManagementService = (IUserManagementService) ctx.getBean("userManagementService");
}
return ToolContentListAction.userManagementService;
}
private DataSource getDataSource() {
if (ToolContentListAction.dataSource == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
- .getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
ToolContentListAction.dataSource = (DataSource) ctx.getBean("dataSource");
}
return ToolContentListAction.dataSource;
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java
===================================================================
diff -u -r862d181bb03e2bbaaf0a9e98c3877a0aff84fdf9 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision 862d181bb03e2bbaaf0a9e98c3877a0aff84fdf9)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -65,14 +65,14 @@
/**
* @author Jun-Dir Liew
- *
+ *
* Created at 17:00:18 on 13/06/2006
*/
/**
* @struts:action path="/user" name="UserForm" scope="request"
* parameter="method" validate="false"
- *
+ *
* @struts:action-forward name="user" path=".user"
* @struts:action-forward name="userlist" path="/usermanage.do"
* @struts:action-forward name="remove" path=".remove"
@@ -85,7 +85,7 @@
private IUserManagementService service;
private MessageService messageService;
private static IThemeService themeService;
- private static ITimezoneService timezoneService;
+ private static ITimezoneService timezoneService;
private static List locales;
private static List authenticationMethods;
@@ -101,10 +101,11 @@
}
if (timezoneService == null) {
timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
- }
+ }
}
- public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
initServices();
if (UserAction.locales == null) {
@@ -124,7 +125,7 @@
request.setAttribute("cssThemes", cssThemes);
List flashThemes = themeService.getAllFlashThemes();
request.setAttribute("flashThemes", flashThemes);
-
+
// Select the default themes by default
Theme defaultCSSTheme = themeService.getDefaultCSSTheme();
for (Theme theme : cssThemes) {
@@ -148,8 +149,8 @@
org = (Organisation) service.findById(Organisation.class, orgId);
if (!canEdit) {
OrganisationType orgType = org.getOrganisationType();
- Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE) ? org.getParentOrganisation().getOrganisationId()
- : orgId;
+ Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)
+ ? org.getParentOrganisation().getOrganisationId() : orgId;
User requestor = service.getUserByLogin(request.getRemoteUser());
if (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN)
|| service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)) {
@@ -221,7 +222,7 @@
}
}
userForm.set("orgId", (org == null ? null : org.getOrganisationId()));
-
+
// Get all available time zones
List availableTimeZones = timezoneService.getDefaultTimezones();
TreeSet timezoneDtos = new TreeSet(new TimezoneDTOComparator());
@@ -253,7 +254,8 @@
// display user's global roles, if any
private UserOrgRoleDTO getGlobalRoles(User user) {
initServices();
- UserOrganisation uo = service.getUserOrganisation(user.getUserId(), service.getRootOrganisation().getOrganisationId());
+ UserOrganisation uo = service.getUserOrganisation(user.getUserId(),
+ service.getRootOrganisation().getOrganisationId());
if (uo == null) {
return null;
}
@@ -273,8 +275,8 @@
initServices();
List uorDTOs = new ArrayList();
- List uos = service
- .getUserOrganisationsForUserByTypeAndStatus(user.getLogin(), OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE);
+ List uos = service.getUserOrganisationsForUserByTypeAndStatus(user.getLogin(),
+ OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE);
for (UserOrganisation uo : uos) {
UserOrgRoleDTO uorDTO = new UserOrgRoleDTO();
List roles = new ArrayList();
@@ -285,8 +287,9 @@
uorDTO.setOrgName(uo.getOrganisation().getName());
uorDTO.setRoles(roles);
List childDTOs = new ArrayList();
- List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(user.getLogin(), OrganisationType.CLASS_TYPE,
- OrganisationState.ACTIVE, uo.getOrganisation().getOrganisationId());
+ List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(
+ user.getLogin(), OrganisationType.CLASS_TYPE, OrganisationState.ACTIVE,
+ uo.getOrganisation().getOrganisationId());
for (UserOrganisation childuo : childuos) {
UserOrgRoleDTO childDTO = new UserOrgRoleDTO();
List childroles = new ArrayList();
@@ -306,7 +309,8 @@
}
// determine whether to disable or delete user based on their lams data
- public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
initServices();
@@ -328,7 +332,8 @@
return mapping.findForward("remove");
}
- public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
initServices();
@@ -354,7 +359,8 @@
}
}
- public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
initServices();
@@ -387,7 +393,8 @@
}
// called from disabled users screen
- public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
initServices();
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserBean.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserBean.java (.../UserBean.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserBean.java (.../UserBean.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -26,47 +26,47 @@
/**
* @author jliew
- *
- * Bean used as member of UserOrgRoleForm, representing a user's roles.
*
+ * Bean used as member of UserOrgRoleForm, representing a user's roles.
+ *
*/
public class UserBean {
private Integer userId;
private String login;
private String[] roleIds = {};
private Boolean memberOfParent;
-
+
public Integer getUserId() {
- return this.userId;
+ return this.userId;
}
-
+
public void setUserId(Integer userId) {
- this.userId = userId;
+ this.userId = userId;
}
-
+
public String getLogin() {
- return this.login;
+ return this.login;
}
-
+
public void setLogin(String login) {
- this.login = login;
+ this.login = login;
}
-
- public String[] getRoleIds(){
- return this.roleIds;
+
+ public String[] getRoleIds() {
+ return this.roleIds;
}
-
- public void setRoleIds(String[] roleIds){
- this.roleIds = roleIds;
+
+ public void setRoleIds(String[] roleIds) {
+ this.roleIds = roleIds;
}
-
+
public Boolean getMemberOfParent() {
- return this.memberOfParent;
+ return this.memberOfParent;
}
-
+
public void setMemberOfParent(Boolean memberOfParent) {
- this.memberOfParent = memberOfParent;
+ this.memberOfParent = memberOfParent;
}
-
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserListDTO.java
===================================================================
diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserListDTO.java (.../UserListDTO.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserListDTO.java (.../UserListDTO.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -31,53 +31,53 @@
/**
* @author Jun-Dir Liew
*
- * Created at 13:47:02 on 9/06/2006
+ * Created at 13:47:02 on 9/06/2006
*/
public class UserListDTO {
- private List userManageBeans;
- private Integer orgId;
- private String orgName;
- private Boolean courseAdminCanAddNewUsers;
- private Boolean courseAdminCanBrowseAllUsers;
+ private List userManageBeans;
+ private Integer orgId;
+ private String orgName;
+ private Boolean courseAdminCanAddNewUsers;
+ private Boolean courseAdminCanBrowseAllUsers;
- public List getUserManageBeans() {
- return userManageBeans;
- }
-
- public void setUserManageBeans(List userManageBeans) {
- this.userManageBeans = userManageBeans;
- }
-
- public Integer getOrgId() {
- return orgId;
- }
-
- public void setOrgId(Integer orgId) {
- this.orgId = orgId;
- }
-
- public String getOrgName() {
- return orgName;
- }
-
- public void setOrgName(String orgName) {
- this.orgName = orgName;
- }
-
- public Boolean getCourseAdminCanAddNewUsers() {
- return courseAdminCanAddNewUsers;
- }
-
- public void setCourseAdminCanAddNewUsers(Boolean courseAdminCanAddNewUsers) {
- this.courseAdminCanAddNewUsers = courseAdminCanAddNewUsers;
- }
-
- public Boolean getCourseAdminCanBrowseAllUsers() {
- return courseAdminCanBrowseAllUsers;
- }
-
- public void setCourseAdminCanBrowseAllUsers(Boolean courseAdminCanBrowseAllUsers) {
- this.courseAdminCanBrowseAllUsers = courseAdminCanBrowseAllUsers;
- }
+ public List getUserManageBeans() {
+ return userManageBeans;
+ }
+
+ public void setUserManageBeans(List userManageBeans) {
+ this.userManageBeans = userManageBeans;
+ }
+
+ public Integer getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(Integer orgId) {
+ this.orgId = orgId;
+ }
+
+ public String getOrgName() {
+ return orgName;
+ }
+
+ public void setOrgName(String orgName) {
+ this.orgName = orgName;
+ }
+
+ public Boolean getCourseAdminCanAddNewUsers() {
+ return courseAdminCanAddNewUsers;
+ }
+
+ public void setCourseAdminCanAddNewUsers(Boolean courseAdminCanAddNewUsers) {
+ this.courseAdminCanAddNewUsers = courseAdminCanAddNewUsers;
+ }
+
+ public Boolean getCourseAdminCanBrowseAllUsers() {
+ return courseAdminCanBrowseAllUsers;
+ }
+
+ public void setCourseAdminCanBrowseAllUsers(Boolean courseAdminCanBrowseAllUsers) {
+ this.courseAdminCanBrowseAllUsers = courseAdminCanBrowseAllUsers;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserManageAction.java
===================================================================
diff -u -r509d15bcc570bff483a13152ef8c45cbae767e78 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserManageAction.java (.../UserManageAction.java) (revision 509d15bcc570bff483a13152ef8c45cbae767e78)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserManageAction.java (.../UserManageAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -56,7 +56,7 @@
/**
* struts doclets
- *
+ *
* @struts:action path="/usermanage" validate="false"
*
* @struts:action-forward name="userlist" path=".userlist"
@@ -67,6 +67,7 @@
private static IUserManagementService service;
private static MessageService messageService;
+ @Override
@SuppressWarnings("unchecked")
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java
===================================================================
diff -u -rbb68074ebb9f2415fcc7758d9257de0c6358dc22 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (.../UserOrgAction.java) (revision bb68074ebb9f2415fcc7758d9257de0c6358dc22)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (.../UserOrgAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -46,7 +46,7 @@
/**
* struts doclets
- *
+ *
* @struts:action path="/userorg"
* name="UserOrgForm"
* scope="request"
@@ -56,50 +56,49 @@
* path=".userorg"
*/
public class UserOrgAction extends Action {
-
- private static final Logger log = Logger.getLogger(UserOrgAction.class);
- private static IUserManagementService service;
- private static MessageService messageService;
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
-
- //ActionMessages errors = new ActionMessages();
- Integer orgId = WebUtil.readIntParam(request,"orgId",true);
- log.debug("orgId: "+orgId);
- // get org name
- Organisation organisation = (Organisation)service.findById(Organisation.class,orgId);
- if((orgId==null)||(orgId<=0)||organisation==null){
- request.setAttribute("errorName","UserOrgAction");
- request.setAttribute("errorMessage",messageService.getMessage("error.org.invalid"));
- return mapping.findForward("error");
- }
-
- String orgName = organisation.getName();
- log.debug("orgName: "+orgName);
- Organisation parentOrg = organisation.getParentOrganisation();
- if(parentOrg!=null && !parentOrg.equals(service.getRootOrganisation())){
- request.setAttribute("pOrgId",parentOrg.getOrganisationId());
- request.setAttribute("pOrgName",parentOrg.getName());
- }
- Integer orgType = organisation.getOrganisationType().getOrganisationTypeId();
- request.setAttribute("orgType",orgType);
-
- // create form object
- DynaActionForm userOrgForm = (DynaActionForm)form;
- userOrgForm.set("orgId",orgId);
- userOrgForm.set("orgName",orgName);
+ private static final Logger log = Logger.getLogger(UserOrgAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
- String[] args = { "0" };
- request.setAttribute("numExistUsers", messageService.getMessage("label.number.of.users", args));
- request.setAttribute("numPotentialUsers", messageService.getMessage("label.number.of.potential.users", args));
-
- return mapping.findForward("userorg");
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+
+ //ActionMessages errors = new ActionMessages();
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ log.debug("orgId: " + orgId);
+ // get org name
+ Organisation organisation = (Organisation) service.findById(Organisation.class, orgId);
+
+ if ((orgId == null) || (orgId <= 0) || organisation == null) {
+ request.setAttribute("errorName", "UserOrgAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.org.invalid"));
+ return mapping.findForward("error");
}
+
+ String orgName = organisation.getName();
+ log.debug("orgName: " + orgName);
+ Organisation parentOrg = organisation.getParentOrganisation();
+ if (parentOrg != null && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("pOrgName", parentOrg.getName());
+ }
+ Integer orgType = organisation.getOrganisationType().getOrganisationTypeId();
+ request.setAttribute("orgType", orgType);
+
+ // create form object
+ DynaActionForm userOrgForm = (DynaActionForm) form;
+ userOrgForm.set("orgId", orgId);
+ userOrgForm.set("orgName", orgName);
+
+ String[] args = { "0" };
+ request.setAttribute("numExistUsers", messageService.getMessage("label.number.of.users", args));
+ request.setAttribute("numPotentialUsers", messageService.getMessage("label.number.of.potential.users", args));
+
+ return mapping.findForward("userorg");
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRoleAction.java
===================================================================
diff -u -r3d8d01d6573f30c61362c27132e8f241ecfea46e -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRoleAction.java (.../UserOrgRoleAction.java) (revision 3d8d01d6573f30c61362c27132e8f241ecfea46e)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRoleAction.java (.../UserOrgRoleAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -46,14 +46,14 @@
/**
* @author jliew
- *
+ *
* Called when a user has added users to an organisation.
*
*/
/**
* struts doclets
- *
+ *
* @struts:action path="/userorgrole"
* name="UserOrgRoleForm"
* scope="session"
@@ -63,57 +63,59 @@
* path=".userorgrole"
*/
public class UserOrgRoleAction extends Action {
-
- private static Logger log = Logger.getLogger(UserOrgRoleAction.class);
- private static IUserManagementService service;
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- UserOrgRoleForm userOrgRoleForm = (UserOrgRoleForm)form;
- // make sure we don't have left overs from any previous attempt
- userOrgRoleForm.setUserBeans(new ArrayList());
-
- // set list of roles appropriate for the organisation type
- List roles = (List)request.getAttribute("roles");
- request.setAttribute("numroles", roles.size());
- Collections.sort(roles);
- request.setAttribute("roles",roles);
-
- Organisation organisation = (Organisation)service.findById(Organisation.class, (Integer)request.getAttribute("orgId"));
- userOrgRoleForm.setOrgId(organisation.getOrganisationId());
-
- // display breadcrumb links
- request.setAttribute("orgName", organisation.getName());
- Organisation parentOrg = organisation.getParentOrganisation();
- if(parentOrg!=null && !parentOrg.equals(service.getRootOrganisation())){
- request.setAttribute("pOrgId",parentOrg.getOrganisationId());
- request.setAttribute("pOrgName",parentOrg.getName());
- }
- request.setAttribute("orgType",organisation.getOrganisationType().getOrganisationTypeId());
-
- // populate form with users
- ArrayList userOrgs = (ArrayList)request.getAttribute("newUserOrganisations");
- for(int i=0; i)Arrays.asList(roleIds));
- // FMALIKOFF 5/7/7 Commented out the following code that set the roles in the course if the current org is a class, as the logic
- // is done in service.setRolesForUserOrganisation()
- //if (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
- // if (service.getUserOrganisation(bean.getUserId(), organisation.getParentOrganisation().getOrganisationId())==null) {
- // service.setRolesForUserOrganisation(user, organisation.getParentOrganisation(), (List)Arrays.asList(roleIds));
- // }
- //}
- }
- return mapping.findForward("userlist");
+
+ private static Logger log = Logger.getLogger(UserOrgRoleSaveAction.class);
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ UserOrgRoleForm userOrgRoleForm = (UserOrgRoleForm) form;
+
+ ArrayList userBeans = userOrgRoleForm.getUserBeans();
+ log.debug("userBeans is null? " + userBeans == null);
+ Integer orgId = userOrgRoleForm.getOrgId();
+ log.debug("orgId: " + orgId);
+
+ request.setAttribute("org", orgId);
+ request.getSession().removeAttribute("UserOrgRoleForm");
+
+ if (isCancelled(request)) {
+ return mapping.findForward("userlist");
}
+ // save UserOrganisation memberships, and the associated roles;
+ // for subgroups, if user is not a member of the parent group then add to that as well.
+ for (int i = 0; i < userBeans.size(); i++) {
+ UserBean bean = (UserBean) userBeans.get(i);
+ User user = (User) service.findById(User.class, bean.getUserId());
+ log.debug("userId: " + bean.getUserId());
+ String[] roleIds = bean.getRoleIds();
+ if (roleIds.length == 0) {
+ // TODO forward to userorgrole.do, not userorg.do
+ ActionMessages errors = new ActionMessages();
+ errors.add("roles", new ActionMessage("error.roles.empty"));
+ saveErrors(request, errors);
+ request.setAttribute("orgId", orgId);
+ return mapping.findForward("userorg");
+ }
+ service.setRolesForUserOrganisation(user, orgId, Arrays.asList(roleIds));
+ // FMALIKOFF 5/7/7 Commented out the following code that set the roles in the course if the current org is a class, as the logic
+ // is done in service.setRolesForUserOrganisation()
+ //if (organisation.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ // if (service.getUserOrganisation(bean.getUserId(), organisation.getParentOrganisation().getOrganisationId())==null) {
+ // service.setRolesForUserOrganisation(user, organisation.getParentOrganisation(), (List)Arrays.asList(roleIds));
+ // }
+ //}
+ }
+ return mapping.findForward("userlist");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgSaveAction.java
===================================================================
diff -u -r9d08e7b9e69a5d52144ad6ccb3cd7a04d2b4925c -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgSaveAction.java (.../UserOrgSaveAction.java) (revision 9d08e7b9e69a5d52144ad6ccb3cd7a04d2b4925c)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgSaveAction.java (.../UserOrgSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -54,9 +54,9 @@
/**
* struts doclets
- *
+ *
* @struts:action path="/userorgsave" name="UserOrgForm" input=".userorg" scope="request" validate="false"
- *
+ *
* @struts:action-forward name="userlist" path="/usermanage.do"
* @struts:action-forward name="userorgrole" path="/userorgrole.do"
*/
@@ -66,6 +66,7 @@
private static IUserManagementService service;
private List rolelist;
+ @Override
@SuppressWarnings("unchecked")
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
@@ -80,8 +81,9 @@
}
service = AdminServiceProxy.getService(getServlet().getServletContext());
- if (rolelist == null)
+ if (rolelist == null) {
rolelist = service.findAll(Role.class);
+ }
Organisation organisation = (Organisation) service.findById(Organisation.class, orgId);
Set uos = organisation.getUserOrganisations();
@@ -109,7 +111,7 @@
// add UserOrganisations that are in form data
List newUserOrganisations = new ArrayList();
for (int i = 0; i < userIdList.size(); i++) {
- Integer userId = new Integer((String) userIdList.get(i));
+ Integer userId = new Integer(userIdList.get(i));
Iterator iter2 = uos.iterator();
Boolean alreadyInOrg = false;
while (iter2.hasNext()) {
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesAction.java
===================================================================
diff -u -r4a2728da7ea82a98b92d3a8b08feb6efa4023b7d -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesAction.java (.../UserRolesAction.java) (revision 4a2728da7ea82a98b92d3a8b08feb6efa4023b7d)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesAction.java (.../UserRolesAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -24,7 +24,6 @@
/* $Id$ */
package org.lamsfoundation.lams.admin.web;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -55,106 +54,110 @@
* @author jliew
*
* @struts:action path="/userroles"
- * name="UserRolesForm"
- * scope="request"
- * parameter="method"
- * validate="false"
- *
+ * name="UserRolesForm"
+ * scope="request"
+ * parameter="method"
+ * validate="false"
+ *
* @struts:action-forward name="userrole" path=".userrole"
* @struts:action-forward name="userlist" path="/usermanage.do"
*/
public class UserRolesAction extends Action {
-
- private static Logger log = Logger.getLogger(UserRolesAction.class);
- private static IUserManagementService service;
- private static MessageService messageService;
- private static List rolelist;
-
- @SuppressWarnings("unchecked")
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
- if (rolelist==null) {
- rolelist = service.findAll(Role.class);
- Collections.sort(rolelist);
- }
-
- ActionMessages errors = new ActionMessages();
- DynaActionForm userRolesForm = (DynaActionForm)form;
- Integer orgId = WebUtil.readIntParam(request,"orgId",true);
- Integer userId = WebUtil.readIntParam(request,"userId",true);
-
- // user and org ids passed as attributes by UserSaveAction
- if (orgId==null) orgId = (Integer)request.getAttribute("orgId");
- if (orgId==null) {
- errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.org.invalid"));
- saveErrors(request,errors);
- return mapping.findForward("userrole");
- }
- if (userId==null || userId==0) userId = (Integer)request.getAttribute("userId");
- if (userId==null) {
- errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.userid.invalid"));
- saveErrors(request,errors);
- return mapping.findForward("userrole");
- }
- log.debug("editing roles for userId: "+userId+" and orgId: "+orgId);
-
- // test requestor's permission
- Organisation org = (Organisation)service.findById(Organisation.class,orgId);
- User user = (User)service.findById(User.class, userId);
- OrganisationType orgType = org.getOrganisationType();
- Integer orgIdOfCourse = (orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE))
- ? org.getParentOrganisation().getOrganisationId() : orgId;
- Boolean isSysadmin = request.isUserInRole(Role.SYSADMIN);
- User requestor = (User)service.getUserByLogin(request.getRemoteUser());
- Integer rootOrgId = service.getRootOrganisation().getOrganisationId();
- Boolean requestorHasRole = service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)
- || (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN) && !rootOrgId.equals(orgId))
- || (service.isUserGlobalGroupAdmin() && !rootOrgId.equals(orgId));
-
- if (!(requestorHasRole || isSysadmin)) {
- request.setAttribute("errorName","UserRolesAction");
- request.setAttribute("errorMessage",messageService.getMessage("error.authorisation"));
- return mapping.findForward("error");
- }
-
- userRolesForm.set("userId",userId);
- userRolesForm.set("orgId", org.getOrganisationId());
- // screen display vars
- request.setAttribute("rolelist",service.filterRoles(rolelist,isSysadmin,orgType));
- request.setAttribute("login", user.getLogin());
- request.setAttribute("fullName", user.getFullName());
- request.setAttribute("orgName", org.getName());
- Organisation parentOrg = org.getParentOrganisation();
- if (parentOrg!=null && !parentOrg.equals(service.getRootOrganisation())) {
- request.setAttribute("pOrgId", parentOrg.getOrganisationId());
- request.setAttribute("parentName", parentOrg.getName());
- }
-
- String[] roles = null;
- UserOrganisation uo = service.getUserOrganisation(userId, orgId);
- if (uo != null) {
- Iterator iter2 = uo.getUserOrganisationRoles().iterator();
- roles = new String[uo.getUserOrganisationRoles().size()];
- int i=0;
- while(iter2.hasNext()){
- UserOrganisationRole uor = (UserOrganisationRole)iter2.next();
- roles[i]=uor.getRole().getRoleId().toString();
- log.debug("got roleid: "+roles[i]);
- i++;
- }
- } else {
- ActionMessages messages = new ActionMessages();
- messages.add("roles", new ActionMessage("msg.add.to.org", org.getName()));
- saveMessages(request,messages);
- }
- userRolesForm.set("roles",roles);
-
- return mapping.findForward("userrole");
+
+ private static Logger log = Logger.getLogger(UserRolesAction.class);
+ private static IUserManagementService service;
+ private static MessageService messageService;
+ private static List rolelist;
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ if (rolelist == null) {
+ rolelist = service.findAll(Role.class);
+ Collections.sort(rolelist);
}
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm userRolesForm = (DynaActionForm) form;
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ Integer userId = WebUtil.readIntParam(request, "userId", true);
+
+ // user and org ids passed as attributes by UserSaveAction
+ if (orgId == null) {
+ orgId = (Integer) request.getAttribute("orgId");
+ }
+ if (orgId == null) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.org.invalid"));
+ saveErrors(request, errors);
+ return mapping.findForward("userrole");
+ }
+ if (userId == null || userId == 0) {
+ userId = (Integer) request.getAttribute("userId");
+ }
+ if (userId == null) {
+ errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.userid.invalid"));
+ saveErrors(request, errors);
+ return mapping.findForward("userrole");
+ }
+ log.debug("editing roles for userId: " + userId + " and orgId: " + orgId);
+
+ // test requestor's permission
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ User user = (User) service.findById(User.class, userId);
+ OrganisationType orgType = org.getOrganisationType();
+ Integer orgIdOfCourse = (orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE))
+ ? org.getParentOrganisation().getOrganisationId() : orgId;
+ Boolean isSysadmin = request.isUserInRole(Role.SYSADMIN);
+ User requestor = service.getUserByLogin(request.getRemoteUser());
+ Integer rootOrgId = service.getRootOrganisation().getOrganisationId();
+ Boolean requestorHasRole = service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)
+ || (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN)
+ && !rootOrgId.equals(orgId))
+ || (service.isUserGlobalGroupAdmin() && !rootOrgId.equals(orgId));
+
+ if (!(requestorHasRole || isSysadmin)) {
+ request.setAttribute("errorName", "UserRolesAction");
+ request.setAttribute("errorMessage", messageService.getMessage("error.authorisation"));
+ return mapping.findForward("error");
+ }
+
+ userRolesForm.set("userId", userId);
+ userRolesForm.set("orgId", org.getOrganisationId());
+ // screen display vars
+ request.setAttribute("rolelist", service.filterRoles(rolelist, isSysadmin, orgType));
+ request.setAttribute("login", user.getLogin());
+ request.setAttribute("fullName", user.getFullName());
+ request.setAttribute("orgName", org.getName());
+ Organisation parentOrg = org.getParentOrganisation();
+ if (parentOrg != null && !parentOrg.equals(service.getRootOrganisation())) {
+ request.setAttribute("pOrgId", parentOrg.getOrganisationId());
+ request.setAttribute("parentName", parentOrg.getName());
+ }
+
+ String[] roles = null;
+ UserOrganisation uo = service.getUserOrganisation(userId, orgId);
+ if (uo != null) {
+ Iterator iter2 = uo.getUserOrganisationRoles().iterator();
+ roles = new String[uo.getUserOrganisationRoles().size()];
+ int i = 0;
+ while (iter2.hasNext()) {
+ UserOrganisationRole uor = (UserOrganisationRole) iter2.next();
+ roles[i] = uor.getRole().getRoleId().toString();
+ log.debug("got roleid: " + roles[i]);
+ i++;
+ }
+ } else {
+ ActionMessages messages = new ActionMessages();
+ messages.add("roles", new ActionMessage("msg.add.to.org", org.getName()));
+ saveMessages(request, messages);
+ }
+ userRolesForm.set("roles", roles);
+
+ return mapping.findForward("userrole");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesSaveAction.java
===================================================================
diff -u -r9d6c499e9e59826c9683b30af19e580403aa8a41 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesSaveAction.java (.../UserRolesSaveAction.java) (revision 9d6c499e9e59826c9683b30af19e580403aa8a41)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesSaveAction.java (.../UserRolesSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -49,60 +49,61 @@
* @author jliew
*
* @struts:action path="/userrolessave"
- * name="UserRolesForm"
- * input=".userroles"
- * scope="request"
- * parameter="method"
- * validate="false"
- *
+ * name="UserRolesForm"
+ * input=".userroles"
+ * scope="request"
+ * parameter="method"
+ * validate="false"
+ *
* @struts:action-forward name="userroles" path="/userroles.do"
* @struts:action-forward name="userlist" path="/usermanage.do"
*/
public class UserRolesSaveAction extends Action {
-
- private static Logger log = Logger.getLogger(UserRolesSaveAction.class);
- private static IUserManagementService service;
- private static List rolelist;
-
- public ActionForward execute(ActionMapping mapping, ActionForm form,
- HttpServletRequest request, HttpServletResponse response)
- throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- if (rolelist==null) {
- rolelist = service.findAll(Role.class);
- Collections.sort(rolelist);
- }
-
- ActionMessages errors = new ActionMessages();
- DynaActionForm userRolesForm = (DynaActionForm) form;
- Integer orgId = (Integer) userRolesForm.get("orgId");
- Integer userId = (Integer) userRolesForm.get("userId");
- String[] roles = (String[]) userRolesForm.get("roles");
-
- request.setAttribute("org", orgId);
-
- if (isCancelled(request)) {
- return mapping.findForward("userlist");
- }
-
- log.debug("userId: "+userId+", orgId: "+orgId+" will have "+roles.length+" roles");
- Organisation org = (Organisation)service.findById(Organisation.class, orgId);
- User user = (User)service.findById(User.class, userId);
-
- // user must have at least 1 role
- if (roles.length < 1) {
- errors.add("roles", new ActionMessage("error.roles.empty"));
- saveErrors(request,errors);
- request.setAttribute("rolelist",service.filterRoles(rolelist,request.isUserInRole(Role.SYSADMIN),org.getOrganisationType()));
- request.setAttribute("login", user.getLogin());
- request.setAttribute("fullName", user.getFullName());
- return mapping.findForward("userroles");
- }
-
- service.setRolesForUserOrganisation(user, orgId, (List)Arrays.asList(roles));
-
- return mapping.findForward("userlist");
+
+ private static Logger log = Logger.getLogger(UserRolesSaveAction.class);
+ private static IUserManagementService service;
+ private static List rolelist;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ if (rolelist == null) {
+ rolelist = service.findAll(Role.class);
+ Collections.sort(rolelist);
}
+ ActionMessages errors = new ActionMessages();
+ DynaActionForm userRolesForm = (DynaActionForm) form;
+ Integer orgId = (Integer) userRolesForm.get("orgId");
+ Integer userId = (Integer) userRolesForm.get("userId");
+ String[] roles = (String[]) userRolesForm.get("roles");
+
+ request.setAttribute("org", orgId);
+
+ if (isCancelled(request)) {
+ return mapping.findForward("userlist");
+ }
+
+ log.debug("userId: " + userId + ", orgId: " + orgId + " will have " + roles.length + " roles");
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ User user = (User) service.findById(User.class, userId);
+
+ // user must have at least 1 role
+ if (roles.length < 1) {
+ errors.add("roles", new ActionMessage("error.roles.empty"));
+ saveErrors(request, errors);
+ request.setAttribute("rolelist",
+ service.filterRoles(rolelist, request.isUserInRole(Role.SYSADMIN), org.getOrganisationType()));
+ request.setAttribute("login", user.getLogin());
+ request.setAttribute("fullName", user.getFullName());
+ return mapping.findForward("userroles");
+ }
+
+ service.setRolesForUserOrganisation(user, orgId, Arrays.asList(roles));
+
+ return mapping.findForward("userlist");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java
===================================================================
diff -u -r273ac76ea166a02a1e72b10010ac41c545349bd5 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision 273ac76ea166a02a1e72b10010ac41c545349bd5)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -25,8 +25,6 @@
package org.lamsfoundation.lams.admin.web;
import java.util.Date;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -43,7 +41,6 @@
import org.apache.struts.action.DynaActionForm;
import org.lamsfoundation.lams.admin.AdminConstants;
import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
-import org.lamsfoundation.lams.integration.UserInfoValidationException;
import org.lamsfoundation.lams.themes.Theme;
import org.lamsfoundation.lams.usermanagement.AuthenticationMethod;
import org.lamsfoundation.lams.usermanagement.SupportedLocale;
@@ -54,15 +51,15 @@
/**
* @author Jun-Dir Liew
- *
+ *
* Created at 12:35:38 on 14/06/2006
*/
/**
* struts doclets
- *
+ *
* @struts:action path="/usersave" name="UserForm" input=".user" scope="request" validate="false"
- *
+ *
* @struts:action-forward name="user" path="/user.do?method=edit"
* @struts:action-forward name="userlist" path="/usermanage.do"
* @struts:action-forward name="userroles" path="/userroles.do"
@@ -90,8 +87,8 @@
Boolean passwordChanged = true;
SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class,
(Integer) userForm.get("localeId"));
- AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service.findById(
- AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId"));
+ AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service
+ .findById(AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId"));
UserSaveAction.log.debug("locale: " + locale);
UserSaveAction.log.debug("authenticationMethod:" + authenticationMethod);
@@ -122,9 +119,8 @@
if ((user != null) && StringUtils.equals(user.getLogin(), login)) {
// login exists - it's the user's current login
} else {
- errors.add("login",
- new ActionMessage("error.login.unique", "(" + login + ", ID: " + existingUser.getUserId()
- + ")"));
+ errors.add("login", new ActionMessage("error.login.unique",
+ "(" + login + ", ID: " + existingUser.getUserId() + ")"));
}
}
}
@@ -140,23 +136,23 @@
errors.add("password", new ActionMessage("error.password.required"));
}
}
-
+
//first name validation
String firstName = (userForm.get("firstName") == null) ? null : (String) userForm.get("firstName");
if (StringUtils.isBlank(firstName)) {
errors.add("firstName", new ActionMessage("error.firstname.required"));
} else if (!ValidationUtil.isFirstLastNameValid(firstName)) {
errors.add("firstName", new ActionMessage("error.firstname.invalid.characters"));
}
-
+
//last name validation
String lastName = (userForm.get("lastName") == null) ? null : (String) userForm.get("lastName");
if (StringUtils.isBlank(lastName)) {
errors.add("lastName", new ActionMessage("error.lastname.required"));
} else if (!ValidationUtil.isFirstLastNameValid(lastName)) {
errors.add("lastName", new ActionMessage("error.lastname.invalid.characters"));
}
-
+
//user email validation
String userEmail = (userForm.get("email") == null) ? null : (String) userForm.get("email");
if (StringUtils.isBlank(userEmail)) {
@@ -200,8 +196,9 @@
user.setHtmlTheme(UserSaveAction.service.getDefaultHtmlTheme());
user.setDisabledFlag(false);
user.setCreateDate(new Date());
- user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service.findByProperty(
- AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database").get(0));
+ user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service
+ .findByProperty(AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database")
+ .get(0));
user.setUserId(null);
user.setLocale(locale);
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java
===================================================================
diff -u -rf0068567e57c2d2da0ebdc6cd43091d564d3b493 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java (.../UserSearchAction.java) (revision f0068567e57c2d2da0ebdc6cd43091d564d3b493)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java (.../UserSearchAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -49,7 +49,7 @@
/**
* @author jliew
- *
+ *
* @struts:action path="/usersearch" parameter="dispatch" input=".usersearchlist" scope="request" validate="false"
*
* @struts:action-forward name="usersearchlist" path=".usersearchlist"
@@ -60,6 +60,7 @@
private static IUserManagementService service;
private static MessageService messageService;
+ @Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
initServices();
@@ -123,7 +124,7 @@
responcedata.put("total_rows", service.getCountUsers(searchString));
JSONArray rows = new JSONArray();
- for (UserDTO userDto: userDtos) {
+ for (UserDTO userDto : userDtos) {
JSONObject responseRow = new JSONObject();
responseRow.put("userId", userDto.getUserID());
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java
===================================================================
diff -u -r6ff4f982622156637b52ed1759eda7103cfda2d8 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (.../CleanupTempFilesAction.java) (revision 6ff4f982622156637b52ed1759eda7103cfda2d8)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (.../CleanupTempFilesAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -48,93 +48,89 @@
* @author jliew
*
* @struts:action path="/cleanup"
- * name="CleanupForm"
- * scope="request"
- * validate="false"
- *
+ * name="CleanupForm"
+ * scope="request"
+ * validate="false"
+ *
* @struts:action-forward name="cleanup" path=".cleanup"
* @struts:action-forward name="sysadmin" path="/sysadminstart.do"
*/
public class CleanupTempFilesAction extends Action {
-
- private static Logger log = Logger.getLogger(CleanupTempFilesAction.class);
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- // check user is sysadmin
- if (!(request.isUserInRole(Role.SYSADMIN))) {
- request.setAttribute("errorName","CleanupTempFilesAction");
- request.setAttribute("errorMessage",AdminServiceProxy
- .getMessageService(getServlet().getServletContext())
- .getMessage("error.need.sysadmin"));
- return mapping.findForward("error");
- }
-
- if (isCancelled(request)) {
- return mapping.findForward("sysadmin");
- }
-
- // check if url contains request for refresh folder sizes only
- String action = WebUtil.readStrParam(request, "action", true);
- if (action != null && StringUtils.equals(action, "refresh")) {
- return refresh(mapping, form, request, response);
- }
-
- ActionMessages errors = new ActionMessages();
- DynaActionForm dynaForm = (DynaActionForm)form;
- Integer numDays = (Integer)dynaForm.get("numDays");
-
- // delete directories if form has been submitted
- if (numDays != null) {
- if (numDays >= 0) {
- int filesDeleted = FileUtil.cleanupOldFiles(FileUtil.getOldTempFiles(numDays));
- MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
- String args[] = new String[1];
- args[0] = new Integer(filesDeleted).toString();
- request.setAttribute("filesDeleted", messageService.getMessage("msg.cleanup.files.deleted", args));
- } else {
- errors.add("numDays", new ActionMessage("error.non.negative.number.required"));
- }
- } else {
- // recommended number of days to leave temp files
- dynaForm.set("numDays", new Integer(1));
- }
-
- return mapping.findForward("cleanup");
+
+ private static Logger log = Logger.getLogger(CleanupTempFilesAction.class);
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // check user is sysadmin
+ if (!(request.isUserInRole(Role.SYSADMIN))) {
+ request.setAttribute("errorName", "CleanupTempFilesAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.need.sysadmin"));
+ return mapping.findForward("error");
}
-
- public ActionForward refresh(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- // display temp files info
- File oldFiles[] = FileUtil.getOldTempFiles(0);
- long zipTotal = 0;
- long tmpTotal = 0;
- if (oldFiles != null) {
- for (int i=0; i= 0) {
+ int filesDeleted = FileUtil.cleanupOldFiles(FileUtil.getOldTempFiles(numDays));
+ MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
+ String args[] = new String[1];
+ args[0] = new Integer(filesDeleted).toString();
+ request.setAttribute("filesDeleted", messageService.getMessage("msg.cleanup.files.deleted", args));
+ } else {
+ errors.add("numDays", new ActionMessage("error.non.negative.number.required"));
+ }
+ } else {
+ // recommended number of days to leave temp files
+ dynaForm.set("numDays", new Integer(1));
+ }
+
+ return mapping.findForward("cleanup");
+ }
+
+ public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // display temp files info
+ File oldFiles[] = FileUtil.getOldTempFiles(0);
+ long zipTotal = 0;
+ long tmpTotal = 0;
+ if (oldFiles != null) {
+ for (int i = 0; i < oldFiles.length; i++) {
+ if (oldFiles[i].getName().startsWith(TempDirectoryFilter.zip_prefix)) {
+ zipTotal += FileUtil.calculateFileSize(oldFiles[i]);
+ } else if (oldFiles[i].getName().startsWith(TempDirectoryFilter.tmp_prefix)) {
+ tmpTotal += FileUtil.calculateFileSize(oldFiles[i]);
}
- request.setAttribute("zipTotal", zipTotal / 1024);
- request.setAttribute("tmpTotal", tmpTotal / 1024);
-
- // set default numDays
- DynaActionForm dynaForm = (DynaActionForm)form;
- Integer numDays = (Integer)dynaForm.get("numDays");
- if (numDays == null) {
- dynaForm.set("numDays", new Integer(1));
- }
-
- return mapping.findForward("cleanup");
+ }
}
+ request.setAttribute("zipTotal", zipTotal / 1024);
+ request.setAttribute("tmpTotal", tmpTotal / 1024);
+ // set default numDays
+ DynaActionForm dynaForm = (DynaActionForm) form;
+ Integer numDays = (Integer) dynaForm.get("numDays");
+ if (numDays == null) {
+ dynaForm.set("numDays", new Integer(1));
+ }
+
+ return mapping.findForward("cleanup");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java
===================================================================
diff -u -r3cb7b834c427936f9909ebc2153d0e548967ec68 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (.../CloneLessonsAction.java) (revision 3cb7b834c427936f9909ebc2153d0e548967ec68)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (.../CloneLessonsAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -52,9 +52,9 @@
/**
* @author jliew
- *
+ *
* @struts:action path="/clone" scope="request" validate="false"
- *
+ *
* @struts:action-forward name="start" path=".clone-start"
* @struts:action-forward name="availableLessonsPart" path="/organisation/parts/availableLessons.jsp"
* @struts:action-forward name="selectStaffPart" path="/organisation/parts/selectStaff.jsp"
@@ -68,6 +68,7 @@
private static ILessonService lessonService;
private static IMonitoringService monitoringService;
+ @Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws UserAccessDeniedException {
@@ -117,8 +118,8 @@
OrganisationState.ACTIVE);
for (Object o : groups) {
Organisation org = (Organisation) o;
- response.getWriter().println(
- "" + org.getName() + " ");
+ response.getWriter()
+ .println("" + org.getName() + " ");
}
return null;
@@ -143,8 +144,8 @@
List groups = userManagementService.findByProperties(Organisation.class, properties);
for (Object o : groups) {
Organisation org = (Organisation) o;
- response.getWriter().println(
- "" + org.getName() + " ");
+ response.getWriter()
+ .println("" + org.getName() + " ");
}
}
@@ -220,8 +221,8 @@
Organisation group = (Organisation) userManagementService.findById(Organisation.class, groupId);
if (group != null) {
- result = monitoringService
- .cloneLessons(lessonIds, addAllStaff, addAllLearners, staffIds, learnerIds, group);
+ result = monitoringService.cloneLessons(lessonIds, addAllStaff, addAllLearners, staffIds, learnerIds,
+ group);
} else {
throw new UserException("Couldn't find Organisation based on id=" + groupId);
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java
===================================================================
diff -u -rb7008b95e3f3054ee6f3696a0579e34a197201ca -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java (.../ImportGroupsAction.java) (revision b7008b95e3f3054ee6f3696a0579e34a197201ca)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java (.../ImportGroupsAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -39,41 +39,40 @@
/**
* @author jliew
- *
+ *
* @struts:action path="/importgroups"
- * name="ImportGroupsForm"
- * scope="request"
- * validate="false"
- *
+ * name="ImportGroupsForm"
+ * scope="request"
+ * validate="false"
+ *
* @struts:action-forward name="importGroups" path=".importGroups"
* @struts:action-forward name="sysadmin" path="/sysadminstart.do"
*
*/
public class ImportGroupsAction extends Action {
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- if (isCancelled(request)) {
- return mapping.findForward("sysadmin");
- }
-
- IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
- ImportExcelForm importForm = (ImportExcelForm)form;
- importForm.setOrgId(0);
- FormFile file = importForm.getFile();
-
- // validation
- if (file==null || file.getFileSize()<=0) {
- return mapping.findForward("importGroups");
- }
-
- List results = importService.parseGroupSpreadsheet(file);
- request.setAttribute("results", results);
-
- return mapping.findForward("importGroups");
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ if (isCancelled(request)) {
+ return mapping.findForward("sysadmin");
}
+ IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
+ ImportExcelForm importForm = (ImportExcelForm) form;
+ importForm.setOrgId(0);
+ FormFile file = importForm.getFile();
+
+ // validation
+ if (file == null || file.getFileSize() <= 0) {
+ return mapping.findForward("importGroups");
+ }
+
+ List results = importService.parseGroupSpreadsheet(file);
+ request.setAttribute("results", results);
+
+ return mapping.findForward("importGroups");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java
===================================================================
diff -u -rbc455765c7c230d438318b1f62994420fe45db44 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java (.../ImportUserResultAction.java) (revision bc455765c7c230d438318b1f62994420fe45db44)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java (.../ImportUserResultAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -49,45 +49,45 @@
*/
public class ImportUserResultAction extends Action {
- private static Logger log = Logger.getLogger(ImportUserResultAction.class);
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- MessageService messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext());
- IImportService importService = AdminServiceProxy.getImportService(getServlet().getServletContext());
- HttpSession ss = SessionManager.getSession();
-
- List results = (List)ss.getAttribute(IImportService.IMPORT_RESULTS);
- String successMessageKey = "";
- try {
- FormFile file = (FormFile)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 groupMap = statisticsService.getGroupMap();
request.setAttribute("statisticsDTO", stats);
request.setAttribute("groupMap", groupMap);
return mapping.findForward("success");
}
- public ActionForward groupStats(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward groupStats(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
Integer orgId = WebUtil.readIntParam(request, "orgId");
// check permission
if (!request.isUserInRole(Role.SYSADMIN)) {
request.setAttribute("errorName", "RegisterAction");
- request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()).getMessage("error.authorisation"));
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
return mapping.findForward("error");
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java
===================================================================
diff -u -r5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision 5e39743e8bd500d0e121cf4c95b9c9fc77eb80fc)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -45,56 +45,54 @@
* @struts.action-forward name="sysadmin" path=".sysadmin"
*/
public class SysAdminStartAction extends Action {
-
- private static IUserManagementService service;
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
-
- ArrayList links = new ArrayList();
- if (request.isUserInRole(Role.SYSADMIN)) {
- LinkBean linkBean = new LinkBean("cache.do", "cache.title");
- links.add(linkBean);
- links.add(new LinkBean("cleanup.do", "sysadmin.batch.temp.file.delete"));
- links.add(new LinkBean("config.do", "sysadmin.config.settings.edit"));
- links.add(new LinkBean("toolcontentlist.do", "sysadmin.tool.management"));
- links.add(new LinkBean("usersearch.do", "admin.user.find"));
- links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
- links.add(new LinkBean("importexcel.do", "admin.user.import"));
- links.add(new LinkBean("ldap.do", "sysadmin.ldap.configuration"));
- links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
- links.add(new LinkBean("loginmaintain.do", "sysadmin.maintain.loginpage"));
- links.add(new LinkBean("serverlist.do", "sysadmin.maintain.external.servers"));
- links.add(new LinkBean("register.do", "sysadmin.register.server"));
- links.add(new LinkBean("statistics.do", "admin.statistics.title"));
- links.add(new LinkBean("signupManagement.do", "admin.signup.title"));
- links.add(new LinkBean("themeManagement.do", "admin.themes.title"));
- links.add(new LinkBean("timezonemanagement.do", "admin.timezone.title"));
-
- OpenIDConfig openIDEnabled = (OpenIDConfig)service.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
- if (openIDEnabled != null && Boolean.parseBoolean(openIDEnabled.getConfigValue()) == Boolean.TRUE) {
- links.add(new LinkBean("openIDConfig.do", "admin.openid.title"));
- }
- } else if (service.isUserGlobalGroupAdmin()) {
- LinkBean linkBean = new LinkBean("usersearch.do", "admin.user.find");
- links.add(linkBean);
- links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
- links.add(new LinkBean("importexcel.do", "admin.user.import"));
- links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
- } else {
- request.setAttribute("errorName", "SysAdminStartAction");
- request.setAttribute("errorMessage", AdminServiceProxy
- .getMessageService(getServlet().getServletContext())
- .getMessage("error.authorisation"));
- return mapping.findForward("error");
- }
-
- request.setAttribute("links", links);
- return mapping.findForward("sysadmin");
+
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+
+ ArrayList links = new ArrayList();
+ if (request.isUserInRole(Role.SYSADMIN)) {
+ LinkBean linkBean = new LinkBean("cache.do", "cache.title");
+ links.add(linkBean);
+ links.add(new LinkBean("cleanup.do", "sysadmin.batch.temp.file.delete"));
+ links.add(new LinkBean("config.do", "sysadmin.config.settings.edit"));
+ links.add(new LinkBean("toolcontentlist.do", "sysadmin.tool.management"));
+ links.add(new LinkBean("usersearch.do", "admin.user.find"));
+ links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
+ links.add(new LinkBean("importexcel.do", "admin.user.import"));
+ links.add(new LinkBean("ldap.do", "sysadmin.ldap.configuration"));
+ links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
+ links.add(new LinkBean("loginmaintain.do", "sysadmin.maintain.loginpage"));
+ links.add(new LinkBean("serverlist.do", "sysadmin.maintain.external.servers"));
+ links.add(new LinkBean("register.do", "sysadmin.register.server"));
+ links.add(new LinkBean("statistics.do", "admin.statistics.title"));
+ links.add(new LinkBean("signupManagement.do", "admin.signup.title"));
+ links.add(new LinkBean("themeManagement.do", "admin.themes.title"));
+ links.add(new LinkBean("timezonemanagement.do", "admin.timezone.title"));
+
+ OpenIDConfig openIDEnabled = (OpenIDConfig) service.findById(OpenIDConfig.class, OpenIDConfig.KEY_ENABLED);
+ if (openIDEnabled != null && Boolean.parseBoolean(openIDEnabled.getConfigValue()) == Boolean.TRUE) {
+ links.add(new LinkBean("openIDConfig.do", "admin.openid.title"));
+ }
+ } else if (service.isUserGlobalGroupAdmin()) {
+ LinkBean linkBean = new LinkBean("usersearch.do", "admin.user.find");
+ links.add(linkBean);
+ links.add(new LinkBean("importgroups.do", "sysadmin.import.groups.title"));
+ links.add(new LinkBean("importexcel.do", "admin.user.import"));
+ links.add(new LinkBean("disabledmanage.do", "admin.list.disabled.users"));
+ } else {
+ request.setAttribute("errorName", "SysAdminStartAction");
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
+ return mapping.findForward("error");
}
+ request.setAttribute("links", links);
+ return mapping.findForward("sysadmin");
+ }
+
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java
===================================================================
diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -32,23 +32,21 @@
import org.apache.struts.action.ActionMapping;
import org.lamsfoundation.lams.admin.service.AdminServiceProxy;
import org.lamsfoundation.lams.admin.web.form.ThemeForm;
-import org.lamsfoundation.lams.config.ConfigurationItem;
import org.lamsfoundation.lams.themes.Theme;
import org.lamsfoundation.lams.themes.service.IThemeService;
import org.lamsfoundation.lams.usermanagement.Role;
import org.lamsfoundation.lams.util.CSSThemeUtil;
import org.lamsfoundation.lams.util.Configuration;
import org.lamsfoundation.lams.util.ConfigurationKeys;
-import org.lamsfoundation.lams.util.MessageService;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
* @author Luke Foxton
- *
+ *
* Actions for maintaining and altering system themes
- *
+ *
* @struts.action path="/themeManagement" parameter="method" name="themeForm"
* input=".themeManagement" scope="request" validate="false"
* @struts.action-forward name="success" path=".themeManagement"
@@ -59,12 +57,15 @@
private static IThemeService themeService;
private static Configuration configurationService;
- public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ @Override
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
// check permission
if (!request.isUserInRole(Role.SYSADMIN)) {
request.setAttribute("errorName", "RegisterAction");
- request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext()).getMessage("error.authorisation"));
+ request.setAttribute("errorMessage", AdminServiceProxy.getMessageService(getServlet().getServletContext())
+ .getMessage("error.authorisation"));
return mapping.findForward("error");
}
@@ -85,7 +86,8 @@
}
theme.setNotEditable(Boolean.FALSE);
- if (theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME) || theme.getName().equals(CSSThemeUtil.DEFAULT_FLASH_THEME)) {
+ if (theme.getName().equals(CSSThemeUtil.DEFAULT_HTML_THEME)
+ || theme.getName().equals(CSSThemeUtil.DEFAULT_FLASH_THEME)) {
theme.setNotEditable(Boolean.TRUE);
}
}
@@ -94,10 +96,10 @@
return mapping.findForward("success");
}
- public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward addOrEditTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
ThemeForm themeForm = (ThemeForm) form;
-
// Update the theme
Theme theme = null;
if (themeForm.getId() != null && themeForm.getId() != 0) {
@@ -137,8 +139,9 @@
return unspecified(mapping, themeForm, request, response);
}
- public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
-
+ public ActionForward removeTheme(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
// Remove the theme
ThemeForm themeForm = (ThemeForm) form;
if (themeForm.getId() != null) {
@@ -164,7 +167,8 @@
return unspecified(mapping, themeForm, request, response);
}
- public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
+ public ActionForward setAsDefault(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
ThemeForm themeForm = (ThemeForm) form;
if (themeForm.getName() != null) {
Configuration.updateItem(ConfigurationKeys.DEFAULT_HTML_THEME, themeForm.getName());
@@ -184,7 +188,8 @@
private Configuration getConfiguration() {
if (configurationService == null) {
- WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServlet().getServletContext());
configurationService = (Configuration) ctx.getBean("configurationService");
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java
===================================================================
diff -u -r009fbce36f45d0929f8007c4bbc798242f57d3af -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java (.../TimezoneManagementAction.java) (revision 009fbce36f45d0929f8007c4bbc798242f57d3af)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java (.../TimezoneManagementAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -1,37 +1,35 @@
-/****************************************************************
- * 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
- * ****************************************************************
- */
-
-/* $$Id$$ */
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+
+/* $$Id$$ */
package org.lamsfoundation.lams.admin.web.action;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.TimeZone;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
@@ -45,40 +43,41 @@
/**
* Implements time zone manager.
- *
+ *
* @author Andrey Balan
- *
+ *
* @struts.action path="/timezonemanagement" parameter="method" name="TimezoneForm" input=".config" scope="request"
* validate="false"
* @struts.action-forward name="timezoneManagement" path=".timezoneManagement"
* @struts.action-forward name="timezoneServerManagement" path="/timezoneServerManagement.jsp"
* @struts.action-forward name="sysadmin" path="/sysadminstart.do"
*/
public class TimezoneManagementAction extends LamsDispatchAction {
-
+
private final static String FORWARD_BACK = "sysadmin";
private final static String FORWARD_TIMEZONE_MANAGEMENT = "timezoneManagement";
private final static String FORWARD_SERVER_TIMEZONE_MANAGEMENT = "timezoneServerManagement";
private static ITimezoneService timezoneService;
- /**
+ /**
* Displays list of all JRE available timezones.
*/
+ @Override
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
-
+
timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
List defaultTimezones = timezoneService.getDefaultTimezones();
-
+
ArrayList timezoneDtos = new ArrayList();
for (String availableTimezoneId : TimeZone.getAvailableIDs()) {
boolean isSelected = defaultTimezones.contains(new Timezone(availableTimezoneId));
TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, isSelected);
timezoneDtos.add(timezoneDto);
- }
-
+ }
+
request.setAttribute("timezoneDtos", timezoneDtos);
request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());
@@ -87,7 +86,7 @@
/**
* Makes selected timezones default ones.
- *
+ *
* @param mapping
* @param form
* @param request
@@ -104,7 +103,7 @@
DynaActionForm timezoneForm = (DynaActionForm) form;
String[] selectedTimezoneIds = (String[]) timezoneForm.get("selected");
-
+
List selectedTimezones = new ArrayList();
for (String selectedTimezoneId : selectedTimezoneIds) {
selectedTimezones.add(new Timezone(selectedTimezoneId));
@@ -113,10 +112,10 @@
return mapping.findForward(FORWARD_BACK);
}
-
+
/**
* Shows page where admin can choose server timezone.
- *
+ *
* @param mapping
* @param form
* @param request
@@ -134,31 +133,31 @@
TimeZone timeZone = TimeZone.getTimeZone(availableTimezoneId);
TimezoneDTO timezoneDto = TimezoneDTO.createTimezoneDTO(timeZone, false);
timezoneDtos.add(timezoneDto);
- }
-
+ }
+
request.setAttribute("timezoneDtos", timezoneDtos);
request.setAttribute("serverTimezone", timezoneService.getServerTimezone().getTimezoneId());
return mapping.findForward(FORWARD_SERVER_TIMEZONE_MANAGEMENT);
}
-
+
/**
* Changes server timezone with the one selected by user.
- *
+ *
* @param mapping
* @param form
* @param request
* @param response
* @return
- * @throws Exception
+ * @throws Exception
*/
public ActionForward changeServerTimezone(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
timezoneService = AdminServiceProxy.getTimezoneService(getServlet().getServletContext());
-
+
String timeZoneId = WebUtil.readStrParam(request, "timeZoneId");
timezoneService.setServerTimezone(timeZoneId);
-
+
return unspecified(mapping, form, request, response);
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserBasicListAction.java
===================================================================
diff -u -r36301c5c3e71d8a4b4ca4e8ef5f7901abadf4e5e -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserBasicListAction.java (.../UserBasicListAction.java) (revision 36301c5c3e71d8a4b4ca4e8ef5f7901abadf4e5e)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserBasicListAction.java (.../UserBasicListAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -18,11 +18,11 @@
*
* http://www.gnu.org/licenses/gpl.txt
* ****************************************************************
- */
-
-/* $Id$ */
-package org.lamsfoundation.lams.admin.web.action;
+ */
+/* $Id$ */
+package org.lamsfoundation.lams.admin.web.action;
+
import java.util.ArrayList;
import java.util.List;
@@ -44,7 +44,7 @@
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
-
+
/**
* @author jliew
*
@@ -53,60 +53,59 @@
* @struts:action-forward name="basiclist" path="/user/basiclist.jsp"
*/
public class UserBasicListAction extends Action {
-
- private static IUserManagementService service;
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- HttpSession session = SessionManager.getSession();
- if (session != null) {
- UserDTO userDto = (UserDTO)session.getAttribute(AttributeNames.USER);
- if (userDto != null) {
- // get inputs
- Integer userId = userDto.getUserID();
- Integer orgId = WebUtil.readIntParam(request, "orgId", true);
- String potential = WebUtil.readStrParam(request, "potential", true);
- if (orgId != null) {
- if (!StringUtils.equals(potential, "1")) {
- // list users in org
- List users = service.getUsersFromOrganisation(orgId);
- request.setAttribute("users", users);
- } else {
- // get all potential users of this org instead... filters results according to user's roles
- // get group
- Organisation org = (Organisation)service.findById(Organisation.class, orgId);
- Organisation group;
- if (org != null) {
- if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
- group = org.getParentOrganisation();
- } else {
- group = org;
- }
- // get users
- List users = new ArrayList();
- if (request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin()) {
- users = service.getAllUsers(org.getOrganisationId());
- } else if (service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_ADMIN)
- || service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_MANAGER)) {
- if (group.getCourseAdminCanBrowseAllUsers()){
- users = service.getAllUsers(org.getOrganisationId());
- } else if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
- users = service.getUsersFromOrganisation(group.getOrganisationId(), orgId);
- }
- }
- request.setAttribute("users", users);
- }
- }
+
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ HttpSession session = SessionManager.getSession();
+ if (session != null) {
+ UserDTO userDto = (UserDTO) session.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
+ // get inputs
+ Integer userId = userDto.getUserID();
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+ String potential = WebUtil.readStrParam(request, "potential", true);
+ if (orgId != null) {
+ if (!StringUtils.equals(potential, "1")) {
+ // list users in org
+ List users = service.getUsersFromOrganisation(orgId);
+ request.setAttribute("users", users);
+ } else {
+ // get all potential users of this org instead... filters results according to user's roles
+ // get group
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ Organisation group;
+ if (org != null) {
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ group = org.getParentOrganisation();
+ } else {
+ group = org;
+ }
+ // get users
+ List users = new ArrayList();
+ if (request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin()) {
+ users = service.getAllUsers(org.getOrganisationId());
+ } else if (service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_ADMIN)
+ || service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_MANAGER)) {
+ if (group.getCourseAdminCanBrowseAllUsers()) {
+ users = service.getAllUsers(org.getOrganisationId());
+ } else if (org.getOrganisationType().getOrganisationTypeId()
+ .equals(OrganisationType.CLASS_TYPE)) {
+ users = service.getUsersFromOrganisation(group.getOrganisationId(), orgId);
}
+ }
+ request.setAttribute("users", users);
}
+ }
}
-
- return mapping.findForward("basiclist");
+ }
}
+ return mapping.findForward("basiclist");
+ }
+
}
-
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java
===================================================================
diff -u -r6452b7bb53f1f0eb5a340fd488a733a9a6bd1415 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java (.../UserSearchSingleTermAction.java) (revision 6452b7bb53f1f0eb5a340fd488a733a9a6bd1415)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java (.../UserSearchSingleTermAction.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -18,11 +18,11 @@
*
* http://www.gnu.org/licenses/gpl.txt
* ****************************************************************
- */
-
-/* $Id$ */
-package org.lamsfoundation.lams.admin.web.action;
+ */
+/* $Id$ */
+package org.lamsfoundation.lams.admin.web.action;
+
import java.util.ArrayList;
import java.util.List;
@@ -44,66 +44,65 @@
import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
-
+
/**
* @author jliew
- *
+ *
* @struts:action path="/user/searchsingle" validate="false"
*
* @struts:action-forward name="basiclist" path="/user/basiclist.jsp"
*/
public class UserSearchSingleTermAction extends Action {
- private static IUserManagementService service;
-
- public ActionForward execute(ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response) throws Exception {
-
- service = AdminServiceProxy.getService(getServlet().getServletContext());
- String term = WebUtil.readStrParam(request, "term", true);
- Integer orgId = WebUtil.readIntParam(request, "orgId", true);
-
- if (StringUtils.isNotBlank(term)) {
- List users = new ArrayList();
- if (orgId != null) {
- // filter results according to user's roles
- Organisation org = (Organisation)service.findById(Organisation.class, orgId);
- Organisation group;
- if (org != null) {
- HttpSession session = SessionManager.getSession();
- if (session != null) {
- UserDTO userDto = (UserDTO)session.getAttribute(AttributeNames.USER);
- if (userDto != null) {
- Integer userId = userDto.getUserID();
- if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
- group = org.getParentOrganisation();
- } else {
- group = org;
- }
- // get search results, filtered according to orgId
- if (request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin()) {
- users = service.searchUserSingleTerm(term, orgId);
- } else if (service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_ADMIN)
- || service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_MANAGER)) {
- if (group.getCourseAdminCanBrowseAllUsers()){
- users = service.searchUserSingleTerm(term, orgId);
- } else if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
- users = service.searchUserSingleTerm(term, group.getOrganisationId(), orgId);
- }
- }
- }
- }
+ private static IUserManagementService service;
+
+ @Override
+ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ service = AdminServiceProxy.getService(getServlet().getServletContext());
+ String term = WebUtil.readStrParam(request, "term", true);
+ Integer orgId = WebUtil.readIntParam(request, "orgId", true);
+
+ if (StringUtils.isNotBlank(term)) {
+ List users = new ArrayList();
+ if (orgId != null) {
+ // filter results according to user's roles
+ Organisation org = (Organisation) service.findById(Organisation.class, orgId);
+ Organisation group;
+ if (org != null) {
+ HttpSession session = SessionManager.getSession();
+ if (session != null) {
+ UserDTO userDto = (UserDTO) session.getAttribute(AttributeNames.USER);
+ if (userDto != null) {
+ Integer userId = userDto.getUserID();
+ if (org.getOrganisationType().getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE)) {
+ group = org.getParentOrganisation();
+ } else {
+ group = org;
+ }
+ // get search results, filtered according to orgId
+ if (request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin()) {
+ users = service.searchUserSingleTerm(term, orgId);
+ } else if (service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_ADMIN)
+ || service.isUserInRole(userId, group.getOrganisationId(), Role.GROUP_MANAGER)) {
+ if (group.getCourseAdminCanBrowseAllUsers()) {
+ users = service.searchUserSingleTerm(term, orgId);
+ } else if (org.getOrganisationType().getOrganisationTypeId()
+ .equals(OrganisationType.CLASS_TYPE)) {
+ users = service.searchUserSingleTerm(term, group.getOrganisationId(), orgId);
}
- } else {
- // if there's no orgId param, search all users
- users = service.searchUserSingleTerm(term);
+ }
}
- request.setAttribute("users", users);
+ }
}
-
- return mapping.findForward("basiclist");
+ } else {
+ // if there's no orgId param, search all users
+ users = service.searchUserSingleTerm(term);
+ }
+ request.setAttribute("users", users);
}
+
+ return mapping.findForward("basiclist");
+ }
}
-
\ No newline at end of file
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/LinkBean.java
===================================================================
diff -u -r44f9636e4923ab01e51ff46d67b190caf4c93012 -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/LinkBean.java (.../LinkBean.java) (revision 44f9636e4923ab01e51ff46d67b190caf4c93012)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/LinkBean.java (.../LinkBean.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -25,27 +25,27 @@
public class LinkBean {
- private String link;
- private String name;
-
- public LinkBean(String link, String name) {
- this.link = link;
- this.name = name;
- }
-
- public String getLink() {
- return link;
- }
-
- public void setLink(String link) {
- this.link = link;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
+ private String link;
+ private String name;
+
+ public LinkBean(String link, String name) {
+ this.link = link;
+ this.name = name;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/UserOrgRoleDTO.java
===================================================================
diff -u -r83813a0305c0aac6ce942d61ce1ce3ccee5361ce -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/UserOrgRoleDTO.java (.../UserOrgRoleDTO.java) (revision 83813a0305c0aac6ce942d61ce1ce3ccee5361ce)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/UserOrgRoleDTO.java (.../UserOrgRoleDTO.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -31,31 +31,31 @@
*/
public class UserOrgRoleDTO {
- private String orgName;
- private List roles;
- private List childDTOs;
-
- public String getOrgName() {
- return orgName;
- }
-
- public void setOrgName(String orgName) {
- this.orgName = orgName;
- }
-
- public List getRoles() {
- return roles;
- }
-
- public void setRoles(List roles) {
- this.roles = roles;
- }
-
- public List getChildDTOs() {
- return childDTOs;
- }
-
- public void setChildDTOs(List childDTOs) {
- this.childDTOs = childDTOs;
- }
+ private String orgName;
+ private List roles;
+ private List childDTOs;
+
+ public String getOrgName() {
+ return orgName;
+ }
+
+ public void setOrgName(String orgName) {
+ this.orgName = orgName;
+ }
+
+ public List getRoles() {
+ return roles;
+ }
+
+ public void setRoles(List roles) {
+ this.roles = roles;
+ }
+
+ public List getChildDTOs() {
+ return childDTOs;
+ }
+
+ public void setChildDTOs(List childDTOs) {
+ this.childDTOs = childDTOs;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java
===================================================================
diff -u -r7ab9e2377fd1ff4c3c5554bd1f6dffe3384f6f9a -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision 7ab9e2377fd1ff4c3c5554bd1f6dffe3384f6f9a)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -30,68 +30,68 @@
/**
* @version
*
- *
- * View Source
- *
+ *
+ * View Source
+ *
*
* @author Fei Yang
*
- * Created at 20:56:24 on 2006-6-5
- *
+ * Created at 20:56:24 on 2006-6-5
+ *
* @struts.form name="OrgManageForm"
*/
public class OrgManageForm extends ActionForm {
- private static final long serialVersionUID = -3960695533993640297L;
+ private static final long serialVersionUID = -3960695533993640297L;
- private List orgManageBeans;
-
- private Integer type;
-
- private Integer parentId;
-
- private String parentName;
-
- private Integer stateId;
+ private List orgManageBeans;
- public Integer getStateId() {
- return stateId;
- }
-
- public void setStateId(Integer stateId) {
- this.stateId = stateId;
- }
-
- public Integer getType() {
- return type;
- }
+ private Integer type;
- public void setType(Integer type) {
- this.type = type;
- }
+ private Integer parentId;
- public List getOrgManageBeans() {
- return orgManageBeans;
- }
+ private String parentName;
- public void setOrgManageBeans(List orgManageBeans) {
- this.orgManageBeans = orgManageBeans;
- }
+ private Integer stateId;
- public Integer getParentId() {
- return parentId;
- }
+ public Integer getStateId() {
+ return stateId;
+ }
- public void setParentId(Integer parentId) {
- this.parentId = parentId;
- }
+ public void setStateId(Integer stateId) {
+ this.stateId = stateId;
+ }
- public String getParentName() {
- return parentName;
- }
+ public Integer getType() {
+ return type;
+ }
- public void setParentName(String parentName) {
- this.parentName = parentName;
- }
+ public void setType(Integer type) {
+ this.type = type;
+ }
+
+ public List getOrgManageBeans() {
+ return orgManageBeans;
+ }
+
+ public void setOrgManageBeans(List orgManageBeans) {
+ this.orgManageBeans = orgManageBeans;
+ }
+
+ public Integer getParentId() {
+ return parentId;
+ }
+
+ public void setParentId(Integer parentId) {
+ this.parentId = parentId;
+ }
+
+ public String getParentName() {
+ return parentName;
+ }
+
+ public void setParentName(String parentName) {
+ this.parentName = parentName;
+ }
}
Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java
===================================================================
diff -u -r7998a31f6d7d4f1eef3e866bafef22caa012eb7a -r45dd45991655ace968c10e54e3e0d641882e52f5
--- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 7998a31f6d7d4f1eef3e866bafef22caa012eb7a)
+++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 45dd45991655ace968c10e54e3e0d641882e52f5)
@@ -2,21 +2,21 @@
* 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
+ * 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
* ****************************************************************
*/
@@ -25,19 +25,20 @@
import org.apache.struts.action.ActionForm;
/**
- *
+ *
* Form for theme management
- *
+ *
* @author lfoxton
- *
+ *
* @struts.form name="themeForm"
*/
public class ThemeForm extends ActionForm {
private static final long serialVersionUID = -3127221000563399156L;
-
- public ThemeForm() {}
-
+
+ public ThemeForm() {
+ }
+
private String method;
private Long id;
private String name;
@@ -47,47 +48,61 @@
private String type;
public String getMethod() {
- return method;
+ return method;
}
+
public void setMethod(String method) {
- this.method = method;
+ this.method = method;
}
+
public Long getId() {
- return id;
+ return id;
}
+
public void setId(Long id) {
- this.id = id;
+ this.id = id;
}
+
public String getName() {
- return name;
+ return name;
}
+
public void setName(String name) {
- this.name = name;
+ this.name = name;
}
+
public String getDescription() {
- return description;
+ return description;
}
+
public void setDescription(String description) {
- this.description = description;
+ this.description = description;
}
+
public String getImageDirectory() {
- return imageDirectory;
+ return imageDirectory;
}
+
public void setImageDirectory(String imageDirectory) {
- this.imageDirectory = imageDirectory;
+ this.imageDirectory = imageDirectory;
}
+
public Boolean getCurrentDefaultTheme() {
- return currentDefaultTheme;
+ return currentDefaultTheme;
}
+
public void setCurrentDefaultTheme(Boolean currentDefaultTheme) {
- this.currentDefaultTheme = currentDefaultTheme;
+ this.currentDefaultTheme = currentDefaultTheme;
}
+
public String getType() {
- return type;
+ return type;
}
+
public void setType(String type) {
- this.type = type;
+ this.type = type;
}
+
public void clear() {
this.method = null;
this.id = null;
@@ -98,4 +113,3 @@
this.type = null;
}
}
-