Index: lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties =================================================================== diff -u -r8ff342a424c47f78303c3224966eb319dd28f1e4 -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties (.../MonitoringResources.properties) (revision 8ff342a424c47f78303c3224966eb319dd28f1e4) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/MonitoringResources.properties (.../MonitoringResources.properties) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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 =================================================================== diff -u -r8ff342a424c47f78303c3224966eb319dd28f1e4 -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml (.../monitoringApplicationContext.xml) (revision 8ff342a424c47f78303c3224966eb319dd28f1e4) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/monitoringApplicationContext.xml (.../monitoringApplicationContext.xml) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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 =================================================================== diff -u -r13f28765828c265f82ca9f6e3206d686a16b3e10 -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision 13f28765828c265f82ca9f6e3206d686a16b3e10) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java (.../IMonitoringService.java) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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 =================================================================== diff -u -r0c9def7e80f2815641f33893d07de35e8d814b7e -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision 0c9def7e80f2815641f33893d07de35e8d814b7e) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java (.../MonitoringService.java) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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 =================================================================== diff -u -rc9c56707245e3ad1149bf1a5338eb251c96c75d2 -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision c9c56707245e3ad1149bf1a5338eb251c96c75d2) +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java (.../MonitoringAction.java) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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/WEB-INF/struts/struts-config.xml =================================================================== diff -u -r04ddbcceec831fcb71c1c9d160300569ac1547f6 -rb484303f0791f74da268d0706057ce4dd4281946 --- lams_monitoring/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision 04ddbcceec831fcb71c1c9d160300569ac1547f6) +++ lams_monitoring/web/WEB-INF/struts/struts-config.xml (.../struts-config.xml) (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -86,6 +86,11 @@ path="/index.jsp" redirect="false" /> + + LocaleFilter + + org.lamsfoundation.lams.web.filter.LocaleFilter + + + HibernateFilter org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter @@ -112,6 +118,10 @@ /* + LocaleFilter + /* + + HibernateFilter /* Index: lams_monitoring/web/previewdeleted.jsp =================================================================== diff -u --- lams_monitoring/web/previewdeleted.jsp (revision 0) +++ lams_monitoring/web/previewdeleted.jsp (revision b484303f0791f74da268d0706057ce4dd4281946) @@ -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