Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/Attic/MonitoringResources.properties,v diff -u -r1.3 -r1.4 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties 14 Feb 2006 05:06:35 -0000 1.3 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties 22 Feb 2006 23:57:55 -0000 1.4 @@ -6,6 +6,9 @@ label.schedule.gate=Schedule Gate lable.description=Description +#========== Deleted Preview Message Screen =======================# +preview.deleted.title=Preview Data Deleted +preview.deleted.message=Preview data for {0} lesson(s) has been deleted. #Flashmessage NO.SUCH.LESSON=No such Lesson with a lessonID of : {0} exists. Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml,v diff -u -r1.13 -r1.14 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml 14 Feb 2006 05:06:35 -0000 1.13 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml 22 Feb 2006 23:57:55 -0000 1.14 @@ -84,7 +84,7 @@ PROPAGATION_REQUIRED PROPAGATION_REQUIRED PROPAGATION_REQUIRED - PROPAGATION_REQUIRED + PROPAGATION_REQUIRES_NEW PROPAGATION_REQUIRED Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java,v diff -u -r1.38 -r1.39 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 20 Feb 2006 05:41:48 -0000 1.38 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 22 Feb 2006 23:57:55 -0000 1.39 @@ -417,7 +417,9 @@ long lessonID) throws UserAccessDeniedException; /** - * Remove all the details for a particular preview lessons. + * Remove all the details for a particular preview lessons. The transaction + * handling for this method should be REQUIRES_NEW, which allows + * each lesson to be deleted separately. * * @param lessonID ID of the lesson which is the preview session. Mandatory. */ @@ -426,6 +428,11 @@ /** * Remove all the "old" preview lessons. Removes all preview lessons older than * the number of days specified in the configuration file. + *

