Index: lams_admin/src/java/org/lamsfoundation/lams/admin/AdminConstants.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r4ab4ba6ef63a831648ca63ca4d91edd4c0fba55f -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision 4ab4ba6ef63a831648ca63ca4d91edd4c0fba55f) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java (.../AdminServiceProxy.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r3dbf966d900adefc34cdad501d3c392118451cd9 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 3dbf966d900adefc34cdad501d3c392118451cd9) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -62,7 +62,7 @@ *

* View Source *

- * + * * @author Fei Yang * @author Jun-Dir Liew */ Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (.../ConfigAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ConfigAction.java (.../ConfigAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,101 +43,97 @@ */ /** * struts doclets - * * * * * + * */ 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]); + + if (item != null) { + // return to ldap page if that's where we came from + if (StringUtils.contains(item.getHeaderName(), "config.header.ldap")) { + errorForward = "ldap"; } - - 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]); - } + + 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); + } } - getConfiguration().persistUpdate(); - - return mapping.findForward("sysadmin"); + 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]); + } } - - 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/DisabledUserManageAction.java (.../DisabledUserManageAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/DisabledUserManageAction.java (.../DisabledUserManageAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -41,35 +41,33 @@ /** * @author jliew - * + * * * * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelAction.java (.../ImportExcelAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelAction.java (.../ImportExcelAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -39,23 +39,22 @@ * * * - * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelForm.java (.../ImportExcelForm.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelForm.java (.../ImportExcelForm.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -32,24 +32,24 @@ * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelSaveAction.java (.../ImportExcelSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ImportExcelSaveAction.java (.../ImportExcelSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -45,63 +45,64 @@ * * * - * * * * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginMaintainAction.java (.../LoginMaintainAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginMaintainAction.java (.../LoginMaintainAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * * - * * - * + * + * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java (.../LoginSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/LoginSaveAction.java (.../LoginSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * - * "method" scope = "request" input = ".loginmaintian" validate = - * "false" - * * + * "method" scope = "request" input = ".loginmaintian" validate = + * "false" * + * + * */ 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/OrgManageAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java (.../OrgManageAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageAction.java (.../OrgManageAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 * **************************************************************** */ @@ -60,21 +60,21 @@ *

* * @author Fei Yang - * * * * + * */ 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) { @@ -155,14 +155,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"); @@ -192,7 +192,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"; @@ -211,11 +211,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); @@ -225,10 +225,11 @@ res.getWriter().print(new String(responcedata.toString())); return null; } - + private void initServices() { if (userManagementService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getWebApplicationContext(getServlet().getServletContext()); userManagementService = (UserManagementService) ctx.getBean("userManagementService"); } } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgManageBean.java =================================================================== diff -u -ra961e120b9299bd497d18a4a9ee9163882c0a217 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgSaveAction.java (.../OrgSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrgSaveAction.java (.../OrgSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,7 +68,6 @@ /** * struts doclets - * * * * @@ -80,174 +77,189 @@ * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrganisationAction.java (.../OrganisationAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/OrganisationAction.java (.../OrganisationAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,10 +54,10 @@ * @author Fei Yang * * - * * * * + * */ public class OrganisationAction extends LamsDispatchAction { @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterAction.java (.../RegisterAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,11 +57,9 @@ 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 */ @@ -82,6 +81,7 @@ private static IUserManagementService userManagementService; private Configuration configurationService; + @Override public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -99,21 +99,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())); @@ -129,7 +128,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"); @@ -155,7 +154,7 @@ registerForm.setSiteName(reg.getSiteName()); registerForm.setOrganisation(reg.getOrganisation()); registerForm.setServerCountry(reg.getServerCountry()); - + registerForm.setPublicDirectory(reg.isPublicDirectory()); registerForm.setEnableLamsCommunityIntegration(reg.isEnableLamsCommunityIntegration()); } @@ -178,15 +177,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(); @@ -196,18 +195,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, @@ -228,28 +225,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"); } } @@ -259,29 +250,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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterForm.java (.../RegisterForm.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/RegisterForm.java (.../RegisterForm.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobListAction.java (.../ScheduledJobListAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ScheduledJobListAction.java (.../ScheduledJobListAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 * **************************************************************** */ @@ -47,13 +47,13 @@ import org.springframework.web.context.support.WebApplicationContextUtils; /** - * + * * @author Steve.Ni * @version $Revision$ - * * - * * + * + * */ public class ScheduledJobListAction extends Action { @@ -62,7 +62,7 @@ /** * 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 @@ -76,15 +76,15 @@ * if an input/output error occurs * @exception ServletException * if a servlet exception occurs - * + * */ @SuppressWarnings("unchecked") @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getWebApplicationContext(this.getServlet().getServletContext()); Scheduler scheduler = (Scheduler) ctx.getBean("scheduler"); ArrayList jobList = new ArrayList(); try { Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java (.../ServerListAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerListAction.java (.../ServerListAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * - * * + * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerMaintainAction.java (.../ServerMaintainAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerMaintainAction.java (.../ServerMaintainAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerSaveAction.java (.../ServerSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ServerSaveAction.java (.../ServerSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,18 +58,19 @@ *

* View Source *

- * + * * @author Fei Yang - * * * + * */ public class ServerSaveAction extends Action { private static IIntegrationService service; 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/ToolContentListAction.java (.../ToolContentListAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -63,12 +63,12 @@ /** * @author jliew - * * - * * * * + * + * */ public class ToolContentListAction extends Action { @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java (.../UserAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,18 +65,18 @@ /** * @author Jun-Dir Liew - * + * * Created at 17:00:18 on 13/06/2006 */ /** * - * * * * * * + * */ public class UserAction extends LamsDispatchAction { Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserBean.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserManageAction.java (.../UserManageAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserManageAction.java (.../UserManageAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,17 +56,18 @@ /** * struts doclets - * * * * + * */ public class UserManageAction extends Action { private static final Logger log = Logger.getLogger(UserManageAction.class); 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (.../UserOrgAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgAction.java (.../UserOrgAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,60 +46,59 @@ /** * struts doclets - * * * * * * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRoleAction.java (.../UserOrgRoleAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgRoleAction.java (.../UserOrgRoleAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -46,74 +46,76 @@ /** * @author jliew - * + * * Called when a user has added users to an organisation. * */ /** * struts doclets - * * * * * * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgSaveAction.java (.../UserOrgSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserOrgSaveAction.java (.../UserOrgSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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,18 +54,19 @@ /** * struts doclets - * * - * * * + * + * */ public class UserOrgSaveAction extends Action { private static Logger log = Logger.getLogger(UserOrgSaveAction.class); 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesAction.java (.../UserRolesAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesAction.java (.../UserRolesAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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; @@ -59,102 +58,106 @@ * * * - * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesSaveAction.java (.../UserRolesSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserRolesSaveAction.java (.../UserRolesSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -54,55 +54,56 @@ * * * - * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java (.../UserSaveAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 * **************************************************************** */ @@ -51,19 +51,19 @@ /** * @author Jun-Dir Liew - * + * * Created at 12:35:38 on 14/06/2006 */ /** * struts doclets - * * - * * * * * + * + * */ public class UserSaveAction extends Action { @@ -178,8 +178,7 @@ user.setLocale(locale); user.setAuthenticationMethod(authenticationMethod); - Theme cssTheme = (Theme) UserSaveAction.service.findById(Theme.class, - (Long) userForm.get("userTheme")); + Theme cssTheme = (Theme) UserSaveAction.service.findById(Theme.class, (Long) userForm.get("userTheme")); user.setTheme(cssTheme); UserSaveAction.service.save(user); Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java (.../UserSearchAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSearchAction.java (.../UserSearchAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -49,17 +49,18 @@ /** * @author jliew - * * * * + * */ public class UserSearchAction extends LamsDispatchAction { private static Logger log = Logger.getLogger(UserSearchAction.class); 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (.../CleanupTempFilesAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CleanupTempFilesAction.java (.../CleanupTempFilesAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -51,90 +51,86 @@ * * * - * * * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (.../CloneLessonsAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/CloneLessonsAction.java (.../CloneLessonsAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -52,14 +52,14 @@ /** * @author jliew - * * - * * * * * * + * + * */ public class CloneLessonsAction extends Action { Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java (.../ImportGroupsAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportGroupsAction.java (.../ImportGroupsAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -39,41 +39,40 @@ /** * @author jliew - * * * * * - * * * * + * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java (.../ImportUserResultAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ImportUserResultAction.java (.../ImportUserResultAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java (.../SysAdminStartAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -44,49 +44,47 @@ * */ 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)) { - 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")); - } 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)) { + 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")); + } 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java (.../ThemeManagementAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 * **************************************************************** */ @@ -44,13 +44,13 @@ /** * @author Luke Foxton - * + * * Actions for maintaining and altering system themes - * * * * * + * */ public class ThemeManagementAction extends LamsDispatchAction { Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java (.../TimezoneManagementAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/TimezoneManagementAction.java (.../TimezoneManagementAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * * * * * + * */ 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/UserSearchSingleTermAction.java =================================================================== diff -u -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java (.../UserSearchSingleTermAction.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/UserSearchSingleTermAction.java (.../UserSearchSingleTermAction.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -47,10 +47,10 @@ /** * @author jliew - * * * * + * */ public class UserSearchSingleTermAction extends Action { Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/dto/LinkBean.java =================================================================== diff -u -r44f9636e4923ab01e51ff46d67b190caf4c93012 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- 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 c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/OrgManageForm.java (.../OrgManageForm.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 * + * */ 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 -r365dc9ce7505993afafc7afd82a6c6072dc27560 -rc92ea51a973dc03ece970c057dd9369eda6a8c24 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision 365dc9ce7505993afafc7afd82a6c6072dc27560) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java (.../ThemeForm.java) (revision c92ea51a973dc03ece970c057dd9369eda6a8c24) @@ -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 - * * + * */ 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; } } -