Index: lams_admin/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources.properties,v diff -u -r1.52.2.4.2.3 -r1.52.2.4.2.4 --- lams_admin/conf/language/lams/ApplicationResources.properties 19 Feb 2010 04:56:33 -0000 1.52.2.4.2.3 +++ lams_admin/conf/language/lams/ApplicationResources.properties 1 Mar 2010 04:56:25 -0000 1.52.2.4.2.4 @@ -415,6 +415,24 @@ sysadmin.userinfoUrl =User Information URL table.heading.organisation.id =Organisation ID title.job.list =Jobs +admin.themes.title =Theme Management +admin.themes.theme =Theme +admin.themes.description =Description +admin.themes.imageDir =CSS image directory +admin.themes.defaultTheme =Current default theme +admin.themes.remove =Remove +admin.themes.edit =Edit +admin.themes.addNew =Add/Edit theme +admin.themes.name =Name +admin.themes.makeThemeDefault =Make this theme the server default +admin.themes.makeDefault =Make default +admin.themes.deleteConfirm =Are you sure you want to delete this theme? +admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. +admin.themes.type =Type +admin.themes.html =HTML +admin.themes.flash =Flash +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 409 labels for en AU ===== Index: lams_admin/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.52.2.4.2.3 -r1.52.2.4.2.4 --- lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 19 Feb 2010 04:56:33 -0000 1.52.2.4.2.3 +++ lams_admin/conf/language/lams/ApplicationResources_en_AU.properties 1 Mar 2010 04:56:25 -0000 1.52.2.4.2.4 @@ -416,5 +416,23 @@ table.heading.organisation.id =Organisation ID title.job.list =Jobs +admin.themes.title =Theme Management +admin.themes.theme =Theme +admin.themes.description =Description +admin.themes.imageDir =CSS image directory +admin.themes.defaultTheme =Current default theme +admin.themes.remove =Remove +admin.themes.edit =Edit +admin.themes.addNew =Add/Edit theme +admin.themes.name =Name +admin.themes.makeThemeDefault =Make this theme the server default +admin.themes.makeDefault =Make default +admin.themes.deleteConfirm =Are you sure you want to delete this theme? +admin.themes.nameAlreadyExists =Please enter a new unused theme name, or click the edit icon to edit. +admin.themes.type =Type +admin.themes.html =HTML +admin.themes.flash =Flash +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 409 labels for en AU ===== Index: lams_admin/conf/xdoclet/struts-forms.xml =================================================================== RCS file: /usr/local/cvsroot/lams_admin/conf/xdoclet/struts-forms.xml,v diff -u -r1.31.2.1 -r1.31.2.1.2.1 --- lams_admin/conf/xdoclet/struts-forms.xml 3 Jun 2009 06:36:50 -0000 1.31.2.1 +++ lams_admin/conf/xdoclet/struts-forms.xml 1 Mar 2010 04:56:25 -0000 1.31.2.1.2.1 @@ -44,6 +44,8 @@ + + Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java,v diff -u -r1.7 -r1.7.8.1 --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java 17 Mar 2009 06:10:31 -0000 1.7 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/AdminServiceProxy.java 1 Mar 2010 04:56:25 -0000 1.7.8.1 @@ -26,6 +26,7 @@ import javax.servlet.ServletContext; import org.lamsfoundation.lams.integration.service.IIntegrationService; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; import org.lamsfoundation.lams.usermanagement.service.LdapService; import org.lamsfoundation.lams.util.MessageService; @@ -46,6 +47,7 @@ private static IAuditService auditService; private static IImportService importService; private static LdapService ldapService; + private static IThemeService themeService; public static final IUserManagementService getService(ServletContext servletContext) { if (manageService == null) { @@ -94,4 +96,11 @@ WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); return wac.getBean(serviceName); } + + public static final IThemeService getThemeService(ServletContext servletContext) { + if (themeService == null) { + themeService = (IThemeService)getDomainService(servletContext, "themeService"); + } + return themeService; + } } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java,v diff -u -r1.11 -r1.11.10.1 --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java 9 Jan 2008 04:19:53 -0000 1.11 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java 1 Mar 2010 04:56:25 -0000 1.11.10.1 @@ -46,7 +46,7 @@ import org.lamsfoundation.lams.admin.web.dto.V1OrgRightDTO; import org.lamsfoundation.lams.admin.web.dto.V1OrganisationDTO; import org.lamsfoundation.lams.admin.web.dto.V1UserDTO; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; @@ -657,7 +657,7 @@ } String flashId = parseStringCell(row.getCell(FLASH_THEME)); - CSSThemeVisualElement flashTheme = getFlashTheme(flashId); + Theme flashTheme = getFlashTheme(flashId); if (flashTheme==null) { args[0] = "("+flashId+")"; rowResult.add(messageService.getMessage("error.flash.theme.invalid", args)); @@ -667,7 +667,7 @@ } String htmlId = parseStringCell(row.getCell(HTML_THEME)); - CSSThemeVisualElement htmlTheme = getHtmlTheme(htmlId); + Theme htmlTheme = getHtmlTheme(htmlId); if (htmlTheme==null) { args[0] = "("+htmlId+")"; rowResult.add(messageService.getMessage("error.html.theme.invalid", args)); @@ -849,25 +849,25 @@ } // set CSSThemeVisualElement to default flash theme if cell is empty - private CSSThemeVisualElement getFlashTheme(String flashId){ + private Theme getFlashTheme(String flashId){ if (flashId==null || flashId=="") { return service.getDefaultFlashTheme(); } else { try { - return (CSSThemeVisualElement)service.findById(CSSThemeVisualElement.class, new Long(flashId)); + return (Theme)service.findById(Theme.class, new Long(flashId)); } catch (Exception e) { return null; } } } // set CSSThemeVisualElement to default html theme if cell is empty - private CSSThemeVisualElement getHtmlTheme(String htmlId){ + private Theme getHtmlTheme(String htmlId){ if (htmlId==null || htmlId=="") { return service.getDefaultHtmlTheme(); } else { try { - return (CSSThemeVisualElement)service.findById(CSSThemeVisualElement.class, new Long(htmlId)); + return (Theme)service.findById(Theme.class, new Long(htmlId)); } catch (Exception e) { return null; } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java,v diff -u -r1.48 -r1.48.10.1 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java 4 Oct 2008 03:37:34 -0000 1.48 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserAction.java 1 Mar 2010 04:56:25 -0000 1.48.10.1 @@ -40,6 +40,8 @@ import org.lamsfoundation.lams.admin.AdminConstants; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; import org.lamsfoundation.lams.admin.web.dto.UserOrgRoleDTO; +import org.lamsfoundation.lams.themes.Theme; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationState; @@ -62,7 +64,8 @@ */ /** - * @struts:action path="/user" name="UserForm" scope="request" parameter="method" validate="false" + * @struts:action path="/user" name="UserForm" scope="request" + * parameter="method" validate="false" * * @struts:action-forward name="user" path=".user" * @struts:action-forward name="userlist" path="/usermanage.do" @@ -72,262 +75,321 @@ */ public class UserAction extends LamsDispatchAction { - private static Logger log = Logger.getLogger(UserAction.class); - private IUserManagementService service; - private MessageService messageService; - private static List locales; - private static List authenticationMethods; + private static Logger log = Logger.getLogger(UserAction.class); + private IUserManagementService service; + private MessageService messageService; + private static IThemeService themeService; + private static List locales; + private static List authenticationMethods; - private void initServices() { - if (service == null) { - service = AdminServiceProxy.getService(getServlet().getServletContext()); + private void initServices() { + if (service == null) { + service = AdminServiceProxy.getService(getServlet().getServletContext()); + } + if (messageService == null) { + messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext()); + } + if (themeService == null) { + themeService = AdminServiceProxy.getThemeService(getServlet().getServletContext()); + } } - if (messageService == null) { - messageService = AdminServiceProxy.getMessageService(getServlet().getServletContext()); - } - } - public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - initServices(); - if (UserAction.locales == null) { - UserAction.locales = service.findAll(SupportedLocale.class); - Collections.sort(UserAction.locales); - } - if (UserAction.authenticationMethods == null) { - UserAction.authenticationMethods = service.findAll(AuthenticationMethod.class); - } + initServices(); + if (UserAction.locales == null) { + UserAction.locales = service.findAll(SupportedLocale.class); + Collections.sort(UserAction.locales); + } + if (UserAction.authenticationMethods == null) { + UserAction.authenticationMethods = service.findAll(AuthenticationMethod.class); + } - DynaActionForm userForm = (DynaActionForm) form; - Integer orgId = WebUtil.readIntParam(request, "orgId", true); - Integer userId = WebUtil.readIntParam(request, "userId", true); + DynaActionForm userForm = (DynaActionForm) form; + Integer orgId = WebUtil.readIntParam(request, "orgId", true); + Integer userId = WebUtil.readIntParam(request, "userId", true); - // test requestor's permission - Organisation org = null; - Boolean canEdit = service.isUserGlobalGroupAdmin(); - if (orgId != null) { - org = (Organisation) service.findById(Organisation.class, orgId); - if (!canEdit) { - OrganisationType orgType = org.getOrganisationType(); - Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE) ? org - .getParentOrganisation().getOrganisationId() : orgId; - User requestor = service.getUserByLogin(request.getRemoteUser()); - if (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN) - || service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)) { - Organisation course = (Organisation) service.findById(Organisation.class, orgIdOfCourse); - canEdit = course.getCourseAdminCanAddNewUsers(); + // Get all the css and flash themes themes + List cssThemes = themeService.getAllCSSThemes(); + request.setAttribute("cssThemes", cssThemes); + List flashThemes = themeService.getAllFlashThemes(); + request.setAttribute("flashThemes", flashThemes); + + // Select the default themes by default + Theme defaultCSSTheme = themeService.getDefaultCSSTheme(); + for (Theme theme : cssThemes) { + if (theme.getThemeId().equals(defaultCSSTheme.getThemeId())) { + userForm.set("userCSSTheme", theme.getThemeId()); + break; + } } - } - } + Theme defaultFlashTheme = themeService.getDefaultFlashTheme(); + for (Theme theme : flashThemes) { + if (theme.getThemeId().equals(defaultFlashTheme.getThemeId())) { + userForm.set("userFlashTheme", theme.getThemeId()); + break; + } + } - if (!(canEdit || request.isUserInRole(Role.SYSADMIN))) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); - return mapping.findForward("error"); - } + // test requestor's permission + Organisation org = null; + Boolean canEdit = service.isUserGlobalGroupAdmin(); + if (orgId != null) { + org = (Organisation) service.findById(Organisation.class, orgId); + if (!canEdit) { + OrganisationType orgType = org.getOrganisationType(); + Integer orgIdOfCourse = orgType.getOrganisationTypeId().equals(OrganisationType.CLASS_TYPE) ? org + .getParentOrganisation().getOrganisationId() : orgId; + User requestor = service.getUserByLogin(request.getRemoteUser()); + if (service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_ADMIN) + || service.isUserInRole(requestor.getUserId(), orgIdOfCourse, Role.GROUP_MANAGER)) { + Organisation course = (Organisation) service.findById(Organisation.class, orgIdOfCourse); + canEdit = course.getCourseAdminCanAddNewUsers(); + } + } + } - // editing a user - if (userId != null && userId != 0) { - User user = (User) service.findById(User.class, userId); - UserAction.log.debug("got userid to edit: " + userId); - BeanUtils.copyProperties(userForm, user); - userForm.set("password", null); - SupportedLocale locale = user.getLocale(); - userForm.set("localeId", locale.getLocaleId()); + if (!(canEdit || request.isUserInRole(Role.SYSADMIN))) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); + return mapping.findForward("error"); + } - AuthenticationMethod authenticationMethod = user.getAuthenticationMethod(); - userForm.set("authenticationMethodId", authenticationMethod.getAuthenticationMethodId()); - // set user's organisations to display - request.setAttribute("userOrgRoles", getUserOrgRoles(user)); - request.setAttribute("globalRoles", getGlobalRoles(user)); - } else { // create a user - try { - SupportedLocale locale = LanguageUtil.getDefaultLocale(); - userForm.set("localeId", locale.getLocaleId()); - } catch (Exception e) { - UserAction.log.debug(e); - } - } - userForm.set("orgId", (org == null ? null : org.getOrganisationId())); + // editing a user + if (userId != null && userId != 0) { + User user = (User) service.findById(User.class, userId); + UserAction.log.debug("got userid to edit: " + userId); + BeanUtils.copyProperties(userForm, user); + userForm.set("password", null); + SupportedLocale locale = user.getLocale(); + userForm.set("localeId", locale.getLocaleId()); - // for breadcrumb links - if (org != null) { - 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()); - } - } + AuthenticationMethod authenticationMethod = user.getAuthenticationMethod(); + userForm.set("authenticationMethodId", authenticationMethod.getAuthenticationMethodId()); + // set user's organisations to display + request.setAttribute("userOrgRoles", getUserOrgRoles(user)); + request.setAttribute("globalRoles", getGlobalRoles(user)); - request.setAttribute("locales", UserAction.locales); - request.setAttribute("authenticationMethods", UserAction.authenticationMethods); + // Check the user css theme is still installed + Long userSelectedCSSTheme = null; + if (user.getHtmlTheme() != null) { + for (Theme theme : cssThemes) { + if (theme.getThemeId() == user.getHtmlTheme().getThemeId()) { + userSelectedCSSTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedCSSTheme == null) { + userSelectedCSSTheme = themeService.getDefaultCSSTheme().getThemeId(); + } + userForm.set("userCSSTheme", userSelectedCSSTheme); - return mapping.findForward("user"); - } + // Check the user flash theme is still installed + Long userSelectedFlashTheme = null; + if (user.getHtmlTheme() != null) { + for (Theme theme : flashThemes) { + if (theme.getThemeId() == user.getFlashTheme().getThemeId()) { + userSelectedFlashTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedFlashTheme == null) { + userSelectedFlashTheme = themeService.getDefaultFlashTheme().getThemeId(); + } + userForm.set("userFlashTheme", userSelectedFlashTheme); - // display user's global roles, if any - private UserOrgRoleDTO getGlobalRoles(User user) { - initServices(); - UserOrganisation uo = service.getUserOrganisation(user.getUserId(), service.getRootOrganisation() - .getOrganisationId()); - if (uo == null) { - return null; - } - UserOrgRoleDTO uorDTO = new UserOrgRoleDTO(); - List roles = new ArrayList(); - for (Object uor : uo.getUserOrganisationRoles()) { - roles.add(((UserOrganisationRole) uor).getRole().getName()); - } - Collections.sort(roles); - uorDTO.setOrgName(uo.getOrganisation().getName()); - uorDTO.setRoles(roles); - return uorDTO; - } + } else { // create a user + try { + SupportedLocale locale = LanguageUtil.getDefaultLocale(); + userForm.set("localeId", locale.getLocaleId()); + } catch (Exception e) { + UserAction.log.debug(e); + } + } + userForm.set("orgId", (org == null ? null : org.getOrganisationId())); - // display user's organisations and roles in them - private List getUserOrgRoles(User user) { + // for breadcrumb links + if (org != null) { + 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()); + } + } - initServices(); - List uorDTOs = new ArrayList(); - List uos = service.getUserOrganisationsForUserByTypeAndStatus(user.getLogin(), - OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE); - for (UserOrganisation uo : uos) { - UserOrgRoleDTO uorDTO = new UserOrgRoleDTO(); - List roles = new ArrayList(); - for (Object uor : uo.getUserOrganisationRoles()) { - roles.add(((UserOrganisationRole) uor).getRole().getName()); - } - Collections.sort(roles); - uorDTO.setOrgName(uo.getOrganisation().getName()); - uorDTO.setRoles(roles); - List childDTOs = new ArrayList(); - List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(user - .getLogin(), OrganisationType.CLASS_TYPE, OrganisationState.ACTIVE, uo.getOrganisation() - .getOrganisationId()); - for (UserOrganisation childuo : childuos) { - UserOrgRoleDTO childDTO = new UserOrgRoleDTO(); - List childroles = new ArrayList(); - for (Object uor : childuo.getUserOrganisationRoles()) { - childroles.add(((UserOrganisationRole) uor).getRole().getName()); + request.setAttribute("locales", UserAction.locales); + request.setAttribute("authenticationMethods", UserAction.authenticationMethods); + + return mapping.findForward("user"); + } + + // display user's global roles, if any + private UserOrgRoleDTO getGlobalRoles(User user) { + initServices(); + UserOrganisation uo = service.getUserOrganisation(user.getUserId(), service.getRootOrganisation() + .getOrganisationId()); + if (uo == null) { + return null; } - Collections.sort(childroles); - childDTO.setOrgName(childuo.getOrganisation().getName()); - childDTO.setRoles(childroles); - childDTOs.add(childDTO); - } - uorDTO.setChildDTOs(childDTOs); - uorDTOs.add(uorDTO); + UserOrgRoleDTO uorDTO = new UserOrgRoleDTO(); + List roles = new ArrayList(); + for (Object uor : uo.getUserOrganisationRoles()) { + roles.add(((UserOrganisationRole) uor).getRole().getName()); + } + Collections.sort(roles); + uorDTO.setOrgName(uo.getOrganisation().getName()); + uorDTO.setRoles(roles); + return uorDTO; } - return uorDTOs; - } + // display user's organisations and roles in them + private List getUserOrgRoles(User user) { - // determine whether to disable or delete user based on their lams data - public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + initServices(); + List uorDTOs = new ArrayList(); + List uos = service.getUserOrganisationsForUserByTypeAndStatus(user.getLogin(), + OrganisationType.COURSE_TYPE, OrganisationState.ACTIVE); + for (UserOrganisation uo : uos) { + UserOrgRoleDTO uorDTO = new UserOrgRoleDTO(); + List roles = new ArrayList(); + for (Object uor : uo.getUserOrganisationRoles()) { + roles.add(((UserOrganisationRole) uor).getRole().getName()); + } + Collections.sort(roles); + uorDTO.setOrgName(uo.getOrganisation().getName()); + uorDTO.setRoles(roles); + List childDTOs = new ArrayList(); + List childuos = service.getUserOrganisationsForUserByTypeAndStatusAndParent(user + .getLogin(), OrganisationType.CLASS_TYPE, OrganisationState.ACTIVE, uo.getOrganisation() + .getOrganisationId()); + for (UserOrganisation childuo : childuos) { + UserOrgRoleDTO childDTO = new UserOrgRoleDTO(); + List childroles = new ArrayList(); + for (Object uor : childuo.getUserOrganisationRoles()) { + childroles.add(((UserOrganisationRole) uor).getRole().getName()); + } + Collections.sort(childroles); + childDTO.setOrgName(childuo.getOrganisation().getName()); + childDTO.setRoles(childroles); + childDTOs.add(childDTO); + } + uorDTO.setChildDTOs(childDTOs); + uorDTOs.add(uorDTO); + } - initServices(); - - if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); - return mapping.findForward("error"); + return uorDTOs; } - Integer orgId = WebUtil.readIntParam(request, "orgId", true); - Integer userId = WebUtil.readIntParam(request, "userId"); - User user = (User) service.findById(User.class, userId); + // determine whether to disable or delete user based on their lams data + public ActionForward remove(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - Boolean hasData = service.userHasData(user); + initServices(); - request.setAttribute("method", (hasData ? "disable" : "delete")); - request.setAttribute("orgId", orgId); - request.setAttribute("userId", userId); - return mapping.findForward("remove"); - } + if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); + return mapping.findForward("error"); + } - public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + Integer orgId = WebUtil.readIntParam(request, "orgId", true); + Integer userId = WebUtil.readIntParam(request, "userId"); + User user = (User) service.findById(User.class, userId); - initServices(); + Boolean hasData = service.userHasData(user); - if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); - return mapping.findForward("error"); + request.setAttribute("method", (hasData ? "disable" : "delete")); + request.setAttribute("orgId", orgId); + request.setAttribute("userId", userId); + return mapping.findForward("remove"); } - Integer orgId = WebUtil.readIntParam(request, "orgId", true); - Integer userId = WebUtil.readIntParam(request, "userId"); - service.disableUser(userId); - String[] args = new String[1]; - args[0] = userId.toString(); - String message = messageService.getMessage("audit.user.disable", args); - AdminServiceProxy.getAuditService(getServlet().getServletContext()).log(AdminConstants.MODULE_NAME, message); + public ActionForward disable(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - if (orgId == null || orgId == 0) { - return mapping.findForward("usersearch"); - } else { - request.setAttribute("org", orgId); - return mapping.findForward("userlist"); - } - } + initServices(); - public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); + return mapping.findForward("error"); + } - initServices(); + Integer orgId = WebUtil.readIntParam(request, "orgId", true); + Integer userId = WebUtil.readIntParam(request, "userId"); + service.disableUser(userId); + String[] args = new String[1]; + args[0] = userId.toString(); + String message = messageService.getMessage("audit.user.disable", args); + AdminServiceProxy.getAuditService(getServlet().getServletContext()).log(AdminConstants.MODULE_NAME, message); - if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); - return mapping.findForward("error"); + if (orgId == null || orgId == 0) { + return mapping.findForward("usersearch"); + } else { + request.setAttribute("org", orgId); + return mapping.findForward("userlist"); + } } - Integer orgId = WebUtil.readIntParam(request, "orgId", true); - Integer userId = WebUtil.readIntParam(request, "userId"); - try { - service.removeUser(userId); - } catch (Exception e) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", e.getMessage()); - return mapping.findForward("error"); - } - String[] args = new String[1]; - args[0] = userId.toString(); - String message = messageService.getMessage("audit.user.delete", args); - AdminServiceProxy.getAuditService(getServlet().getServletContext()).log(AdminConstants.MODULE_NAME, message); + public ActionForward delete(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - if (orgId == null || orgId == 0) { - return mapping.findForward("usersearch"); - } else { - request.setAttribute("org", orgId); - return mapping.findForward("userlist"); - } - } + initServices(); - // called from disabled users screen - public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); + return mapping.findForward("error"); + } - initServices(); + Integer orgId = WebUtil.readIntParam(request, "orgId", true); + Integer userId = WebUtil.readIntParam(request, "userId"); + try { + service.removeUser(userId); + } catch (Exception e) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", e.getMessage()); + return mapping.findForward("error"); + } + String[] args = new String[1]; + args[0] = userId.toString(); + String message = messageService.getMessage("audit.user.delete", args); + AdminServiceProxy.getAuditService(getServlet().getServletContext()).log(AdminConstants.MODULE_NAME, message); - if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { - request.setAttribute("errorName", "UserAction"); - request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); - return mapping.findForward("error"); + if (orgId == null || orgId == 0) { + return mapping.findForward("usersearch"); + } else { + request.setAttribute("org", orgId); + return mapping.findForward("userlist"); + } } - Integer userId = WebUtil.readIntParam(request, "userId", true); - User user = (User) service.findById(User.class, userId); + // called from disabled users screen + public ActionForward enable(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - UserAction.log.debug("enabling user: " + userId); - user.setDisabledFlag(false); - service.save(user); + initServices(); - return mapping.findForward("disabledlist"); - } + if (!(request.isUserInRole(Role.SYSADMIN) || service.isUserGlobalGroupAdmin())) { + request.setAttribute("errorName", "UserAction"); + request.setAttribute("errorMessage", messageService.getMessage("error.authorisation")); + return mapping.findForward("error"); + } + Integer userId = WebUtil.readIntParam(request, "userId", true); + User user = (User) service.findById(User.class, userId); + + UserAction.log.debug("enabling user: " + userId); + user.setDisabledFlag(false); + service.save(user); + + return mapping.findForward("disabledlist"); + } + } \ No newline at end of file Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java,v diff -u -r1.35 -r1.35.6.1 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java 10 Apr 2009 13:28:14 -0000 1.35 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/UserSaveAction.java 1 Mar 2010 04:56:25 -0000 1.35.6.1 @@ -43,6 +43,7 @@ import org.apache.struts.action.DynaActionForm; import org.lamsfoundation.lams.admin.AdminConstants; import org.lamsfoundation.lams.admin.service.AdminServiceProxy; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.AuthenticationMethod; import org.lamsfoundation.lams.usermanagement.SupportedLocale; import org.lamsfoundation.lams.usermanagement.User; @@ -58,7 +59,8 @@ /** * struts doclets * - * @struts:action path="/usersave" name="UserForm" input=".user" scope="request" validate="false" + * @struts:action path="/usersave" name="UserForm" input=".user" scope="request" + * validate="false" * * @struts:action-forward name="user" path="/user.do?method=edit" * @struts:action-forward name="userlist" path="/usermanage.do" @@ -67,139 +69,154 @@ */ public class UserSaveAction extends Action { - private static Logger log = Logger.getLogger(UserSaveAction.class); - private static IUserManagementService service; + private static Logger log = Logger.getLogger(UserSaveAction.class); + private static IUserManagementService service; - @Override - @SuppressWarnings("unchecked") - public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { + @Override + @SuppressWarnings("unchecked") + public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { - UserSaveAction.service = AdminServiceProxy.getService(getServlet().getServletContext()); + UserSaveAction.service = AdminServiceProxy.getService(getServlet().getServletContext()); - // action input - ActionMessages errors = new ActionMessages(); - DynaActionForm userForm = (DynaActionForm) form; - Integer orgId = (Integer) userForm.get("orgId"); - Integer userId = (Integer) userForm.get("userId"); + // action input + ActionMessages errors = new ActionMessages(); + DynaActionForm userForm = (DynaActionForm) form; + Integer orgId = (Integer) userForm.get("orgId"); + Integer userId = (Integer) userForm.get("userId"); - UserSaveAction.log.debug("orgId: " + orgId); - Boolean edit = false; - Boolean passwordChanged = true; - SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class, - (Integer) userForm.get("localeId")); - AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service.findById( - AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId")); - UserSaveAction.log.debug("locale: " + locale); - UserSaveAction.log.debug("authenticationMethod:" + authenticationMethod); + UserSaveAction.log.debug("orgId: " + orgId); + Boolean edit = false; + Boolean passwordChanged = true; + SupportedLocale locale = (SupportedLocale) UserSaveAction.service.findById(SupportedLocale.class, + (Integer) userForm.get("localeId")); + AuthenticationMethod authenticationMethod = (AuthenticationMethod) UserSaveAction.service.findById( + AuthenticationMethod.class, (Integer) userForm.get("authenticationMethodId")); + UserSaveAction.log.debug("locale: " + locale); + UserSaveAction.log.debug("authenticationMethod:" + authenticationMethod); - if (isCancelled(request)) { - if (orgId == null || orgId == 0) { - return mapping.findForward("usersearch"); - } - request.setAttribute("org", orgId); - return mapping.findForward("userlist"); - } + if (isCancelled(request)) { + if (orgId == null || orgId == 0) { + return mapping.findForward("usersearch"); + } + request.setAttribute("org", orgId); + return mapping.findForward("userlist"); + } - User user = null; - if (userId != 0) { - edit = true; - user = (User) UserSaveAction.service.findById(User.class, userId); - } + User user = null; + if (userId != 0) { + edit = true; + user = (User) UserSaveAction.service.findById(User.class, userId); + } - // (dyna)form validation - userForm.set("login", userForm.getString("login").trim()); - if (userForm.get("login") == null || userForm.getString("login").length() == 0) { - errors.add("login", new ActionMessage("error.login.required")); - } - if (UserSaveAction.service.getUserByLogin(userForm.getString("login")) != null) { - if (user != null && StringUtils.equals(user.getLogin(), userForm.getString("login"))) { - // login exists - it's the user's current login - } else { - errors.add("login", new ActionMessage("error.login.unique", "(" + userForm.getString("login") + ")")); - } - } - if (!StringUtils.equals((String) userForm.get("password"), ((String) userForm.get("password2")))) { - errors.add("password", new ActionMessage("error.newpassword.mismatch")); - } - if (userForm.get("password") == null || userForm.getString("password").trim().length() == 0) { - passwordChanged = false; - if (!edit) { - errors.add("password", new ActionMessage("error.password.required")); - } - } - if (userForm.get("firstName") == null || userForm.getString("firstName").trim().length() == 0) { - errors.add("firstName", new ActionMessage("error.firstname.required")); - } - if (userForm.get("lastName") == null || userForm.getString("lastName").trim().length() == 0) { - errors.add("lastName", new ActionMessage("error.lastname.required")); - } - if (userForm.get("email") == null || userForm.getString("email").trim().length() == 0) { - errors.add("email", new ActionMessage("error.email.required")); - } else { - Pattern p = Pattern.compile(".+@.+\\.[a-z]+"); - Matcher m = p.matcher(userForm.getString("email")); - if (!m.matches()) { - errors.add("email", new ActionMessage("error.valid.email.required")); - } - } - - if (errors.isEmpty()) { - if (edit) { // edit user - UserSaveAction.log.debug("editing userId: " + userId); - // hash the new password if necessary, and audit the fact - if (passwordChanged) { - UserSaveAction.service.auditPasswordChanged(user, AdminConstants.MODULE_NAME); - userForm.set("password", HashUtil.sha1((String) userForm.get("password"))); + // (dyna)form validation + userForm.set("login", userForm.getString("login").trim()); + if (userForm.get("login") == null || userForm.getString("login").length() == 0) { + errors.add("login", new ActionMessage("error.login.required")); + } + if (UserSaveAction.service.getUserByLogin(userForm.getString("login")) != null) { + if (user != null && StringUtils.equals(user.getLogin(), userForm.getString("login"))) { + // login exists - it's the user's current login + } else { + errors.add("login", new ActionMessage("error.login.unique", "(" + userForm.getString("login") + ")")); + } + } + if (!StringUtils.equals((String) userForm.get("password"), ((String) userForm.get("password2")))) { + errors.add("password", new ActionMessage("error.newpassword.mismatch")); + } + if (userForm.get("password") == null || userForm.getString("password").trim().length() == 0) { + passwordChanged = false; + if (!edit) { + errors.add("password", new ActionMessage("error.password.required")); + } + } + if (userForm.get("firstName") == null || userForm.getString("firstName").trim().length() == 0) { + errors.add("firstName", new ActionMessage("error.firstname.required")); + } + if (userForm.get("lastName") == null || userForm.getString("lastName").trim().length() == 0) { + errors.add("lastName", new ActionMessage("error.lastname.required")); + } + if (userForm.get("email") == null || userForm.getString("email").trim().length() == 0) { + errors.add("email", new ActionMessage("error.email.required")); } else { - userForm.set("password", user.getPassword()); + Pattern p = Pattern.compile(".+@.+\\.[a-z]+"); + Matcher m = p.matcher(userForm.getString("email")); + if (!m.matches()) { + errors.add("email", new ActionMessage("error.valid.email.required")); + } } - BeanUtils.copyProperties(user, userForm); - user.setLocale(locale); - user.setAuthenticationMethod(authenticationMethod); - UserSaveAction.service.save(user); - } else { // create user - user = new User(); - userForm.set("password", HashUtil.sha1((String) userForm.get("password"))); - BeanUtils.copyProperties(user, userForm); - UserSaveAction.log.debug("creating user... new login: " + user.getLogin()); + if (errors.isEmpty()) { - // TODO set flash/html themes according to user input instead of server default. - user.setFlashTheme(UserSaveAction.service.getDefaultFlashTheme()); - user.setHtmlTheme(UserSaveAction.service.getDefaultHtmlTheme()); - user.setDisabledFlag(false); - user.setCreateDate(new Date()); - user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service.findByProperty( - AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database").get(0)); - user.setUserId(null); - user.setLocale(locale); - UserSaveAction.service.save(user); + if (edit) { // edit user + UserSaveAction.log.debug("editing userId: " + userId); + // hash the new password if necessary, and audit the fact + if (passwordChanged) { + UserSaveAction.service.auditPasswordChanged(user, AdminConstants.MODULE_NAME); + userForm.set("password", HashUtil.sha1((String) userForm.get("password"))); + } else { + userForm.set("password", user.getPassword()); + } + BeanUtils.copyProperties(user, userForm); + user.setLocale(locale); + user.setAuthenticationMethod(authenticationMethod); - // make 'create user' audit log entry - UserSaveAction.service.auditUserCreated(user, AdminConstants.MODULE_NAME); + Theme cssTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userCSSTheme")); + user.setHtmlTheme(cssTheme); - UserSaveAction.log.debug("user: " + user.toString()); + Theme flashTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userFlashTheme")); + user.setFlashTheme(flashTheme); + + UserSaveAction.service.save(user); + } else { // create user + user = new User(); + userForm.set("password", HashUtil.sha1((String) userForm.get("password"))); + BeanUtils.copyProperties(user, userForm); + UserSaveAction.log.debug("creating user... new login: " + user.getLogin()); + if (errors.isEmpty()) { + // TODO set flash/html themes according to user input + // instead of server default. + user.setFlashTheme(UserSaveAction.service.getDefaultFlashTheme()); + user.setHtmlTheme(UserSaveAction.service.getDefaultHtmlTheme()); + user.setDisabledFlag(false); + user.setCreateDate(new Date()); + user.setAuthenticationMethod((AuthenticationMethod) UserSaveAction.service.findByProperty( + AuthenticationMethod.class, "authenticationMethodName", "LAMS-Database").get(0)); + user.setUserId(null); + user.setLocale(locale); + + Theme cssTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userCSSTheme")); + user.setHtmlTheme(cssTheme); + + Theme flashTheme = (Theme) service.findById(Theme.class, (Long) userForm.get("userFlashTheme")); + user.setFlashTheme(flashTheme); + + UserSaveAction.service.save(user); + + // make 'create user' audit log entry + UserSaveAction.service.auditUserCreated(user, AdminConstants.MODULE_NAME); + + UserSaveAction.log.debug("user: " + user.toString()); + } + } } - } - } - if (errors.isEmpty()) { - if (orgId == null || orgId == 0) { - return mapping.findForward("usersearch"); - } - if (edit) { - request.setAttribute("org", orgId); - return mapping.findForward("userlist"); - } else { - request.setAttribute("orgId", orgId); - request.setAttribute("userId", user.getUserId()); - return mapping.findForward("userroles"); - } - } else { - saveErrors(request, errors); - request.setAttribute("orgId", orgId); - return mapping.findForward("user"); + if (errors.isEmpty()) { + if (orgId == null || orgId == 0) { + return mapping.findForward("usersearch"); + } + if (edit) { + request.setAttribute("org", orgId); + return mapping.findForward("userlist"); + } else { + request.setAttribute("orgId", orgId); + request.setAttribute("userId", user.getUserId()); + return mapping.findForward("userroles"); + } + } else { + saveErrors(request, errors); + request.setAttribute("orgId", orgId); + return mapping.findForward("user"); + } } - } } Index: lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java,v diff -u -r1.9 -r1.9.10.1 --- lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java 13 Sep 2007 08:11:58 -0000 1.9 +++ lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/SysAdminStartAction.java 1 Mar 2010 04:56:25 -0000 1.9.10.1 @@ -71,6 +71,7 @@ links.add(new LinkBean("serverlist.do", "sysadmin.maintain.external.servers")); links.add(new LinkBean("register.do", "sysadmin.register.server")); links.add(new LinkBean("libraryManage.do", "sysadmin.library.management")); + links.add(new LinkBean("themeManagement.do", "admin.themes.title")); } else if (request.isUserInRole(Role.AUTHOR_ADMIN)) { LinkBean linkBean = new LinkBean("toolcontentlist.do", "sysadmin.tool.management"); links.add(linkBean); Fisheye: Tag 1.2.2.1 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/action/ThemeManagementAction.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.2.2.1 refers to a dead (removed) revision in file `lams_admin/src/java/org/lamsfoundation/lams/admin/web/form/ThemeForm.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.3.2.1 refers to a dead (removed) revision in file `lams_admin/web/themeManagement.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_admin/web/user.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/user.jsp,v diff -u -r1.26 -r1.26.10.1 --- lams_admin/web/user.jsp 4 Oct 2008 03:37:34 -0000 1.26 +++ lams_admin/web/user.jsp 1 Mar 2010 04:56:25 -0000 1.26.10.1 @@ -131,6 +131,26 @@ + : + + + + ${theme.name} + + + + + + : + + + + ${theme.name} + + + + + Index: lams_admin/web/WEB-INF/tiles/tiles-defs.xml =================================================================== RCS file: /usr/local/cvsroot/lams_admin/web/WEB-INF/tiles/Attic/tiles-defs.xml,v diff -u -r1.30 -r1.30.10.1 --- lams_admin/web/WEB-INF/tiles/tiles-defs.xml 9 Jan 2008 00:53:14 -0000 1.30 +++ lams_admin/web/WEB-INF/tiles/tiles-defs.xml 1 Mar 2010 04:56:25 -0000 1.30.10.1 @@ -150,4 +150,9 @@ + + + + + \ No newline at end of file Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources.properties,v diff -u -r1.71.2.16.2.3 -r1.71.2.16.2.4 --- lams_central/conf/language/lams/ApplicationResources.properties 19 Feb 2010 04:40:56 -0000 1.71.2.16.2.3 +++ lams_central/conf/language/lams/ApplicationResources.properties 1 Mar 2010 04:55:47 -0000 1.71.2.16.2.4 @@ -275,5 +275,7 @@ unsupport.move =LAMS does not support moving a file via the workspace interface. videorecorder.instructions.fck =Click the record button to start and stop recording. Once a recording is completed, you can review it by clicking the play button. When ready to add the video, click the tick button. Having problems with recording? It might be that your network blocks the video recording ports. Contact your system administrator. +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 268 labels for en AU ===== Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/language/lams/ApplicationResources_en_AU.properties,v diff -u -r1.67.2.13.4.3 -r1.67.2.13.4.4 --- lams_central/conf/language/lams/ApplicationResources_en_AU.properties 19 Feb 2010 04:40:56 -0000 1.67.2.13.4.3 +++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties 1 Mar 2010 04:55:47 -0000 1.67.2.13.4.4 @@ -275,5 +275,7 @@ unsupport.move =LAMS does not support moving a file via the workspace interface. videorecorder.instructions.fck =Click the record button to start and stop recording. Once a recording is completed, you can review it by clicking the play button. When ready to add the video, click the tick button. Having problems with recording? It might be that your network blocks the video recording ports. Contact your system administrator. +label.html.htmlTheme =HTML Theme +label.html.flashTheme =Flash Theme #======= End labels: Exported 268 labels for en AU ===== Index: lams_central/conf/xdoclet/struts-forms.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/conf/xdoclet/struts-forms.xml,v diff -u -r1.8.4.3 -r1.8.4.3.2.1 --- lams_central/conf/xdoclet/struts-forms.xml 19 Jun 2009 04:32:10 -0000 1.8.4.3 +++ lams_central/conf/xdoclet/struts-forms.xml 1 Mar 2010 04:55:47 -0000 1.8.4.3.2.1 @@ -37,6 +37,8 @@ + + Index: lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java,v diff -u -r1.26 -r1.26.10.1 --- lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java 13 Nov 2008 01:20:28 -0000 1.26 +++ lams_central/src/java/org/lamsfoundation/lams/security/UniversalLoginModule.java 1 Mar 2010 04:55:47 -0000 1.26.10.1 @@ -52,9 +52,13 @@ import javax.sql.DataSource; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.themes.Theme; +import org.lamsfoundation.lams.themes.dto.CSSThemeBriefDTO; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.AuthenticationMethodType; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.service.LdapService; import org.lamsfoundation.lams.usermanagement.service.UserManagementService; import org.lamsfoundation.lams.util.Configuration; @@ -71,263 +75,317 @@ public class UniversalLoginModule extends UsernamePasswordLoginModule { - private static Logger log = Logger.getLogger(UniversalLoginModule.class); + private static Logger log = Logger.getLogger(UniversalLoginModule.class); - public UniversalLoginModule() { - } + public UniversalLoginModule() { + } - protected String dsJndiName; + protected String dsJndiName; - protected String rolesQuery; + protected String rolesQuery; - protected String principalsQuery; + protected String principalsQuery; - public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { - super.initialize(subject, callbackHandler, sharedState, options); - dsJndiName = (String) options.get("dsJndiName"); - principalsQuery = (String) options.get("principalsQuery"); - rolesQuery = (String) options.get("rolesQuery"); - } + private IThemeService themeService; + private UserManagementService service; - protected boolean validatePassword(String inputPassword, String expectedPassword) { - boolean isValid = false; - if (inputPassword != null) { - // empty password not allowed - if (inputPassword.length() == 0) - return false; + public void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) { + super.initialize(subject, callbackHandler, sharedState, options); + dsJndiName = (String) options.get("dsJndiName"); + principalsQuery = (String) options.get("principalsQuery"); + rolesQuery = (String) options.get("rolesQuery"); + } - try { - String username = getUsername(); - log.debug("===> authenticating user: " + username); + protected boolean validatePassword(String inputPassword, String expectedPassword) { + boolean isValid = false; + if (inputPassword != null) { + // empty password not allowed + if (inputPassword.length() == 0) + return false; - WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager - .getInstance().getServletContext()); - UserManagementService service = (UserManagementService) ctx.getBean("userManagementService"); - User user = service.getUserByLogin(username); - - // LDAP user provisioning - if (user == null) { - // provision a new user by checking ldap server - if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_PROVISIONING_ENABLED)) { - LdapService ldapService; try { - ldapService = (LdapService) ctx.getBean("ldapService"); - } catch (NoSuchBeanDefinitionException e) { - // LDEV-1937 - log.error("NoSuchBeanDefinitionException while getting ldapService bean, will try another method...", - e); - ApplicationContext context = new ClassPathXmlApplicationContext( - "org/lamsfoundation/lams/usermanagement/ldapContext.xml"); - ldapService = (LdapService) context.getBean("ldapService"); - } - log.debug("===> LDAP provisioning is enabled, checking username against LDAP server..."); - LDAPAuthenticator ldap = new LDAPAuthenticator(); - isValid = ldap.authenticate(username, inputPassword); - if (isValid) { // create a new user - log.info("===> Creating new user for LDAP username: " + username); - if (ldapService.createLDAPUser(ldap.getAttrs())) { - user = service.getUserByLogin(username); - if (!ldapService.addLDAPUser(ldap.getAttrs(), user.getUserId())) { - log.error("===> Couldn't add LDAP user: " + username + " to organisation."); + String username = getUsername(); + log.debug("===> authenticating user: " + username); + + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager + .getInstance().getServletContext()); + + if (service == null) { + service = (UserManagementService) ctx.getBean("userManagementService"); } - } else { - log.error("===> Couldn't create new user for LDAP username: " + username); - return false; - } - } else { // didn't authenticate successfully with ldap - return false; - } - } else { - return false; - } - } + User user = service.getUserByLogin(username); - // allow sysadmin to login as another user; in this case, the - // LAMS shared session - // will be present, allowing the following check to work - if (service.isUserSysAdmin()) { - isValid = true; - } + if (themeService == null) { + themeService = (IThemeService) ctx.getBean("themeService"); + } - // perform password checking according to user's authentication - // method - if (!isValid) { - String type = user.getAuthenticationMethod().getAuthenticationMethodType().getDescription(); - log.debug("===> authentication type: " + type); - if (AuthenticationMethodType.LDAP.equals(type)) { - LDAPAuthenticator authenticator = new LDAPAuthenticator(); - isValid = authenticator.authenticate(username, inputPassword); - // if ldap user profile has updated, udpate user object - // for dto below - user = service.getUserByLogin(username); - } else if (AuthenticationMethodType.LAMS.equals(type)) { - DatabaseAuthenticator authenticator = new DatabaseAuthenticator(dsJndiName, principalsQuery); - // if the password is not encrypted when sent from the - // jsp (e.g. when it is passed - // unencrypted to say, ldap) then encrypt it here when - // authenticating against local db - if (!Configuration.getAsBoolean(ConfigurationKeys.LDAP_ENCRYPT_PASSWORD_FROM_BROWSER)) { - // try the passed in password first, - // LoginRequestServlet always passes in encrypted - // passwords - isValid = authenticator.authenticate(username, inputPassword); - if (!isValid) { - inputPassword = HashUtil.sha1(inputPassword); - } - isValid = authenticator.authenticate(username, inputPassword); - } else { - isValid = authenticator.authenticate(username, inputPassword); - } - } else if (AuthenticationMethodType.WEB_AUTH.equals(type)) { - WebAuthAuthenticator authenticator = new WebAuthAuthenticator(); - isValid = authenticator.authenticate(username, inputPassword); - } else { - log.error("===> Unexpected authentication type: " + type); - return false; - } - } + // LDAP user provisioning + if (user == null) { + // provision a new user by checking ldap server + if (Configuration.getAsBoolean(ConfigurationKeys.LDAP_PROVISIONING_ENABLED)) { + LdapService ldapService; + try { + ldapService = (LdapService) ctx.getBean("ldapService"); + } catch (NoSuchBeanDefinitionException e) { + // LDEV-1937 + log + .error( + "NoSuchBeanDefinitionException while getting ldapService bean, will try another method...", + e); + ApplicationContext context = new ClassPathXmlApplicationContext( + "org/lamsfoundation/lams/usermanagement/ldapContext.xml"); + ldapService = (LdapService) context.getBean("ldapService"); + } + log.debug("===> LDAP provisioning is enabled, checking username against LDAP server..."); + LDAPAuthenticator ldap = new LDAPAuthenticator(); + isValid = ldap.authenticate(username, inputPassword); + if (isValid) { // create a new user + log.info("===> Creating new user for LDAP username: " + username); + if (ldapService.createLDAPUser(ldap.getAttrs())) { + user = service.getUserByLogin(username); + if (!ldapService.addLDAPUser(ldap.getAttrs(), user.getUserId())) { + log.error("===> Couldn't add LDAP user: " + username + " to organisation."); + } + } else { + log.error("===> Couldn't create new user for LDAP username: " + username); + return false; + } + } else { // didn't authenticate successfully with ldap + return false; + } + } else { + return false; + } + } - // disabled users can't login; - // check after authentication to give non-db authentication - // methods - // a chance to update disabled flag - if (user.getDisabledFlag()) { - log.debug("===> user is disabled."); - return false; - } + // allow sysadmin to login as another user; in this case, the + // LAMS shared session + // will be present, allowing the following check to work + if (service.isUserSysAdmin()) { + isValid = true; + } - // if login is valid, register userDTO into session. - if (isValid) { - HttpSession sharedsession = SessionManager.getSession(); - sharedsession.setAttribute(AttributeNames.USER, user.getUserDTO()); - } - } catch (Exception e) { - e.printStackTrace(); - log.error("===> exception: " + e, e); - } - } - return isValid; - } + // perform password checking according to user's authentication + // method + if (!isValid) { + String type = user.getAuthenticationMethod().getAuthenticationMethodType().getDescription(); + log.debug("===> authentication type: " + type); + if (AuthenticationMethodType.LDAP.equals(type)) { + LDAPAuthenticator authenticator = new LDAPAuthenticator(); + isValid = authenticator.authenticate(username, inputPassword); + // if ldap user profile has updated, udpate user object + // for dto below + user = service.getUserByLogin(username); + } else if (AuthenticationMethodType.LAMS.equals(type)) { + DatabaseAuthenticator authenticator = new DatabaseAuthenticator(dsJndiName, principalsQuery); + // if the password is not encrypted when sent from the + // jsp (e.g. when it is passed + // unencrypted to say, ldap) then encrypt it here when + // authenticating against local db + if (!Configuration.getAsBoolean(ConfigurationKeys.LDAP_ENCRYPT_PASSWORD_FROM_BROWSER)) { + // try the passed in password first, + // LoginRequestServlet always passes in encrypted + // passwords + isValid = authenticator.authenticate(username, inputPassword); + if (!isValid) { + inputPassword = HashUtil.sha1(inputPassword); + } + isValid = authenticator.authenticate(username, inputPassword); + } else { + isValid = authenticator.authenticate(username, inputPassword); + } + } else if (AuthenticationMethodType.WEB_AUTH.equals(type)) { + WebAuthAuthenticator authenticator = new WebAuthAuthenticator(); + isValid = authenticator.authenticate(username, inputPassword); + } else { + log.error("===> Unexpected authentication type: " + type); + return false; + } + } - /** - * According to Lams's security policy, all the authorization must be done - * locally, in other word, through Lams database or other "local"(logically) - * data resource. - * - * @return Group[] containing the sets of roles - */ - protected Group[] getRoleSets() throws LoginException { - String username = getUsername(); - Connection conn = null; - HashMap setsMap = new HashMap(); - PreparedStatement ps = null; - ResultSet rs = null; + // disabled users can't login; + // check after authentication to give non-db authentication + // methods + // a chance to update disabled flag + if (user.getDisabledFlag()) { + log.debug("===> user is disabled."); + return false; + } - try { + // if login is valid, register userDTO into session. + if (isValid) { + UserDTO userDTO = user.getUserDTO(); - InitialContext ctx = new InitialContext(); - DataSource ds = (DataSource) ctx.lookup(this.dsJndiName); + // If the user's theme has been deleted, use the default as + // fallback + CSSThemeBriefDTO userTheme = userDTO.getHtmlTheme(); + if (userTheme != null) { + // If the user's css theme has been deleted, use the + // default as fallback + CSSThemeBriefDTO userCSSTheme = userDTO.getHtmlTheme(); + if (userCSSTheme != null) { + boolean themeExists = false; - // log.debug("===> getRoleSets() called: " + dsJndiName + ": " + - // rolesQuery); - conn = ds.getConnection(); - // Get the user role names - ps = conn.prepareStatement(this.rolesQuery); - try { - ps.setString(1, username); - } catch (ArrayIndexOutOfBoundsException ignore) { - // The query may not have any parameters so just try it - } - rs = ps.executeQuery(); - if (rs.next() == false) { - if (getUnauthenticatedIdentity() == null) - throw new FailedLoginException("No matching username found in Roles"); - /* - * We are running with an unauthenticatedIdentity so create an - * empty Roles set and return. - */ - Group[] roleSets = { new SimpleGroup("Roles") }; - return roleSets; - } + for (Theme theme : themeService.getAllCSSThemes()) { + if (userCSSTheme.getId().equals(theme.getThemeId())) { + themeExists = true; + break; + } + } - ArrayList groupMembers = new ArrayList(); - do { - String name = rs.getString(1); - String groupName = rs.getString(2); - if (groupName == null || groupName.length() == 0) - groupName = "Roles"; - Group group = (Group) setsMap.get(groupName); - if (group == null) { - group = new SimpleGroup(groupName); - setsMap.put(groupName, group); + if (!themeExists) { + userDTO.setHtmlTheme(new CSSThemeBriefDTO(themeService.getDefaultCSSTheme())); + } + } + } + + // If the user's flash theme has been deleted, use the + // default as fallback + CSSThemeBriefDTO userFlashTheme = userDTO.getFlashTheme(); + if (userFlashTheme != null) { + boolean themeExists = false; + for (Theme theme : themeService.getAllFlashThemes()) { + if (userFlashTheme.getId().equals(theme.getThemeId())) { + themeExists = true; + break; + } + } + + if (!themeExists) { + userDTO.setFlashTheme(new CSSThemeBriefDTO(themeService.getDefaultFlashTheme())); + } + } + + HttpSession sharedsession = SessionManager.getSession(); + sharedsession.setAttribute(AttributeNames.USER, userDTO); + } + } catch (Exception e) { + e.printStackTrace(); + log.error("===> exception: " + e, e); + } } + return isValid; + } + /** + * According to Lams's security policy, all the authorization must be done + * locally, in other word, through Lams database or other "local"(logically) + * data resource. + * + * @return Group[] containing the sets of roles + */ + protected Group[] getRoleSets() throws LoginException { + String username = getUsername(); + Connection conn = null; + HashMap setsMap = new HashMap(); + PreparedStatement ps = null; + ResultSet rs = null; + try { - Principal p; - // Assign minimal role if user has none - if (name == null) { - name = Role.LEARNER; - log.info("===> Found no roles"); - } - p = super.createIdentity(name); - if (!groupMembers.contains(name)) { - log.info("===> Assign user to role " + p.getName()); - group.addMember(p); - groupMembers.add(name); - } - if (name.equals(Role.SYSADMIN) || name.equals(Role.AUTHOR_ADMIN)) { - p = super.createIdentity(Role.AUTHOR); - log.info("===> Found " + name); - if (!groupMembers.contains(Role.AUTHOR)) { - log.info("===> Assign user to role " + Role.AUTHOR); - group.addMember(p); - groupMembers.add(Role.AUTHOR); + + InitialContext ctx = new InitialContext(); + DataSource ds = (DataSource) ctx.lookup(this.dsJndiName); + + // log.debug("===> getRoleSets() called: " + dsJndiName + ": " + + // rolesQuery); + conn = ds.getConnection(); + // Get the user role names + ps = conn.prepareStatement(this.rolesQuery); + try { + ps.setString(1, username); + } catch (ArrayIndexOutOfBoundsException ignore) { + // The query may not have any parameters so just try it } - } - } catch (Exception e) { - log.debug("===> Failed to create principal: " + name, e); + rs = ps.executeQuery(); + if (rs.next() == false) { + if (getUnauthenticatedIdentity() == null) + throw new FailedLoginException("No matching username found in Roles"); + /* + * We are running with an unauthenticatedIdentity so create an + * empty Roles set and return. + */ + Group[] roleSets = { new SimpleGroup("Roles") }; + return roleSets; + } + + ArrayList groupMembers = new ArrayList(); + do { + String name = rs.getString(1); + String groupName = rs.getString(2); + if (groupName == null || groupName.length() == 0) + groupName = "Roles"; + Group group = (Group) setsMap.get(groupName); + if (group == null) { + group = new SimpleGroup(groupName); + setsMap.put(groupName, group); + } + + try { + Principal p; + // Assign minimal role if user has none + if (name == null) { + name = Role.LEARNER; + log.info("===> Found no roles"); + } + p = super.createIdentity(name); + if (!groupMembers.contains(name)) { + log.info("===> Assign user to role " + p.getName()); + group.addMember(p); + groupMembers.add(name); + } + if (name.equals(Role.SYSADMIN) || name.equals(Role.AUTHOR_ADMIN)) { + p = super.createIdentity(Role.AUTHOR); + log.info("===> Found " + name); + if (!groupMembers.contains(Role.AUTHOR)) { + log.info("===> Assign user to role " + Role.AUTHOR); + group.addMember(p); + groupMembers.add(Role.AUTHOR); + } + } + } catch (Exception e) { + log.debug("===> Failed to create principal: " + name, e); + } + } while (rs.next()); + } catch (NamingException ex) { + throw new LoginException(ex.toString(true)); + } catch (SQLException ex) { + super.log.error("SQL failure", ex); + throw new LoginException(ex.toString()); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + } + } + if (ps != null) { + try { + ps.close(); + } catch (SQLException e) { + } + } + if (conn != null) { + try { + conn.close(); + } catch (Exception ex) { + } + } } - } while (rs.next()); - } catch (NamingException ex) { - throw new LoginException(ex.toString(true)); - } catch (SQLException ex) { - super.log.error("SQL failure", ex); - throw new LoginException(ex.toString()); - } finally { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - } - } - if (ps != null) { - try { - ps.close(); - } catch (SQLException e) { - } - } - if (conn != null) { - try { - conn.close(); - } catch (Exception ex) { - } - } + + Group[] roleSets = new Group[setsMap.size()]; + setsMap.values().toArray(roleSets); + return roleSets; } - Group[] roleSets = new Group[setsMap.size()]; - setsMap.values().toArray(roleSets); - return roleSets; - } + /** + * Overriden to return an empty password string as typically one cannot + * obtain a user's password. We also override the validatePassword so this + * is ok. + * + * @return and empty password String + */ + protected String getUsersPassword() throws LoginException { + return ""; + } - /** - * Overriden to return an empty password string as typically one cannot - * obtain a user's password. We also override the validatePassword so this - * is ok. - * - * @return and empty password String - */ - protected String getUsersPassword() throws LoginException { - return ""; - } - } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java,v diff -u -r1.17.8.2 -r1.17.8.3 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 29 Oct 2009 01:59:21 -0000 1.17.8.2 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileAction.java 1 Mar 2010 04:55:47 -0000 1.17.8.3 @@ -41,6 +41,8 @@ import org.lamsfoundation.lams.index.IndexOrgBean; import org.lamsfoundation.lams.learning.service.ICoreLearnerService; import org.lamsfoundation.lams.lesson.dto.LessonDTO; +import org.lamsfoundation.lams.themes.Theme; +import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationType; import org.lamsfoundation.lams.usermanagement.SupportedLocale; @@ -81,6 +83,8 @@ private static List locales; private static ICoreLearnerService learnerService; + + private static IThemeService themeService; public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -201,7 +205,50 @@ boolean hasLamsCommunityToken = requestor.getLamsCommunityToken() != null; request.setAttribute("hasLamsCommunityToken", hasLamsCommunityToken); + + themeService = getThemeService(); + + // Get all the css themes + List cssThemes = themeService.getAllCSSThemes(); + request.setAttribute("cssThemes", cssThemes); + + // Check the user theme is still installed + Long userSelectedCSSTheme = null; + if (requestor.getHtmlTheme() != null) { + for (Theme theme : cssThemes) { + if (theme.getThemeId() == requestor.getHtmlTheme().getThemeId()) { + userSelectedCSSTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedCSSTheme == null) { + userSelectedCSSTheme = themeService.getDefaultCSSTheme().getThemeId(); + } + userForm.set("userCSSTheme", userSelectedCSSTheme); + + // Get all the flash themes + List flashThemes = themeService.getAllFlashThemes(); + request.setAttribute("flashThemes", flashThemes); + // Check the user theme is still installed + Long userSelectedFlashTheme = null; + if (requestor.getHtmlTheme() != null) { + for (Theme theme : flashThemes) { + if (theme.getThemeId() == requestor.getFlashTheme().getThemeId()) { + userSelectedFlashTheme = theme.getThemeId(); + break; + } + } + } + // if still null, use the default + if (userSelectedFlashTheme == null) { + userSelectedFlashTheme = themeService.getDefaultFlashTheme().getThemeId(); + } + userForm.set("userFlashTheme", userSelectedFlashTheme); + + return mapping.findForward("edit"); } @@ -224,4 +271,13 @@ } return learnerService; } + + private IThemeService getThemeService() { + if (themeService == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + themeService = (IThemeService) ctx.getBean("themeService"); + } + return themeService; + } } Index: lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java,v diff -u -r1.12.8.1 -r1.12.8.2 --- lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 1 Mar 2010 00:16:47 -0000 1.12.8.1 +++ lams_central/src/java/org/lamsfoundation/lams/web/ProfileSaveAction.java 1 Mar 2010 04:55:47 -0000 1.12.8.2 @@ -40,7 +40,7 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.action.DynaActionForm; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.SupportedLocale; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; @@ -115,10 +115,14 @@ (Integer) userForm.get("localeId")); requestor.setLocale(locale); - CSSThemeVisualElement theme = (CSSThemeVisualElement) getService().findById(CSSThemeVisualElement.class, - (Long) userForm.get("userTheme")); - requestor.setHtmlTheme(theme); - + Theme cssTheme = (Theme) getService().findById(Theme.class, + (Long) userForm.get("userCSSTheme")); + requestor.setHtmlTheme(cssTheme); + + Theme flashTheme = (Theme) getService().findById(Theme.class, + (Long) userForm.get("userFlashTheme")); + requestor.setFlashTheme(flashTheme); + if (userForm.get("disableLamsCommunityUsername") != null && (Boolean) userForm.get("disableLamsCommunityUsername")) { requestor.setLamsCommunityToken(null); Index: lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java,v diff -u -r1.20 -r1.20.8.1 --- lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java 23 Jan 2009 06:02:40 -0000 1.20 +++ lams_central/src/java/org/lamsfoundation/lams/web/tag/CssTag.java 1 Mar 2010 04:55:46 -0000 1.20.8.1 @@ -92,14 +92,7 @@ if (pageDirection.toLowerCase().equals(RTL_DIR)) rtl = true; - String style = getStyle(); - List themeList; - if(style != null && style.equals(MAIN_STYLE)){ - themeList = CSSThemeUtil.getAllUserThemes(CSSThemeUtil.DEFAULT_MAIN_HTML_THEME); - } - else{ - themeList = CSSThemeUtil.getAllUserThemes(CSSThemeUtil.DEFAULT_HTML_THEME); - } + List themeList = CSSThemeUtil.getAllUserThemes(); for (String theme : themeList) { if (theme != null) { Index: lams_central/web/editprofile.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/editprofile.jsp,v diff -u -r1.14.4.3 -r1.14.4.3.2.1 --- lams_central/web/editprofile.jsp 19 Jun 2009 04:32:10 -0000 1.14.4.3 +++ lams_central/web/editprofile.jsp 1 Mar 2010 04:55:46 -0000 1.14.4.3.2.1 @@ -139,6 +139,26 @@ + + : + + + + ${theme.name} + + + + + + : + + + + ${theme.name} + + + + @@ -235,6 +255,26 @@ : + + : + + + + ${theme.name} + + + + + + : + + + + ${theme.name} + + + + Index: lams_central/web/main.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/main.jsp,v diff -u -r1.40.2.2.2.1 -r1.40.2.2.2.2 --- lams_central/web/main.jsp 16 Nov 2009 02:25:13 -0000 1.40.2.2.2.1 +++ lams_central/web/main.jsp 1 Mar 2010 04:55:46 -0000 1.40.2.2.2.2 @@ -140,7 +140,7 @@ -
+
Index: lams_central/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.34.2.1 -r1.34.2.1.4.1 --- lams_central/web/WEB-INF/struts/struts-config.xml 23 Apr 2009 06:41:42 -0000 1.34.2.1 +++ lams_central/web/WEB-INF/struts/struts-config.xml 1 Mar 2010 04:55:46 -0000 1.34.2.1.4.1 @@ -64,10 +64,13 @@ + + + @@ -380,7 +380,7 @@ Index: lams_common/db/sql/create_lams_11_tables.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/create_lams_11_tables.sql,v diff -u -r1.138.2.6.2.2 -r1.138.2.6.2.3 --- lams_common/db/sql/create_lams_11_tables.sql 26 Feb 2010 21:16:34 -0000 1.138.2.6.2.2 +++ lams_common/db/sql/create_lams_11_tables.sql 1 Mar 2010 04:54:33 -0000 1.138.2.6.2.3 @@ -251,44 +251,16 @@ )TYPE=InnoDB; - -CREATE TABLE lams_css_theme_ve ( - theme_ve_id BIGINT(20) NOT NULL AUTO_INCREMENT +CREATE TABLE lams_theme ( + theme_id BIGINT(20) NOT NULL AUTO_INCREMENT , name VARCHAR(100) NOT NULL , description VARCHAR(100) - , parent_id BIGINT(20) - , theme_flag TINYINT(1) NOT NULL DEFAULT 0 , image_directory VARCHAR(100) - , PRIMARY KEY (theme_ve_id) - , INDEX (parent_id) - , CONSTRAINT FK_lams_css_theme_ve_2 FOREIGN KEY (parent_id) - REFERENCES lams_css_theme_ve (theme_ve_id) ON DELETE NO ACTION ON UPDATE NO ACTION + , theme_type TINYINT(11) + , PRIMARY KEY (theme_id) + , UNIQUE UQ_name (name) )TYPE=InnoDB; -ALTER TABLE lams_css_theme_ve COMMENT='Stores both the Flash theme and visual element'; -CREATE TABLE lams_css_style ( - style_id BIGINT(20) NOT NULL AUTO_INCREMENT - , theme_ve_id BIGINT(20) NOT NULL - , PRIMARY KEY (style_id) - , INDEX (theme_ve_id) - , CONSTRAINT FK_lams_css_style_1 FOREIGN KEY (theme_ve_id) - REFERENCES lams_css_theme_ve (theme_ve_id) ON DELETE NO ACTION ON UPDATE NO ACTION -)TYPE=InnoDB; -ALTER TABLE lams_css_style COMMENT='Groups lams_css_property into a CSSStyleDeclaration.'; - -CREATE TABLE lams_css_property ( - property_id BIGINT(20) NOT NULL AUTO_INCREMENT - , style_id BIGINT(20) NOT NULL - , name VARCHAR(255) NOT NULL - , value VARCHAR(100) NOT NULL - , style_subset VARCHAR(20) - , type TINYINT NOT NULL - , PRIMARY KEY (property_id) - -- , INDEX (style_id) - -- , CONSTRAINT FK_lams_css_property_1 FOREIGN KEY (style_id) - -- REFERENCES lams_css_style (style_id) ON DELETE NO ACTION ON UPDATE NO ACTION -)TYPE=InnoDB; - CREATE TABLE lams_user ( user_id BIGINT(20) NOT NULL AUTO_INCREMENT , login VARCHAR(255) NOT NULL @@ -331,10 +303,10 @@ REFERENCES lams_workspace (workspace_id) ON DELETE NO ACTION ON UPDATE NO ACTION , INDEX (flash_theme_id) , CONSTRAINT FK_lams_user_4 FOREIGN KEY (flash_theme_id) - REFERENCES lams_css_theme_ve (theme_ve_id) ON DELETE NO ACTION ON UPDATE NO ACTION + REFERENCES lams_theme (theme_id) ON DELETE NO ACTION ON UPDATE NO ACTION , INDEX (html_theme_id) , CONSTRAINT FK_lams_user_5 FOREIGN KEY (html_theme_id) - REFERENCES lams_css_theme_ve (theme_ve_id) ON DELETE NO ACTION ON UPDATE NO ACTION + REFERENCES lams_theme (theme_id) ON DELETE NO ACTION ON UPDATE NO ACTION , INDEX (locale_id) , CONSTRAINT FK_lams_user_6 FOREIGN KEY (locale_id) REFERENCES lams_supported_locale (locale_id) ON DELETE NO ACTION ON UPDATE NO ACTION Index: lams_common/db/sql/drop_lams_11_tables.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/drop_lams_11_tables.sql,v diff -u -r1.29.8.1 -r1.29.8.2 --- lams_common/db/sql/drop_lams_11_tables.sql 26 Feb 2010 21:16:34 -0000 1.29.8.1 +++ lams_common/db/sql/drop_lams_11_tables.sql 1 Mar 2010 04:54:32 -0000 1.29.8.2 @@ -13,9 +13,7 @@ DROP TABLE IF EXISTS lams_cr_node_version_property; DROP TABLE IF EXISTS lams_cr_workspace; DROP TABLE IF EXISTS lams_cr_workspace_credential; -DROP TABLE IF EXISTS lams_css_property; -DROP TABLE IF EXISTS lams_css_style; -DROP TABLE IF EXISTS lams_css_theme_ve; +DROP TABLE IF EXISTS lams_theme; DROP TABLE IF EXISTS lams_event_subscriptions; DROP TABLE IF EXISTS lams_events; DROP TABLE IF EXISTS lams_gate_activity_level; Index: lams_common/db/sql/insert_lams_users.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/insert_lams_users.sql,v diff -u -r1.2 -r1.2.8.1 --- lams_common/db/sql/insert_lams_users.sql 3 Feb 2009 05:48:01 -0000 1.2 +++ lams_common/db/sql/insert_lams_users.sql 1 Mar 2010 04:54:32 -0000 1.2.8.1 @@ -3,11 +3,9 @@ SET FOREIGN_KEY_CHECKS=0; -- themes and styles -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (1, "default", "Default Flash style", null, 1, null); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (2, "defaultHTML", "Default HTML style", null, 1, "css"); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (3, "rams", "RAMS Default Flash style", null, 1, null); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (4,"ramsthemeHTML", "RAMS Default HTML sty;e", null, 1, "ramsthemecss"); - +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (1, "default", "Default Flash style", null, 2); +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (2, "defaultHTML", "Default HTML style", "css", 1); + insert into lams_workspace (workspace_id, name, default_fld_id) values(1,'ROOT',1); insert into lams_workspace (workspace_id, name, default_fld_id, def_run_seq_fld_id) values(2,'Developers Playpen',2,22); insert into lams_workspace (workspace_id, name, default_fld_id, def_run_seq_fld_id) values(3,'MATH111',3,23); Index: lams_common/db/sql/insert_rams_users.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/Attic/insert_rams_users.sql,v diff -u -r1.1 -r1.1.18.1 --- lams_common/db/sql/insert_rams_users.sql 23 Apr 2007 00:55:02 -0000 1.1 +++ lams_common/db/sql/insert_rams_users.sql 1 Mar 2010 04:54:32 -0000 1.1.18.1 @@ -3,10 +3,10 @@ SET FOREIGN_KEY_CHECKS=0; -- themes and styles -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (1, "default", "Default Flash style", null, 1, null); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (2, "defaultHTML", "Default HTML style", null, 1, "css"); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (3, "rams", "RAMS Default Flash style", null, 1, null); -INSERT INTO lams_css_theme_ve (theme_ve_id, name, description, parent_id, theme_flag, image_directory) VALUES (4,"ramsthemeHTML", "RAMS Default HTML sty;e", null, 1, "ramsthemecss"); +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (1, "default", "Default Flash style", null, 2); +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (2, "defaultHTML", "Default HTML style", "css", 1); +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (3, "rams", "RAMS Default Flash style", null, 2); +INSERT INTO lams_theme (theme_id, name, description, image_directory, theme_type) VALUES (4, "ramsthemeHTML", "RAMS Default HTML style", "ramsthemecss", 1); insert into lams_workspace (workspace_id, name, default_fld_id) values(1,'ROOT',1); insert into lams_workspace (workspace_id, name, default_fld_id, def_run_seq_fld_id) values(2,'Developers Playpen',2,22); Index: lams_common/db/sql/insert_types_data.sql =================================================================== RCS file: /usr/local/cvsroot/lams_common/db/sql/insert_types_data.sql,v diff -u -r1.85.4.4.2.3 -r1.85.4.4.2.4 --- lams_common/db/sql/insert_types_data.sql 26 Feb 2010 02:48:16 -0000 1.85.4.4.2.3 +++ lams_common/db/sql/insert_types_data.sql 1 Mar 2010 04:54:32 -0000 1.85.4.4.2.4 @@ -311,4 +311,4 @@ (1,'moodle','moodle','moodle','moodle','mdl','http://localhost/moodle/mod/lamstwo/userinfo.php?ts=%timestamp%&un=%username%&hs=%hash%', '', 'http://dummy','\0',7); -- initialise db version -INSERT INTO patches VALUES ('lams', 2030401, NOW(), 'F'); \ No newline at end of file +INSERT INTO patches VALUES ('lams', 2030402, NOW(), 'F'); \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/commonContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/commonContext.xml,v diff -u -r1.79.2.3.2.1 -r1.79.2.3.2.2 --- lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 26 Feb 2010 21:16:34 -0000 1.79.2.3.2.1 +++ lams_common/src/java/org/lamsfoundation/lams/commonContext.xml 1 Mar 2010 04:54:34 -0000 1.79.2.3.2.2 @@ -63,9 +63,7 @@ classpath:org/lamsfoundation/lams/workspace/WorkspaceFolderContent.hbm.xml - classpath:org/lamsfoundation/lams/themes/CSSProperty.hbm.xml - classpath:org/lamsfoundation/lams/themes/CSSStyle.hbm.xml - classpath:org/lamsfoundation/lams/themes/CSSThemeVisualElement.hbm.xml + classpath:org/lamsfoundation/lams/themes/Theme.hbm.xml classpath:org/lamsfoundation/lams/notebook/model/NotebookEntry.hbm.xml Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch02030402.sql'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.5.20.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/CSSProperty.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.5.20.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/CSSStyle.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.9.16.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/CSSThemeVisualElement.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.5.20.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/PropertyType.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/Theme.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_common/src/java/org/lamsfoundation/lams/themes/dao/ICSSThemeDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/dao/ICSSThemeDAO.java,v diff -u -r1.5 -r1.5.20.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/dao/ICSSThemeDAO.java 17 Sep 2006 06:14:25 -0000 1.5 +++ lams_common/src/java/org/lamsfoundation/lams/themes/dao/ICSSThemeDAO.java 1 Mar 2010 04:54:34 -0000 1.5.20.1 @@ -25,7 +25,7 @@ import java.util.List; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; /** * This class interacts with Spring's HibernateTemplate to save/delete and @@ -36,13 +36,17 @@ public interface ICSSThemeDAO { public abstract List getAllThemes(); - public abstract CSSThemeVisualElement getThemeById(Long themeId); + public abstract Theme getThemeById(Long themeId); public abstract List getThemeByName(String name); - public abstract void saveOrUpdateTheme(CSSThemeVisualElement theme); + public abstract void saveOrUpdateTheme(Theme theme); - public abstract void deleteTheme(CSSThemeVisualElement theme); + public abstract void deleteTheme(Theme theme); public abstract void deleteThemeById(Long themeId); + + public abstract List getAllCSSThemes(); + + public abstract List getAllFlashThemes(); } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/themes/dao/hibernate/CSSThemeDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/dao/hibernate/CSSThemeDAO.java,v diff -u -r1.6 -r1.6.20.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/dao/hibernate/CSSThemeDAO.java 17 Sep 2006 06:14:25 -0000 1.6 +++ lams_common/src/java/org/lamsfoundation/lams/themes/dao/hibernate/CSSThemeDAO.java 1 Mar 2010 04:54:34 -0000 1.6.20.1 @@ -25,56 +25,56 @@ import java.util.List; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.dao.ICSSThemeDAO; import org.springframework.orm.hibernate3.support.HibernateDaoSupport; /** * This class interacts with Spring's HibernateTemplate to save/delete and - * retrieve CSSThemeVisualElement and other related objects. + * retrieve Theme and other related objects. * * @author Fiona Malikoff -*/ + */ public class CSSThemeDAO extends HibernateDaoSupport implements ICSSThemeDAO { - /** + /** * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#getAllThemes() */ public List getAllThemes() { - return getHibernateTemplate().find("from CSSThemeVisualElement c where c.theme=true"); + return getHibernateTemplate().find("from Theme c"); } /** * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#getThemeById(java.lang.Long) */ - public CSSThemeVisualElement getThemeById(Long themeId) { - String queryString = "from CSSThemeVisualElement c where c.id=?"; - List list = getHibernateTemplate().find(queryString,themeId); - if ( list != null && list.size() > 0 ) - return (CSSThemeVisualElement) list.get(0); - else - return null; + public Theme getThemeById(Long themeId) { + String queryString = "from Theme c where c.themeId=?"; + List list = getHibernateTemplate().find(queryString, themeId); + if (list != null && list.size() > 0) + return (Theme) list.get(0); + else + return null; } - /** + /** * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#getThemeByName(java.lang.String) */ public List getThemeByName(String name) { - String queryString = "from CSSThemeVisualElement c where c.name=? and c.theme=true"; - return getHibernateTemplate().find(queryString,name); + String queryString = "from Theme c where c.name=?"; + return getHibernateTemplate().find(queryString, name); } /** * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#saveOrUpdateTheme(org.lamsfoundation.lams.usermanagement.User) */ - public void saveOrUpdateTheme(CSSThemeVisualElement theme) { + public void saveOrUpdateTheme(Theme theme) { getHibernateTemplate().saveOrUpdate(theme); } /** * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#deleteTheme(org.lamsfoundation.lams.usermanagement.User) */ - public void deleteTheme(CSSThemeVisualElement theme) { + public void deleteTheme(Theme theme) { getHibernateTemplate().delete(theme); } @@ -85,4 +85,18 @@ getHibernateTemplate().delete(getThemeById(themeId)); } + /** + * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#getAllCSSThemes() + */ + public List getAllCSSThemes() { + return getHibernateTemplate().find("from Theme c where c.type=1"); + } + + /** + * @see org.lamsfoundation.lams.themes.dao.ICSSThemeDAO#getAllFlashThemes() + */ + public List getAllFlashThemes() { + return getHibernateTemplate().find("from Theme c where c.type=2"); + } + } Fisheye: Tag 1.6.20.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSStyleDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeBriefDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeBriefDTO.java,v diff -u -r1.6 -r1.6.20.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeBriefDTO.java 17 Sep 2006 06:14:20 -0000 1.6 +++ lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeBriefDTO.java 1 Mar 2010 04:54:34 -0000 1.6.20.1 @@ -24,7 +24,7 @@ package org.lamsfoundation.lams.themes.dto; import org.lamsfoundation.lams.learningdesign.dto.BaseDTO; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; /** * Contains only the basic details for a theme - name, id, etc. Does not @@ -51,9 +51,9 @@ /** * Create the DTO from a database object. */ - public CSSThemeBriefDTO(CSSThemeVisualElement theme) { + public CSSThemeBriefDTO(Theme theme) { if ( theme != null ) { - this.id = theme.getId(); + this.id = theme.getThemeId(); this.name = theme.getName(); this.description = theme.getDescription(); } Index: lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeDTO.java,v diff -u -r1.7 -r1.7.20.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeDTO.java 17 Sep 2006 06:14:20 -0000 1.7 +++ lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSThemeDTO.java 1 Mar 2010 04:54:34 -0000 1.7.20.1 @@ -32,192 +32,123 @@ import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.log4j.Logger; import org.lamsfoundation.lams.learningdesign.dto.BaseDTO; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.util.wddx.WDDXProcessor; import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException; /** - * Models the Theme structure that is used to communicate with Flash. - * Includes all the information from Theme down to each individual property. - * Based on the native Flash structure for Style objects. + * Models the Theme structure that is used to communicate with Flash. Includes + * all the information from Theme down to each individual property. Based on the + * native Flash structure for Style objects. * * @author Fiona Malikoff */ public class CSSThemeDTO extends BaseDTO { - protected Logger log = Logger.getLogger(CSSThemeDTO.class); + protected Logger log = Logger.getLogger(CSSThemeDTO.class); public final static String ID_TAG = "id"; - public final static String NAME_TAG = "name"; + public final static String NAME_TAG = "name"; public final static String DESCRIPTION_TAG = "description"; public final static String BASE_STYLE_OBJECT_TAG = "baseStyleObject"; public final static String VISUAL_ELEMENTS_TAG = "visualElements"; public final static String TEXT_FORMAT_TAG = "_tf"; public final static String STYLE_OBJECT_TAG = "styleObject"; - /* The variables must have the same names as the tags above, or the WDDX packet will have the - * wrong tag names when sent to Flash. We can model the visual elements as CSSVisualElementDTO - * any arbitrary Java class to a hashtable. There is no point modelling the style objects - * as anything but a hashtable, as all they contain are properties. + /* + * The variables must have the same names as the tags above, or the WDDX + * packet will have the wrong tag names when sent to Flash. We can model the + * visual elements as CSSVisualElementDTO any arbitrary Java class to a + * hashtable. There is no point modelling the style objects as anything but + * a hashtable, as all they contain are properties. */ private Long id; private String name; private String description; - private CSSStyleDTO baseStyleObject; - private List visualElements; - - /** - * Create the DTO using the data from Flash - * @throws WDDXProcessorConversionException - */ - public CSSThemeDTO(Hashtable wddxData) throws WDDXProcessorConversionException { - if ( wddxData != null ) { - this.id = WDDXProcessor.convertToLong(wddxData,ID_TAG); - this.name = WDDXProcessor.convertToString(wddxData,NAME_TAG); - this.description = WDDXProcessor.convertToString(wddxData,DESCRIPTION_TAG); - Hashtable so = (Hashtable) wddxData.get(BASE_STYLE_OBJECT_TAG); - if ( so != null ) { - baseStyleObject = new CSSStyleDTO(so); - } - List ve = (List) wddxData.get(VISUAL_ELEMENTS_TAG); - if ( ve != null ) { - int numElements = ve.size(); - visualElements = new ArrayList(numElements); - Iterator iter = ve.iterator(); - while ( iter.hasNext() ) { - visualElements.add(new CSSVisualElementDTO((Hashtable) iter.next())); - } - } - } - } - /** - * Create the DTO from a database object. - * - * @throws ParseException - * - */ - public CSSThemeDTO (CSSThemeVisualElement theme){ - if ( theme != null ) { - this.id = theme.getId(); - this.name = theme.getName(); - this.description = theme.getDescription(); - if ( theme.getStyle()!= null ) { - this.baseStyleObject = new CSSStyleDTO(theme.getStyle()); - } - if ( theme.getElements() != null ) { - int numElements = theme.getElements().size(); - if ( numElements > 0 ) { - this.visualElements = new ArrayList(numElements); - Iterator iter = theme.getElements().iterator(); - while ( iter.hasNext() ) { - CSSThemeVisualElement element = (CSSThemeVisualElement) iter.next(); - if ( element.isTheme() ) { - log.error("Theme found within another theme. Flash packet currently doesn't support this format. " - +" Theme being skipped. "+element); - } else { - this.visualElements.add(new CSSVisualElementDTO(element)); - } - } - } - } - } - } - - /** - * Creates the database format object from this DTO. Does not look up any - * existing entries in the database. Does not set the users field. - * - * Don't call it getCSSTheme, or CSSTheme will be be written out in the - * WDDX packet created from the DTO! - */ - public CSSThemeVisualElement createCSSThemeVisualElement() { - CSSThemeVisualElement theme = new CSSThemeVisualElement(); - if ( baseStyleObject != null ) { - theme.setStyle(baseStyleObject.createNewCSSStyle()); - } - theme.setDescription(description); - theme.setName(name); - theme.setId(id); - theme.setTheme(true); - if ( visualElements != null && visualElements.size() > 0 ) { - Iterator iter = visualElements.iterator(); - while (iter.hasNext()) { - CSSVisualElementDTO element = (CSSVisualElementDTO) iter.next(); - theme.addElement(element.createCSSThemeVisualElement()); - } - } - return theme; - } + /** + * Create the DTO using the data from Flash + * + * @throws WDDXProcessorConversionException + */ + public CSSThemeDTO(Hashtable wddxData) throws WDDXProcessorConversionException { + if (wddxData != null) { + this.id = WDDXProcessor.convertToLong(wddxData, ID_TAG); + this.name = WDDXProcessor.convertToString(wddxData, NAME_TAG); + this.description = WDDXProcessor.convertToString(wddxData, DESCRIPTION_TAG); + } + } - /** - * Update an existing CSSTheme object ( probably from the database) with the - * current values. Arguably this functionality belongs in the CSSTheme object but - * that would confused matters as some of the field copying code would be in - * this object, and other bits would be in the CSSTheme object. Does not - * change the user's field. - * - * Changes the parameter object (currentTheme) and returns the modified object. - */ - public CSSThemeVisualElement updateCSSTheme(CSSThemeVisualElement currentTheme) { - if ( baseStyleObject != null ) { - currentTheme.setStyle(baseStyleObject.createNewCSSStyle()); - } else { - currentTheme.setStyle(null); - } - currentTheme.setDescription(description); - currentTheme.setName(name); - currentTheme.setId(id); - currentTheme.clearElements(); - if ( visualElements != null && visualElements.size() > 0 ) { - Iterator iter = visualElements.iterator(); - while (iter.hasNext()) { - CSSVisualElementDTO element = (CSSVisualElementDTO) iter.next(); - currentTheme.addElement(element.createCSSThemeVisualElement()); - } - } - return currentTheme; - } + /** + * Create the DTO from a database object. + * + * @throws ParseException + * + */ + public CSSThemeDTO(Theme theme) { + if (theme != null) { + this.id = theme.getThemeId(); + this.name = theme.getName(); + this.description = theme.getDescription(); + } + } - /** - * @return Returns the baseStyleObject. - */ - public CSSStyleDTO getBaseStyleObject() { - return baseStyleObject; - } - /** - * @return Returns the description. - */ - public String getDescription() { - return description; - } - /** - * @return Returns the id. - */ - public Long getId() { - return id; - } - /** - * @return Returns the name. - */ - public String getName() { - return name; - } - /** - * @return Returns the visualElements. - */ - public List getVisualElements() { - return visualElements; - } - - public String toString() { - return new ToStringBuilder(this) - .append("id", id) - .append("name", name) - .append("description", description) - .append("baseStyleObject", baseStyleObject) - .append("visualElements", visualElements) - .toString(); - } + /** + * Creates the database format object from this DTO. Does not look up any + * existing entries in the database. Does not set the users field. + * + * Don't call it getCSSTheme, or CSSTheme will be be written out in the WDDX + * packet created from the DTO! + */ + public Theme createCSSThemeVisualElement() { + Theme theme = new Theme(); + theme.setDescription(description); + theme.setName(name); + theme.setThemeId(id); + return theme; + } + /** + * Update an existing CSSTheme object ( probably from the database) with the + * current values. Arguably this functionality belongs in the CSSTheme + * object but that would confused matters as some of the field copying code + * would be in this object, and other bits would be in the CSSTheme object. + * Does not change the user's field. + * + * Changes the parameter object (currentTheme) and returns the modified + * object. + */ + public Theme updateCSSTheme(Theme currentTheme) { + + currentTheme.setDescription(description); + currentTheme.setName(name); + return currentTheme; + } + + /** + * @return Returns the description. + */ + public String getDescription() { + return description; + } + + /** + * @return Returns the id. + */ + public Long getId() { + return id; + } + + /** + * @return Returns the name. + */ + public String getName() { + return name; + } + + public String toString() { + return new ToStringBuilder(this).append("id", id).append("name", name).append("description", description) + .toString(); + } + } Fisheye: Tag 1.7.20.1 refers to a dead (removed) revision in file `lams_common/src/java/org/lamsfoundation/lams/themes/dto/CSSVisualElementDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java,v diff -u -r1.11 -r1.11.16.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java 1 Feb 2007 03:43:16 -0000 1.11 +++ lams_common/src/java/org/lamsfoundation/lams/themes/service/IThemeService.java 1 Mar 2010 04:54:33 -0000 1.11.16.1 @@ -24,11 +24,11 @@ package org.lamsfoundation.lams.themes.service; import java.io.IOException; +import java.util.List; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; -import org.lamsfoundation.lams.themes.dao.ICSSThemeDAO; -import org.lamsfoundation.lams.usermanagement.exception.UserException; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.exception.ThemeException; +import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.wddx.FlashMessage; @@ -82,12 +82,12 @@ /** * Returns a theme */ - public CSSThemeVisualElement getTheme(Long themeId); + public Theme getTheme(Long themeId); /** * Returns a theme based on the name. */ - public CSSThemeVisualElement getTheme(String themeName); + public Theme getTheme(String themeName); /** * This method returns a list of all available themes in @@ -105,5 +105,47 @@ public FlashMessage setHtmlTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException; public FlashMessage setFlashTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException; + + /** + * Get all the installed themes + * @return + */ + public List getAllThemes(); + + /** + * Get all the installed CSS themes + * @return + */ + public List getAllCSSThemes(); + + /** + * Get all the installed flash themes + * @return + */ + public List getAllFlashThemes(); + + /** + * Remove a theme + * @param themeId + */ + public void removeTheme(Long themeId); + + /** + * Saves or updates a theme + * @param theme + */ + public void saveOrUpdateTheme(Theme theme); + + /** + * Returns the default css theme for the server + * @return + */ + public Theme getDefaultCSSTheme(); + + /** + * Returns the default theme for the server + * @return + */ + public Theme getDefaultFlashTheme(); } Index: lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java,v diff -u -r1.12 -r1.12.16.1 --- lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java 1 Feb 2007 03:43:16 -0000 1.12 +++ lams_common/src/java/org/lamsfoundation/lams/themes/service/ThemeService.java 1 Mar 2010 04:54:33 -0000 1.12.16.1 @@ -25,20 +25,21 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import org.apache.log4j.Logger; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.dao.ICSSThemeDAO; import org.lamsfoundation.lams.themes.dto.CSSThemeBriefDTO; import org.lamsfoundation.lams.themes.dto.CSSThemeDTO; import org.lamsfoundation.lams.themes.exception.ThemeException; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.wddx.FlashMessage; import org.lamsfoundation.lams.util.wddx.WDDXProcessor; @@ -48,228 +49,292 @@ /** * * @author Mitchell Seaton - * + * */ public class ThemeService implements IThemeService { - protected Logger log = Logger.getLogger(ThemeService.class); - - /** Required DAO's */ - protected ICSSThemeDAO themeDAO; - protected MessageService messageService; - protected IUserManagementService userManagementService; - - public ThemeService() { - - } - - /********************************************** - * Setter Methods - * *******************************************/ - - /** + protected Logger log = Logger.getLogger(ThemeService.class); + + /** Required DAO's */ + protected ICSSThemeDAO themeDAO; + protected MessageService messageService; + protected IUserManagementService userManagementService; + + public ThemeService() { + + } + + /********************************************** + * Setter Methods + * *******************************************/ + + /** * @return Returns the themeDAO. */ public ICSSThemeDAO getThemeDAO() { - return themeDAO; + return themeDAO; } - + /** * - * @param themeDAO The ICSSThemeDAO to set. + * @param themeDAO + * The ICSSThemeDAO to set. */ - public void setThemeDAO(ICSSThemeDAO themeDAO) { - this.themeDAO = themeDAO; - } - + public void setThemeDAO(ICSSThemeDAO themeDAO) { + this.themeDAO = themeDAO; + } + /** * - * @param IUserManagementService The userManagementService to set. + * @param IUserManagementService + * The userManagementService to set. */ - public void setUserManagementService(IUserManagementService userManagementService) { - this.userManagementService = userManagementService; + public void setUserManagementService(IUserManagementService userManagementService) { + this.userManagementService = userManagementService; + } + + /** + * Set i18n MessageService + */ + public void setMessageService(MessageService messageService) { + this.messageService = messageService; + } + + /** + * Get i18n MessageService + */ + public MessageService getMessageService() { + return this.messageService; + } + + /********************************************** + * Utility/Service Methods + * *******************************************/ + + /** + * Store a theme created on a client. + * + * @param wddxPacket + * The WDDX packet received from Flash + * @return String The acknowledgement in WDDX format that the theme has been + * successfully saved. + * @throws IOException + * @throws WddxDeserializationException + * @throws Exception + */ + public String storeTheme(String wddxPacket) throws Exception { + + FlashMessage flashMessage = null; + Hashtable table = (Hashtable) WDDXProcessor.deserialize(wddxPacket); + + CSSThemeDTO themeDTO = new CSSThemeDTO(table); + if (log.isDebugEnabled()) { + log.debug("Converted Theme packet. Packet was \n" + wddxPacket + "\nDTO is\n" + themeDTO); } - - /** - * Set i18n MessageService - */ - public void setMessageService(MessageService messageService) { - this.messageService = messageService; + + Theme dbTheme = null; + Theme storedTheme = null; + if (themeDTO.getId() != null) { + // Flash has supplied an id, get the record from the database for update + dbTheme = themeDAO.getThemeById(themeDTO.getId()); } - /** - * Get i18n MessageService - */ - public MessageService getMessageService() { - return this.messageService; + if (dbTheme == null) { + storedTheme = themeDTO.createCSSThemeVisualElement(); + } else { + storedTheme = themeDTO.updateCSSTheme(dbTheme); } - - /********************************************** - * Utility/Service Methods - * *******************************************/ - - /** - * Store a theme created on a client. - * @param wddxPacket The WDDX packet received from Flash - * @return String The acknowledgement in WDDX format that the theme has been - * successfully saved. - * @throws IOException - * @throws WddxDeserializationException - * @throws Exception - */ - public String storeTheme(String wddxPacket) throws Exception { - - FlashMessage flashMessage= null; - Hashtable table = (Hashtable)WDDXProcessor.deserialize(wddxPacket); - - CSSThemeDTO themeDTO = new CSSThemeDTO(table); - if ( log.isDebugEnabled() ) { - log.debug("Converted Theme packet. Packet was \n"+wddxPacket+ - "\nDTO is\n"+themeDTO); - } + themeDAO.saveOrUpdateTheme(storedTheme); + flashMessage = new FlashMessage(IThemeService.STORE_THEME_MESSAGE_KEY, storedTheme.getThemeId()); + return flashMessage.serializeMessage(); + } - CSSThemeVisualElement dbTheme = null; - CSSThemeVisualElement storedTheme = null; - if ( themeDTO.getId() != null ) { - // Flash has supplied an id, get the record from the database for update - dbTheme = themeDAO.getThemeById(themeDTO.getId()); - } - - if ( dbTheme == null ) { - storedTheme = themeDTO.createCSSThemeVisualElement(); - } else { - storedTheme = themeDTO.updateCSSTheme(dbTheme); - } - - themeDAO.saveOrUpdateTheme(storedTheme); - flashMessage = new FlashMessage(IThemeService.STORE_THEME_MESSAGE_KEY,storedTheme.getId()); - return flashMessage.serializeMessage(); + /** + * Returns a string representing the requested theme in WDDX format + * + * @param themeId + * The id of the theme whose WDDX packet is requested + * @return String The requested theme in WDDX format + * @throws Exception + */ + public String getThemeWDDX(Long themeId) throws IOException { + FlashMessage flashMessage = null; + Theme theme = getTheme(themeId); + if (theme == null) + flashMessage = FlashMessage.getNoSuchTheme("wddxPacket", themeId); + else { + CSSThemeDTO dto = new CSSThemeDTO(theme); + flashMessage = new FlashMessage("getTheme", dto); } + return flashMessage.serializeMessage(); + } - /** - * Returns a string representing the requested theme in WDDX format - * - * @param themeId The id of the theme whose WDDX packet is requested - * @return String The requested theme in WDDX format - * @throws Exception - */ - public String getThemeWDDX(Long themeId)throws IOException { - FlashMessage flashMessage= null; - CSSThemeVisualElement theme = getTheme(themeId); - if(theme==null) - flashMessage = FlashMessage.getNoSuchTheme("wddxPacket",themeId); - else{ - CSSThemeDTO dto = new CSSThemeDTO(theme); - flashMessage = new FlashMessage("getTheme",dto); - } - return flashMessage.serializeMessage(); - } + /** + * Returns a theme + */ + public Theme getTheme(Long themeId) { + return themeDAO.getThemeById(themeId); + } + /** + * Returns a theme based on the name. + */ + public Theme getTheme(String themeName) { + List themes = themeDAO.getThemeByName(themeName); + if (themes != null && themes.size() > 0) + return (Theme) themes.get(0); + else + return null; + } - /** - * Returns a theme - */ - public CSSThemeVisualElement getTheme(Long themeId) { - return themeDAO.getThemeById(themeId); + /** + * This method returns a list of all available themes in WDDX format. We + * need to work out if this should be restricted by user. + * + * @return String The required information in WDDX format + * @throws IOException + */ + public String getThemes() throws IOException { + FlashMessage flashMessage = null; + List themes = themeDAO.getAllThemes(); + ArrayList themeList = new ArrayList(); + Iterator iterator = themes.iterator(); + while (iterator.hasNext()) { + CSSThemeBriefDTO dto = new CSSThemeBriefDTO((Theme) iterator.next()); + themeList.add(dto); } + flashMessage = new FlashMessage("getThemes", themeList); + return flashMessage.serializeMessage(); + } + /** + * Set the User's theme + * + * @return String The acknowledgement or error in WDDX format + * @throws IOException + */ + private FlashMessage setTheme(Integer userId, Long themeId, String type) throws IOException, ThemeException, + UserException { + FlashMessage flashMessage = null; + User user = (User) userManagementService.findById(User.class, userId); + Theme theme = themeDAO.getThemeById(themeId); - /** - * Returns a theme based on the name. - */ - public CSSThemeVisualElement getTheme(String themeName) { - List themes = themeDAO.getThemeByName(themeName); - if ( themes != null && themes.size() > 0 ) - return (CSSThemeVisualElement) themes.get(0); - else - return null; + if (theme == null) + throw new ThemeException(messageService.getMessage(IThemeService.NO_SUCH_THEME_KEY)); + else if (user == null) + throw new UserException(messageService.getMessage(IThemeService.NO_SUCH_USER_KEY)); + else { + if (type == null) { + user.setHtmlTheme(theme); + user.setFlashTheme(theme); + } else if (type.equals(IThemeService.FLASH_KEY)) + user.setFlashTheme(theme); + + else if (type.equals(IThemeService.HTML_KEY)) + user.setHtmlTheme(theme); + + userManagementService.save(user); + flashMessage = new FlashMessage("setTheme", messageService + .getMessage(IThemeService.SET_THEME_SAVED_MESSAGE_KEY)); } + return flashMessage; + } - /** - * This method returns a list of all available themes in - * WDDX format. We need to work out if this should be restricted - * by user. - * - * @return String The required information in WDDX format - * @throws IOException - */ - public String getThemes() throws IOException { - FlashMessage flashMessage= null; - List themes = themeDAO.getAllThemes(); - ArrayList themeList = new ArrayList(); - Iterator iterator = themes.iterator(); - while(iterator.hasNext()){ - CSSThemeBriefDTO dto = new CSSThemeBriefDTO((CSSThemeVisualElement)iterator.next()); - themeList.add(dto); + /** + * Set the User's theme (Common) + * + * @return FlashMessage The acknowledgement or error in WDDX format + * @throws IOException + */ + public FlashMessage setTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { + return setTheme(userId, themeId, null); + } + + /** + * Set the User's HTML theme + * + * @return FlashMessage The acknowledgement or error in WDDX format + * @throws IOException + */ + public FlashMessage setHtmlTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { + return setTheme(userId, themeId, IThemeService.HTML_KEY); + } + + /** + * Set the User's Flash theme + * + * @return FlashMessage The acknowledgement or error in WDDX format + * @throws IOException + */ + public FlashMessage setFlashTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { + return setTheme(userId, themeId, IThemeService.FLASH_KEY); + } + + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#getAllThemes() + */ + @SuppressWarnings("unchecked") + public List getAllThemes(){ + return (List)themeDAO.getAllThemes(); + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#removeTheme(java.lang.Long) + */ + public void removeTheme(Long themeId) { + themeDAO.deleteThemeById(themeId); + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#saveOrUpdateTheme(org.lamsfoundation.lams.themes.Theme) + */ + public void saveOrUpdateTheme(Theme theme) { + themeDAO.saveOrUpdateTheme(theme); + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#getDefaultTheme() + */ + public Theme getDefaultCSSTheme() { + List themes = getAllThemes(); + String defaultTheme = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + for (Theme theme : themes) { + if (theme.getName().equals(defaultTheme)) { + return theme; + } } - flashMessage = new FlashMessage("getThemes",themeList); - return flashMessage.serializeMessage(); - } - - /** - * Set the User's theme - * - * @return String The acknowledgement or error in WDDX format - * @throws IOException - */ - private FlashMessage setTheme(Integer userId, Long themeId, String type) throws IOException, ThemeException, UserException { - FlashMessage flashMessage= null; - User user = (User)userManagementService.findById(User.class,userId); - CSSThemeVisualElement theme = themeDAO.getThemeById(themeId); - - if(theme==null) - throw new ThemeException(messageService.getMessage(IThemeService.NO_SUCH_THEME_KEY)); - else if(user==null) - throw new UserException(messageService.getMessage(IThemeService.NO_SUCH_USER_KEY)); - else{ - if(type==null) { - user.setHtmlTheme(theme); - user.setFlashTheme(theme); - } - else if(type.equals(IThemeService.FLASH_KEY)) - user.setFlashTheme(theme); - - else if(type.equals(IThemeService.HTML_KEY)) - user.setHtmlTheme(theme); - - userManagementService.save(user); - flashMessage = new FlashMessage("setTheme", messageService.getMessage(IThemeService.SET_THEME_SAVED_MESSAGE_KEY)); + return null; + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#getDefaultTheme() + */ + public Theme getDefaultFlashTheme() { + List themes = getAllThemes(); + String defaultTheme = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); + for (Theme theme : themes) { + if (theme.getName().equals(defaultTheme)) { + return theme; + } } - - return flashMessage; - } - - /** - * Set the User's theme (Common) - * - * @return FlashMessage The acknowledgement or error in WDDX format - * @throws IOException - */ - public FlashMessage setTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { - return setTheme(userId, themeId, null); - } - - /** - * Set the User's HTML theme - * - * @return FlashMessage The acknowledgement or error in WDDX format - * @throws IOException - */ - public FlashMessage setHtmlTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { - return setTheme(userId, themeId, IThemeService.HTML_KEY); - } - - /** - * Set the User's Flash theme - * - * @return FlashMessage The acknowledgement or error in WDDX format - * @throws IOException - */ - public FlashMessage setFlashTheme(Integer userId, Long themeId) throws IOException, ThemeException, UserException { - return setTheme(userId, themeId, IThemeService.FLASH_KEY); - } + return null; + } - + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#getAlCSSThemes() + */ + public List getAllCSSThemes() { + return themeDAO.getAllCSSThemes(); + } + + /* (non-Javadoc) + * @see org.lamsfoundation.lams.themes.service.IThemeService#getAlFlashThemes() + */ + public List getAllFlashThemes() { + return themeDAO.getAllFlashThemes(); + } + } \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java,v diff -u -r1.36.4.5.2.1 -r1.36.4.5.2.2 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java 25 Feb 2010 18:32:46 -0000 1.36.4.5.2.1 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/User.java 1 Mar 2010 04:54:34 -0000 1.36.4.5.2.2 @@ -35,7 +35,7 @@ import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.dto.CSSThemeBriefDTO; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.dto.UserFlashDTO; @@ -125,10 +125,10 @@ private Set userOrganisations; /** persistent field */ - private CSSThemeVisualElement flashTheme; + private Theme flashTheme; /** persistent field */ - private CSSThemeVisualElement htmlTheme; + private Theme htmlTheme; /** nullable persistent field */ private String chatId; @@ -178,7 +178,7 @@ String addressLine2, String addressLine3, String city, String state, String postcode, String country, String dayPhone, String eveningPhone, String mobilePhone, String fax, String email, Boolean disabledFlag, Date createDate, Workspace workspace, AuthenticationMethod authenticationMethod, - CSSThemeVisualElement flashTheme, CSSThemeVisualElement htmlTheme, Set userOrganisations, String chatId, + Theme flashTheme, Theme htmlTheme, Set userOrganisations, String chatId, Set learnerProgresses, Set userToolSessions, Set userGroups, Set learningDesigns, Set lessons, Long portraitUuid, Boolean changePassword, Boolean enableFlash, String lamsCommunityToken) { this.login = login; @@ -518,11 +518,11 @@ * @hibernate.column name="flash_theme_id" * */ - public CSSThemeVisualElement getFlashTheme() { + public Theme getFlashTheme() { return flashTheme; } - public void setFlashTheme(CSSThemeVisualElement flashTheme) { + public void setFlashTheme(Theme flashTheme) { this.flashTheme = flashTheme; } @@ -531,11 +531,11 @@ * @hibernate.column name="html_theme_id" * */ - public CSSThemeVisualElement getHtmlTheme() { + public Theme getHtmlTheme() { return htmlTheme; } - public void setHtmlTheme(CSSThemeVisualElement htmlTheme) { + public void setHtmlTheme(Theme htmlTheme) { this.htmlTheme = htmlTheme; } Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java,v diff -u -r1.19.4.3 -r1.19.4.3.2.1 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java 19 Jun 2009 04:32:09 -0000 1.19.4.3 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/dto/UserDTO.java 1 Mar 2010 04:54:33 -0000 1.19.4.3.2.1 @@ -42,7 +42,6 @@ private String fckLanguageMapping; private String direction; private String email; - // private CSSThemeVisualElement theme; private CSSThemeBriefDTO flashTheme; private CSSThemeBriefDTO htmlTheme; private TimeZone timeZone; @@ -52,16 +51,6 @@ private String lamsCommunityUsername; private Boolean loggedIntoLamsCommunity; - // public UserDTO(Integer userID, String firstName, String lastName, - // String login, String email, CSSThemeVisualElement theme) { - // this.userID = userID; - // this.firstName = firstName; - // this.lastName = lastName; - // this.login = login; - // this.email = email; - // this.theme = theme; - // } - public UserDTO(Integer userID, String firstName, String lastName, String login, String localeLanguage, String localeCountry, String direction, String email, CSSThemeBriefDTO flashTheme, CSSThemeBriefDTO htmlTheme, TimeZone timezone, Integer authenticationMethodId, String fckLanguageMapping, @@ -222,12 +211,4 @@ this.loggedIntoLamsCommunity = loggedIntoLamsCommunity; } - // public CSSThemeVisualElement getTheme() { - // return theme; - // } - // - // public void setTheme(CSSThemeVisualElement theme) { - // this.theme = theme; - // } - } Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java,v diff -u -r1.60.6.1 -r1.60.6.2 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java 25 Feb 2010 18:32:46 -0000 1.60.6.1 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/IUserManagementService.java 1 Mar 2010 04:54:33 -0000 1.60.6.2 @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Vector; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.ForgotPasswordRequest; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationType; @@ -405,13 +405,13 @@ * Get default flash theme of server. * @return default flash theme object */ - public CSSThemeVisualElement getDefaultFlashTheme(); + public Theme getDefaultFlashTheme(); /** * Get default html theme of server. * @return default html theme object */ - public CSSThemeVisualElement getDefaultHtmlTheme(); + public Theme getDefaultHtmlTheme(); public void auditPasswordChanged(User user, String moduleName); Index: lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java,v diff -u -r1.102.6.2 -r1.102.6.3 --- lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java 25 Feb 2010 18:32:46 -0000 1.102.6.2 +++ lams_common/src/java/org/lamsfoundation/lams/usermanagement/service/UserManagementService.java 1 Mar 2010 04:54:33 -0000 1.102.6.3 @@ -41,7 +41,7 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.dao.IBaseDAO; import org.lamsfoundation.lams.learningdesign.dao.IGroupDAO; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.usermanagement.ForgotPasswordRequest; import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.OrganisationType; @@ -1029,16 +1029,16 @@ return new Integer(0); } - public CSSThemeVisualElement getDefaultFlashTheme() { - String flashName = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); - List list = findByProperty(CSSThemeVisualElement.class, "name", flashName); - return (list != null ? (CSSThemeVisualElement) list.get(0) : null); + public Theme getDefaultFlashTheme() { + String flashName = Configuration.get(ConfigurationKeys.DEFAULT_FLASH_THEME); + List list = findByProperty(Theme.class, "name", flashName); + return list != null ? (Theme) list.get(0) : null; } - public CSSThemeVisualElement getDefaultHtmlTheme() { - String htmlName = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); - List list = findByProperty(CSSThemeVisualElement.class, "name", htmlName); - return (list != null ? (CSSThemeVisualElement) list.get(0) : null); + public Theme getDefaultHtmlTheme() { + String htmlName = Configuration.get(ConfigurationKeys.DEFAULT_HTML_THEME); + List list = findByProperty(Theme.class, "name", htmlName); + return list != null ? (Theme) list.get(0) : null; } public void auditPasswordChanged(User user, String moduleName) { Index: lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java,v diff -u -r1.10 -r1.10.8.1 --- lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java 23 Jan 2009 06:02:40 -0000 1.10 +++ lams_common/src/java/org/lamsfoundation/lams/util/CSSThemeUtil.java 1 Mar 2010 04:54:33 -0000 1.10.8.1 @@ -37,25 +37,24 @@ // private static Logger log = Logger.getLogger(CSSThemeUtil.class); public static String DEFAULT_HTML_THEME = "defaultHTML"; + public static String DEFAULT_FLASH_THEME = "default"; - public static String DEFAULT_MAIN_HTML_THEME = "defaultMainHTML"; - /** * Will return a list of stylesheets for the current user. * If the user does not have a specific stylesheet, then * the default stylesheet will be included in this list. * The default stylesheet will always be included in this list. * @return */ - public static List getAllUserThemes(String defaultTheme) + public static List getAllUserThemes() { List themeList = new ArrayList(); // Always have default as that defines everything. Other themes // define changes. - themeList.add(defaultTheme); + themeList.add(DEFAULT_HTML_THEME); boolean userThemeFound = false; Index: lams_common/test/java/org/lamsfoundation/lams/themes/dao/TestCSSThemeDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_common/test/java/org/lamsfoundation/lams/themes/dao/Attic/TestCSSThemeDAO.java,v diff -u -r1.6 -r1.6.20.1 --- lams_common/test/java/org/lamsfoundation/lams/themes/dao/TestCSSThemeDAO.java 17 Sep 2006 06:14:23 -0000 1.6 +++ lams_common/test/java/org/lamsfoundation/lams/themes/dao/TestCSSThemeDAO.java 1 Mar 2010 04:54:33 -0000 1.6.20.1 @@ -29,9 +29,7 @@ import java.util.Set; import org.lamsfoundation.lams.test.AbstractCommonTestCase; -import org.lamsfoundation.lams.themes.CSSProperty; -import org.lamsfoundation.lams.themes.CSSStyle; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.dao.hibernate.CSSThemeDAO; import org.lamsfoundation.lams.themes.dto.CSSThemeDTO; @@ -40,224 +38,157 @@ */ public class TestCSSThemeDAO extends AbstractCommonTestCase { - private CSSThemeDAO themeDAO = null; - private final static Long RUBY_THEME_ID = new Long(1); - private final static String RUBY_THEME_NAME = "ruby"; - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - themeDAO =(CSSThemeDAO) context.getBean("themeDAO"); - } + private CSSThemeDAO themeDAO = null; + private final static Long RUBY_THEME_ID = new Long(1); + private final static String RUBY_THEME_NAME = "ruby"; - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + themeDAO = (CSSThemeDAO) context.getBean("themeDAO"); + } - /** - * Constructor for TestCSSThemeDAO. - * @param arg0 - */ - public TestCSSThemeDAO(String arg0) { - super(arg0); - } + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + } - public void testGetAllThemes() { - List list = themeDAO.getAllThemes(); - assertTrue("At least one theme returned", list != null && list.size() > 0 ); - } + /** + * Constructor for TestCSSThemeDAO. + * + * @param arg0 + */ + public TestCSSThemeDAO(String arg0) { + super(arg0); + } - public void testGetThemeById() { - CSSThemeVisualElement theme = themeDAO.getThemeById(RUBY_THEME_ID); - assertTrue("Theme returned is Ruby theme", - theme!=null && RUBY_THEME_NAME.equals(theme.getName())); - } + public void testGetAllThemes() { + List list = themeDAO.getAllThemes(); + assertTrue("At least one theme returned", list != null && list.size() > 0); + } - public void testGetThemeByName() { - List list = themeDAO.getThemeByName(RUBY_THEME_NAME); - assertTrue("At least one theme returned", list != null && list.size() > 0 ); - Iterator iter = list.iterator(); - while (iter.hasNext()) { - CSSThemeVisualElement element = (CSSThemeVisualElement) iter.next(); - assertEquals("Theme has correct name (ruby)",RUBY_THEME_NAME,element.getName()); - } - } + public void testGetThemeById() { + Theme theme = themeDAO.getThemeById(RUBY_THEME_ID); + assertTrue("Theme returned is Ruby theme", theme != null && RUBY_THEME_NAME.equals(theme.getName())); + } - public void testSaveOrUpdateTheme() { - try { - // create a new theme - CSSThemeVisualElement theme = saveTheme("testSaveOrUpdateTheme", "testSaveOrUpdateTheme description"); - Long themeId = theme.getId(); - CSSStyle baseStyle = theme.getStyle(); - Set elements = theme.getElements(); - Iterator iter = elements.iterator(); - CSSThemeVisualElement element = (CSSThemeVisualElement) iter.next(); + public void testGetThemeByName() { + List list = themeDAO.getThemeByName(RUBY_THEME_NAME); + assertTrue("At least one theme returned", list != null && list.size() > 0); + Iterator iter = list.iterator(); + while (iter.hasNext()) { + Theme element = (Theme) iter.next(); + assertEquals("Theme has correct name (ruby)", RUBY_THEME_NAME, element.getName()); + } + } - // update the theme and check the changes - theme.setName("testSaveOrUpdateTheme2"); - theme.setDescription("testSaveOrUpdateTheme2 description"); - element.setName("extendingButton"); - themeDAO.saveOrUpdateTheme(theme); - CSSThemeVisualElement dbTheme = themeDAO.getThemeById(themeId); - checkTheme("testSaveOrUpdateTheme2", themeId, "testSaveOrUpdateTheme2 description", - "extendingButton", dbTheme); + public void testSaveOrUpdateTheme() { + try { + // create a new theme + Theme theme = saveTheme("testSaveOrUpdateTheme", "testSaveOrUpdateTheme description"); + Long themeId = theme.getThemeId(); - } catch (ParseException e) { - fail("ParseException thrown"+e.getMessage()); - } - } + // update the theme and check the changes + theme.setName("testSaveOrUpdateTheme2"); + theme.setDescription("testSaveOrUpdateTheme2 description"); + themeDAO.saveOrUpdateTheme(theme); + Theme dbTheme = themeDAO.getThemeById(themeId); + checkTheme("testSaveOrUpdateTheme2", themeId, "testSaveOrUpdateTheme2 description", "extendingButton", + dbTheme); - - public void testDeleteTheme() { - CSSThemeVisualElement theme = null; - try { - theme = saveTheme("testDeleteTheme", "testDeleteTheme description"); - } catch (ParseException e) { - fail("ParseException thrown"+e.getMessage()); - } - Long themeId = theme.getId(); + } catch (ParseException e) { + fail("ParseException thrown" + e.getMessage()); + } + } - themeDAO.deleteTheme(theme); - themeDAO.getHibernateTemplate().flush(); - CSSThemeVisualElement dbTheme = themeDAO.getThemeById(themeId); - assertNull("Saved theme cannot be retrieved after deletion",dbTheme); - } + public void testDeleteTheme() { + Theme theme = null; + try { + theme = saveTheme("testDeleteTheme", "testDeleteTheme description"); + } catch (ParseException e) { + fail("ParseException thrown" + e.getMessage()); + } + Long themeId = theme.getThemeId(); - public void testDeleteThemeById() { - CSSThemeVisualElement theme = null; - try { - theme = saveTheme("testDeleteThemeById", "testDeleteThemeById description"); - } catch (ParseException e) { - fail("ParseException thrown"+e.getMessage()); - } - Long themeId = theme.getId(); + themeDAO.deleteTheme(theme); + themeDAO.getHibernateTemplate().flush(); + Theme dbTheme = themeDAO.getThemeById(themeId); + assertNull("Saved theme cannot be retrieved after deletion", dbTheme); + } - themeDAO.deleteThemeById(themeId); - themeDAO.getHibernateTemplate().flush(); - CSSThemeVisualElement dbTheme = themeDAO.getThemeById(themeId); - assertNull("Saved theme cannot be retrieved after deletion",dbTheme); - } - - /* ************* End of tests ***********************************/ - - private CSSThemeVisualElement saveTheme(String themeName, String description) throws ParseException { - - CSSThemeVisualElement theme = createNewTheme(themeName, description, "button"); - themeDAO.saveOrUpdateTheme(theme); - Long themeId = theme.getId(); - themeDAO.getHibernateTemplate().flush(); + public void testDeleteThemeById() { + Theme theme = null; + try { + theme = saveTheme("testDeleteThemeById", "testDeleteThemeById description"); + } catch (ParseException e) { + fail("ParseException thrown" + e.getMessage()); + } + Long themeId = theme.getThemeId(); - CSSThemeVisualElement dbTheme = themeDAO.getThemeById(themeId); - assertNotNull("Saved theme can be retrieved",dbTheme); - checkTheme(themeName, themeId, description, "button", dbTheme); - assertEquals(themeName, dbTheme.getName()); - return dbTheme; - } - - /* if you change any of the values in the new theme, please change checkTheme to match */ - private CSSThemeVisualElement createNewTheme(String themeName, String description, String elementName) { - - CSSThemeVisualElement theme = new CSSThemeVisualElement(); + themeDAO.deleteThemeById(themeId); + themeDAO.getHibernateTemplate().flush(); + Theme dbTheme = themeDAO.getThemeById(themeId); + assertNull("Saved theme cannot be retrieved after deletion", dbTheme); + } - theme.setDescription(description); - theme.setName(themeName); - theme.setTheme(true); + /* ************* End of tests ********************************** */ - CSSStyle baseStyle = new CSSStyle(); - CSSProperty property = new CSSProperty("borderStyle", "outset", null); - baseStyle.addProperty(property); - property = new CSSProperty("rollOverColor", new Long(16711680), null); - baseStyle.addProperty(property); - // try it as a double, as that is what WDDX creates - property = new CSSProperty("color", new Double(12452097), CSSThemeDTO.TEXT_FORMAT_TAG); - baseStyle.addProperty(property); + private Theme saveTheme(String themeName, String description) throws ParseException { - theme.setStyle(baseStyle); + Theme theme = createNewTheme(themeName, description, "button"); + themeDAO.saveOrUpdateTheme(theme); + Long themeId = theme.getThemeId(); + themeDAO.getHibernateTemplate().flush(); - CSSStyle elementStyle = new CSSStyle(); - property = new CSSProperty("selectionColor", new Double(16711681), null); - elementStyle.addProperty(property); - property = new CSSProperty("display", "block", CSSThemeDTO.TEXT_FORMAT_TAG); - elementStyle.addProperty(property); - - CSSThemeVisualElement element = new CSSThemeVisualElement(); - element.setName(elementName); - element.setStyle(elementStyle); - element.setTheme(false); + Theme dbTheme = themeDAO.getThemeById(themeId); + assertNotNull("Saved theme can be retrieved", dbTheme); + checkTheme(themeName, themeId, description, "button", dbTheme); + assertEquals(themeName, dbTheme.getName()); + return dbTheme; + } - theme.addElement(element); + /* + * if you change any of the values in the new theme, please change + * checkTheme to match + */ + private Theme createNewTheme(String themeName, String description, String elementName) { + Theme theme = new Theme(); + theme.setDescription(description); + theme.setName(themeName); + Theme element = new Theme(); + element.setName(elementName); + return theme; + } - return theme; - } - - /* This attempts to check that the correct values have been written to the database. Doesn't really work - * as it isn't the db object that it is returned - it is the cached Hibernate object. e.g. if the cascades - * fail and no CSSThemeVisualElement are written to the database, the tested object contains them anyway!!!! - * - * @param themeName - * @param themeId - * @param description - * @param elementName - * @param theme - * @throws ParseException - */ - private void checkTheme(String themeName, Long themeId, String description, String elementName, CSSThemeVisualElement theme) throws ParseException { - - assertEquals(theme.getDescription(), description); - assertEquals(theme.getName(),themeName); - assertTrue("Theme flag for theme is true", theme.isTheme()); - - CSSStyle baseStyle = theme.getStyle(); - assertNotNull(baseStyle); - Set bsproperties = baseStyle.getProperties(); - assertNotNull(bsproperties); - Iterator iter = bsproperties.iterator(); - while (iter.hasNext()) { - CSSProperty property = (CSSProperty) iter.next(); - if ( "borderStyle".equals(property.getName()) ) { - assertEquals(property.getValueAsObject(), "outset"); - assertNull(property.getStyleSubset()); - } else if ( "rollOverColor".equals(property.getName()) ) { - assertEquals(property.getValueAsObject(), new Long(16711680)); - assertNull(property.getStyleSubset()); - } else if ( "color".equals(property.getName()) ) { - assertEquals(property.getValueAsObject(), new Double(12452097)); - assertEquals(property.getStyleSubset(), CSSThemeDTO.TEXT_FORMAT_TAG); - } else { - fail("Unexpected property in baseStyle "+property); - } - } + /* + * This attempts to check that the correct values have been written to the + * database. Doesn't really work as it isn't the db object that it is + * returned - it is the cached Hibernate object. e.g. if the cascades fail + * and no Theme are written to the database, the tested object contains them + * anyway!!!! + * + * @param themeName + * + * @param themeId + * + * @param description + * + * @param elementName + * + * @param theme + * + * @throws ParseException + */ + private void checkTheme(String themeName, Long themeId, String description, String elementName, Theme theme) + throws ParseException { - Set elements = theme.getElements(); - assertNotNull(elements); - iter = elements.iterator(); - while (iter.hasNext()) { - CSSThemeVisualElement element = (CSSThemeVisualElement) iter.next(); - assertEquals(element.getName(), elementName); - assertNull("Description is null",element.getDescription()); - assertFalse("Theme flag for element is false", element.isTheme()); - assertNotNull(element.getStyle()); - assertNotNull(element.getStyle().getProperties()); - Iterator iter2 = element.getStyle().getProperties().iterator(); - while (iter2.hasNext()) { - CSSProperty property= (CSSProperty) iter2.next(); - if ( "selectionColor".equals(property.getName()) ) { - assertEquals(property.getValueAsObject(), new Double(16711681)); - assertNull(property.getStyleSubset()); - } else if ( "display".equals(property.getName()) ) { - assertEquals(property.getValueAsObject(), "block"); - assertEquals(property.getStyleSubset(), CSSThemeDTO.TEXT_FORMAT_TAG); - } else { - fail("Unexpected property in baseStyle "+property); - } - } - } - - } - + assertEquals(theme.getDescription(), description); + assertEquals(theme.getName(), themeName); + } + } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java,v diff -u -r1.34.8.1 -r1.34.8.2 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java 11 Feb 2010 00:32:58 -0000 1.34.8.1 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/ExportPortfolioService.java 1 Mar 2010 04:53:24 -0000 1.34.8.2 @@ -55,7 +55,7 @@ import org.lamsfoundation.lams.lesson.Lesson; import org.lamsfoundation.lams.lesson.dao.ILessonDAO; import org.lamsfoundation.lams.notebook.service.ICoreNotebookService; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.themes.service.IThemeService; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; @@ -510,16 +510,16 @@ * Gets the themes for the current user. This is used to determine the stylesheets included in the export file. We * need the full theme, not just the name, so we can get the directory names for the images. */ - public Collection getUserThemes() { - List themeNames = CSSThemeUtil.getAllUserThemes(CSSThemeUtil.DEFAULT_HTML_THEME); - Set userThemes = new HashSet(); - for (String themeName : themeNames) { - CSSThemeVisualElement theme = themeService.getTheme(themeName); - if (theme != null) { - userThemes.add(theme); - } - } - return userThemes; + public Collection getUserThemes() { + List themeNames = CSSThemeUtil.getAllUserThemes(); + Set userThemes = new HashSet(); + for (String themeName : themeNames) { + Theme theme = themeService.getTheme(themeName); + if (theme != null) { + userThemes.add(theme); + } + } + return userThemes; } } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java,v diff -u -r1.16 -r1.16.10.1 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java 29 May 2007 06:17:40 -0000 1.16 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/service/IExportPortfolioService.java 1 Mar 2010 04:53:24 -0000 1.16.10.1 @@ -30,7 +30,7 @@ import javax.servlet.http.HttpServletRequest; import org.lamsfoundation.lams.learning.export.Portfolio; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.tool.ToolAccessMode; /** * @author mtruong @@ -114,6 +114,6 @@ /** Gets the themes for the current user. This is used to determine the stylesheets * included in the export file. We need the full theme, not just the name, so we can get * the directory names for the images. */ - public Collection getUserThemes(); + public Collection getUserThemes(); } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java,v diff -u -r1.9 -r1.9.10.1 --- lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java 8 Apr 2008 03:32:33 -0000 1.9 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/export/web/action/CSSBundler.java 1 Mar 2010 04:53:24 -0000 1.9.10.1 @@ -37,108 +37,132 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; -import org.lamsfoundation.lams.themes.CSSThemeVisualElement; +import org.lamsfoundation.lams.themes.Theme; import org.lamsfoundation.lams.util.Configuration; import org.lamsfoundation.lams.util.ConfigurationKeys; import org.lamsfoundation.lams.util.HttpUrlConnectionUtil; import org.lamsfoundation.lams.web.filter.LocaleFilter; public class CSSBundler extends Bundler { - private static final String RTL_DIR = "rtl"; // right-to-left direction + private static final String RTL_DIR = "rtl"; // right-to-left direction - Map filesToCopy = null; - HttpServletRequest request = null; - Cookie[] cookies = null; - String outputDirectory = null; - String centralPath = null; + Map filesToCopy = null; + HttpServletRequest request = null; + Cookie[] cookies = null; + String outputDirectory = null; + String centralPath = null; boolean rtl = false; - Collection themes = null; + Collection themes = null; List directoriesRequired; - + /** - * @param centralPath the directory path to the lams-central.war. Assumes that it is an expanded war. + * @param centralPath + * the directory path to the lams-central.war. Assumes that it is + * an expanded war. */ - public CSSBundler(HttpServletRequest request, Cookie[] cookies, String outputDirectory, Collection themes) { - filesToCopy = new HashMap(); + public CSSBundler(HttpServletRequest request, Cookie[] cookies, String outputDirectory, Collection themes) { + filesToCopy = new HashMap(); directoriesRequired = new ArrayList(); this.request = request; this.cookies = cookies; this.outputDirectory = outputDirectory; - this.themes = themes != null ? themes : new ArrayList(); - + this.themes = themes != null ? themes : new ArrayList(); + this.centralPath = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR); - if ( centralPath == null ) { - log.error("Unable to get path to the LAMS ear from the configuration file - the exported portfolios will be missing parts of their css (style and images)."); + if (centralPath == null) { + log + .error("Unable to get path to the LAMS ear from the configuration file - the exported portfolios will be missing parts of their css (style and images)."); } else { centralPath = centralPath + File.separator + "lams-central.war"; } - - String pageDirection = (String) request.getSession().getAttribute(LocaleFilter.DIRECTION); // RTL or LTR (default) - if(pageDirection != null) - if(pageDirection.toLowerCase().equals(RTL_DIR)) + + String pageDirection = (String) request.getSession().getAttribute(LocaleFilter.DIRECTION); // RTL + // or + // LTR + // (default) + if (pageDirection != null) + if (pageDirection.toLowerCase().equals(RTL_DIR)) this.rtl = true; } - - /** Bundle the stylesheets. + + /** + * Bundle the stylesheets. * - * @param outputDirectory directory for the export + * @param outputDirectory + * directory for the export * @param request * @param cookies * @throws IOException */ - public void bundleStylesheet( ) throws IOException - { + public void bundleStylesheet() throws IOException { File central = new File(centralPath); - if ( centralPath == null || ! central.canRead() || ! central.isDirectory() ) { - log.error("Unable to get the path for lams-central or unable to read it as a directory. Bundling stylesheets via http but not including images"); + if (centralPath == null || !central.canRead() || !central.isDirectory()) { + log + .error("Unable to get the path for lams-central or unable to read it as a directory. Bundling stylesheets via http but not including images"); bundleViaHTTP(request, cookies); } else { - log.debug("Copying stylesheets and images from path "+centralPath); + log.debug("Copying stylesheets and images from path " + centralPath); bundleViaCopy(); } - + } - - /** Fallback code if it can't do normal file copies (because it doesn't know the path to lams-central. - * Only does the stylesheets, not the images + + /** + * Fallback code if it can't do normal file copies (because it doesn't know + * the path to lams-central. Only does the stylesheets, not the images * * @param outputDirectory * @param request * @param cookies - * @throws IOException - * @throws FileNotFoundException - * @throws MalformedURLException + * @throws IOException + * @throws FileNotFoundException + * @throws MalformedURLException */ - private void bundleViaHTTP(HttpServletRequest request, Cookie[] cookies) throws MalformedURLException, FileNotFoundException, IOException { - - String cssDirectory = outputDirectory+File.separator+"css"; + private void bundleViaHTTP(HttpServletRequest request, Cookie[] cookies) throws MalformedURLException, + FileNotFoundException, IOException { + + String cssDirectory = outputDirectory + File.separator + "css"; File cssDirectoryFile = new File(cssDirectory); cssDirectoryFile.mkdirs(); - - String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort(); - for ( CSSThemeVisualElement theme : themes) { + String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort(); + + for (Theme theme : themes) { String themeName = theme.getName(); - - String url = (!rtl)? basePath + "/lams/css/" + themeName + ".css" : basePath + "/lams/css/" + themeName + "_" + RTL_DIR + ".css"; - HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? themeName + ".css" : themeName + "_" + RTL_DIR + ".css", cookies); //cookies aren't really needed here. - url = (!rtl)? basePath + "/lams/css/" + themeName + "_learner.css" : basePath + "/lams/css/" + themeName + "_" + RTL_DIR + "_learner.css" ; - HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl)? themeName + "_learner.css" : themeName + "_" + RTL_DIR + "_learner.css", cookies); //cookies aren't really needed here. + String url = (!rtl) ? basePath + "/lams/css/" + themeName + ".css" : basePath + "/lams/css/" + themeName + + "_" + RTL_DIR + ".css"; + HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl) ? themeName + ".css" : themeName + "_" + + RTL_DIR + ".css", cookies); // cookies aren't really + // needed here. + + url = (!rtl) ? basePath + "/lams/css/" + themeName + "_learner.css" : basePath + "/lams/css/" + themeName + + "_" + RTL_DIR + "_learner.css"; + HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, (!rtl) ? themeName + "_learner.css" + : themeName + "_" + RTL_DIR + "_learner.css", cookies); // cookies + // aren't + // really + // needed + // here. } - + // include the special IE stylesheet String url = basePath + "/lams/css/ie-styles.css"; - HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, "ie-styles.css", cookies); //cookies aren't really needed here. - + HttpUrlConnectionUtil.writeResponseToFile(url, cssDirectory, "ie-styles.css", cookies); // cookies + // aren't + // really + // needed + // here. + } - /** Preferred method - copies the files from lams-central.war + /** + * Preferred method - copies the files from lams-central.war * * @param outputDirectory - * @throws IOException + * @throws IOException */ private void bundleViaCopy() throws IOException { @@ -147,11 +171,11 @@ // build up a list of images to copy setupImageList(); - + // now copy all those files createDirectories(directoriesRequired); - for ( Map.Entry fileEntry : filesToCopy.entrySet() ) { - copyFile((String)fileEntry.getKey(), (File)fileEntry.getValue()); + for (Map.Entry fileEntry : filesToCopy.entrySet()) { + copyFile((String) fileEntry.getKey(), (File) fileEntry.getValue()); } } @@ -160,55 +184,56 @@ */ private void setupThemeList() { // build up a list of themes to copy - String cssDirectory = outputDirectory+File.separatorChar+"css"; + String cssDirectory = outputDirectory + File.separatorChar + "css"; directoriesRequired.add(cssDirectory); - - for ( CSSThemeVisualElement theme : themes) { + for (Theme theme : themes) { + String themeName = theme.getName(); - + String themeFilename = (!rtl) ? themeName + ".css" : themeName + "_" + RTL_DIR + ".css"; addThemeFile(cssDirectory, themeFilename); themeFilename = (!rtl) ? themeName + "_learner.css" : themeName + "_" + RTL_DIR + "_learner.css"; addThemeFile(cssDirectory, themeFilename); } - + // include the special IE stylesheet addThemeFile(cssDirectory, "ie-styles.css"); } private void addThemeFile(String cssDirectory, String themeFilename) { File themeFile = new File(centralPath + File.separatorChar + "css" + File.separatorChar + themeFilename); - if ( ! themeFile.canRead() ) { - log.error("Unable to read theme file "+themeFile.getAbsolutePath()); + if (!themeFile.canRead()) { + log.error("Unable to read theme file " + themeFile.getAbsolutePath()); } else { - filesToCopy.put(cssDirectory+File.separatorChar+themeFilename,themeFile); + filesToCopy.put(cssDirectory + File.separatorChar + themeFilename, themeFile); } } private void setupImageList() { - for ( CSSThemeVisualElement theme : themes) { + for (Theme theme : themes) { String dirName = theme.getImageDirectory(); - if ( dirName != null ) { - - String imageDirectory = centralPath+File.separatorChar+"images"+File.separatorChar+dirName; - String outputImageDirectory = outputDirectory+File.separatorChar+"images"+File.separatorChar+dirName; - + if (dirName != null) { + + String imageDirectory = centralPath + File.separatorChar + "images" + File.separatorChar + dirName; + String outputImageDirectory = outputDirectory + File.separatorChar + "images" + File.separatorChar + + dirName; + directoriesRequired.add(outputImageDirectory); - + File dir = new File(imageDirectory); - if ( ! dir.canRead() || ! dir.isDirectory() ) { - log.error("Unable to read css image directory "+dir.getAbsolutePath()); - - } else { - + if (!dir.canRead() || !dir.isDirectory()) { + log.error("Unable to read css image directory " + dir.getAbsolutePath()); + + } else { + File[] files = dir.listFiles(); - for ( File imageFile: files ) { - filesToCopy.put(outputImageDirectory+File.separatorChar+imageFile.getName(),imageFile); + for (File imageFile : files) { + filesToCopy.put(outputImageDirectory + File.separatorChar + imageFile.getName(), imageFile); } } }