+ * Calls deletePreviewLesson(long lessonID) to do the actual deletion, so + * if one lesson throws a database exception when deleting, the other lessons + * should delete okay (as deletePreviewLesson uses a REQUIRES_NEW transaction) + * * @return number of lessons deleted. */ public abstract int deleteAllOldPreviewLessons(); Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java,v diff -u -r1.53 -r1.54 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 21 Feb 2006 08:27:38 -0000 1.53 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 22 Feb 2006 23:57:55 -0000 1.54 @@ -1570,14 +1570,12 @@ } else { log.debug("deletePreviewLesson: Removing tool sessions - none exist"); } - - - // get the learning design for this lesson + + // lesson has learning design as a foriegn key, so need to remove lesson before learning design LearningDesign ld = lesson.getLearningDesign(); + deleteLesson(lesson); authoringService.deleteLearningDesign(ld); - // remove the lesson. - deleteLesson(lesson); } else { log.warn("Unable to delete lesson as lesson is not a preview lesson. Learning design copy type was "+lesson.getLearningDesign().getCopyTypeID()); } @@ -1614,8 +1612,12 @@ Iterator iter = sessions.iterator(); while (iter.hasNext()) { Lesson lesson = (Lesson) iter.next(); - deletePreviewLesson(lesson); - numDeleted++; + try { + deletePreviewLesson(lesson); + numDeleted++; + } catch ( Exception e ) { + log.error("Unable to delete lesson "+lesson.getLessonId()+" due to exception.",e); + } } return numDeleted; Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java,v diff -u -r1.19 -r1.20 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 10 Feb 2006 08:30:54 -0000 1.19 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 22 Feb 2006 23:57:55 -0000 1.20 @@ -27,10 +27,12 @@ import java.text.DateFormat; import java.text.ParseException; import java.util.Date; +import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; @@ -40,10 +42,18 @@ import org.lamsfoundation.lams.monitoring.service.IMonitoringService; import org.lamsfoundation.lams.monitoring.service.MonitoringServiceProxy; import org.lamsfoundation.lams.tool.exception.LamsToolServiceException; +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.UserManagementService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.wddx.FlashMessage; import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.HttpSessionManager; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -65,25 +75,33 @@ * handler="org.lamsfoundation.lams.web.util.CustomStrutsExceptionHandler" * @struts:action-forward name="scheduler" path="/TestScheduler.jsp" * @struts.action-forward name = "success" path = "/index.jsp" + * @struts.action-forward name = "previewdeleted" path = "/previewdeleted.jsp" * * ----------------XDoclet Tags-------------------- */ public class MonitoringAction extends LamsDispatchAction { - //--------------------------------------------------------------------- + WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(HttpSessionManager.getInstance().getServletContext()); + UserManagementService userManagementService = (UserManagementService) ctx.getBean("userManagementServiceTarget"); + + //--------------------------------------------------------------------- // Instance variables //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Class level constants - Struts forward //--------------------------------------------------------------------- + private static final String PREVIEW_DELETED_REPORT_SCREEN = "previewdeleted"; /** If you want the output given as a jsp, set the request parameter "jspoutput" to * some value other than an empty string (e.g. 1, true, 0, false, blah). * If you want it returned as a stream (ie for Flash), do not define this parameter */ public static String USE_JSP_OUTPUT = "jspoutput"; - + + /** See deleteOldPreviewLessons */ + public static final String NUM_DELETED = "numDeleted"; + /** Output the supplied WDDX packet. If the request parameter USE_JSP_OUTPUT * is set, then it sets the session attribute "parameterName" to the wddx packet string. * If USE_JSP_OUTPUT is not set, then the packet is written out to the @@ -690,4 +708,17 @@ return null; } + /** Delete all old preview lessons and their related data, across all + * organisations. + * Should go to a monitoring webservice maybe ? */ + public ActionForward deleteOldPreviewLessons(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + + IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet().getServletContext()); + int numDeleted = monitoringService.deleteAllOldPreviewLessons(); + request.setAttribute(NUM_DELETED, Integer.toString(numDeleted)); + return mapping.findForward(PREVIEW_DELETED_REPORT_SCREEN); + } + } Index: lams_monitoring/web/previewdeleted.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/previewdeleted.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_monitoring/web/previewdeleted.jsp 22 Feb 2006 23:57:55 -0000 1.1 @@ -0,0 +1,44 @@ +<%-- +Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +USA + +http://www.gnu.org/licenses/gpl.txt +--%> + +<%@ page language="java"%> +<%@ taglib uri="tags-html" prefix="html"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-fmt" prefix="fmt" %> +<%@ taglib uri="tags-lams" prefix="lams" %> + + + + + + + Learner :: Staff + + + +

+ +

+ +

+ + + \ No newline at end of file Index: lams_monitoring/web/WEB-INF/web.xml =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/WEB-INF/Attic/web.xml,v diff -u -r1.15 -r1.16 --- lams_monitoring/web/WEB-INF/web.xml 2 Feb 2006 05:53:51 -0000 1.15 +++ lams_monitoring/web/WEB-INF/web.xml 22 Feb 2006 23:57:55 -0000 1.16 @@ -75,6 +75,12 @@ + LocaleFilter + + org.lamsfoundation.lams.web.filter.LocaleFilter + + + HibernateFilter org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter @@ -112,6 +118,10 @@ /* + LocaleFilter + /* + + HibernateFilter /* Index: lams_monitoring/web/WEB-INF/struts/struts-config.xml =================================================================== RCS file: /usr/local/cvsroot/lams_monitoring/web/WEB-INF/struts/Attic/struts-config.xml,v diff -u -r1.7 -r1.8 --- lams_monitoring/web/WEB-INF/struts/struts-config.xml 7 Dec 2005 05:11:07 -0000 1.7 +++ lams_monitoring/web/WEB-INF/struts/struts-config.xml 22 Feb 2006 23:57:55 -0000 1.8 @@ -86,6 +86,11 @@ path="/index.jsp" redirect="false" /> +