Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java,v diff -u -r1.29 -r1.30 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 27 Jun 2006 07:47:09 -0000 1.29 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/AuthoringService.java 18 Jul 2006 02:31:54 -0000 1.30 @@ -651,5 +651,9 @@ learningDesignDAO.delete(design); } + public MessageService getMessageService() { + return messageService; + } + } \ No newline at end of file Index: lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java,v diff -u -r1.11 -r1.12 --- lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java 3 Apr 2006 23:28:17 -0000 1.11 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/service/IAuthoringService.java 18 Jul 2006 02:31:54 -0000 1.12 @@ -33,6 +33,7 @@ import org.lamsfoundation.lams.usermanagement.WorkspaceFolder; import org.lamsfoundation.lams.usermanagement.exception.UserException; import org.lamsfoundation.lams.usermanagement.exception.WorkspaceFolderException; +import org.lamsfoundation.lams.util.MessageService; /** * @author Manpreet Minhas @@ -183,4 +184,8 @@ * that is done by the LamsCoreToolService */ public void deleteLearningDesign(LearningDesign design); + + /** Get the message service, which gives access to the I18N text */ + public MessageService getMessageService(); + } Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java,v diff -u -r1.11 -r1.12 --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java 3 Apr 2006 23:28:17 -0000 1.11 +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java 18 Jul 2006 02:31:54 -0000 1.12 @@ -35,14 +35,11 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; -import org.apache.struts.actions.DispatchAction; -import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.authoring.service.IAuthoringService; -import org.lamsfoundation.lams.learningdesign.exception.LearningDesignException; -import org.lamsfoundation.lams.usermanagement.exception.UserException; -import org.lamsfoundation.lams.usermanagement.exception.WorkspaceFolderException; import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.audit.IAuditService; import org.lamsfoundation.lams.util.wddx.FlashMessage; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -65,7 +62,9 @@ * If you want it returned as a stream (ie for Flash), do not define this parameter */ public static String USE_JSP_OUTPUT = "jspoutput"; - + + private static IAuditService auditService; + public IAuthoringService getAuthoringService(){ WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServlet().getServletContext()); return (IAuthoringService) webContext.getBean(AuthoringConstants.AUTHORING_SERVICE_BEAN_NAME); @@ -99,28 +98,43 @@ public ActionForward getLearningDesignDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response)throws ServletException, IOException{ - Long learningDesignID = new Long(WebUtil.readLongParam(request,"learningDesignID")); + HttpServletResponse response)throws ServletException, IOException{ + String wddxPacket; IAuthoringService authoringService = getAuthoringService(); - String wddxPacket = authoringService.getLearningDesignDetails(learningDesignID); + try { + Long learningDesignID = new Long(WebUtil.readLongParam(request,"learningDesignID")); + wddxPacket = authoringService.getLearningDesignDetails(learningDesignID); + } catch (Exception e) { + wddxPacket = handleException(e, "getLearningDesignDetails", authoringService).serializeMessage(); + } return outputPacket(mapping, request, response, wddxPacket, "details"); } public ActionForward getLearningDesignsForUser(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ - Long userID = new Long(WebUtil.readLongParam(request,"userID")); + String wddxPacket; IAuthoringService authoringService = getAuthoringService(); - String wddxPacket = authoringService.getLearningDesignsForUser(userID); + try { + Long userID = new Long(WebUtil.readLongParam(request,"userID")); + wddxPacket = authoringService.getLearningDesignsForUser(userID); + } catch (Exception e) { + wddxPacket = handleException(e, "getLearningDesignsForUser", authoringService).serializeMessage(); + } return outputPacket(mapping, request, response, wddxPacket, "details"); } public ActionForward getAllLearningDesignDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ + String wddxPacket; IAuthoringService authoringService = getAuthoringService(); - String wddxPacket = authoringService.getAllLearningDesignDetails(); + try { + wddxPacket = authoringService.getAllLearningDesignDetails(); + } catch (Exception e) { + wddxPacket = handleException(e, "getAllLearningDesignDetails", authoringService).serializeMessage(); + } log.debug("getAllLearningDesignDetails: returning "+wddxPacket); return outputPacket(mapping, request, response, wddxPacket, "details"); } @@ -129,8 +143,13 @@ ActionForm form, HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{ + String wddxPacket; IAuthoringService authoringService = getAuthoringService(); - String wddxPacket = authoringService.getAllLearningLibraryDetails(); + try { + wddxPacket = authoringService.getAllLearningLibraryDetails(); + } catch (Exception e) { + wddxPacket = handleException(e, "getAllLearningLibraryDetails", authoringService).serializeMessage(); + } log.debug("getAllLearningLibraryDetails: returning "+wddxPacket); return outputPacket(mapping, request, response, wddxPacket, "details"); } @@ -140,10 +159,15 @@ HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - Long toolID = new Long(WebUtil.readLongParam(request,"toolID")); - IAuthoringService authoringService = getAuthoringService(); - String message = authoringService.getToolContentID(toolID); - return outputPacket(mapping, request, response, message, "details"); + String wddxPacket; + IAuthoringService authoringService = getAuthoringService(); + try { + Long toolID = new Long(WebUtil.readLongParam(request,"toolID")); + wddxPacket = authoringService.getToolContentID(toolID); + } catch (Exception e) { + wddxPacket = handleException(e, "getAllLearningLibraryDetails", authoringService).serializeMessage(); + } + return outputPacket(mapping, request, response, wddxPacket, "details"); } @@ -175,12 +199,42 @@ flashMessage = new FlashMessage("getAvailableLicenses", "License details unavailable due to system error :" + e.getMessage(), FlashMessage.ERROR); + + getAuditService().log(AuthoringAction.class.getName(), e.toString()); } PrintWriter writer = response.getWriter(); writer.println(flashMessage.serializeMessage()); return null; } + /** + * Handle flash error. + * @param e + * @param methodKey + * @param monitoringService + * @return + */ + private FlashMessage handleException(Exception e, String methodKey, IAuthoringService authoringService) { + log.error("Exception thrown "+methodKey,e); + getAuditService().log(AuthoringAction.class.getName()+":"+methodKey, e.toString()); + String[] msg = new String[1]; + msg[0] = e.getMessage(); + return new FlashMessage(methodKey, + authoringService.getMessageService().getMessage("error.system.error", msg), + FlashMessage.CRITICAL_ERROR); + } + /** + * Get AuditService bean. + * @return + */ + private IAuditService getAuditService(){ + if(auditService==null){ + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + auditService = (IAuditService) ctx.getBean("auditService"); + } + return auditService; + } + } Index: lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java,v diff -u -r1.30 -r1.31 --- lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java 13 Jul 2006 22:33:50 -0000 1.30 +++ lams_learning/src/java/org/lamsfoundation/lams/learning/web/action/LearnerAction.java 18 Jul 2006 02:31:01 -0000 1.31 @@ -46,10 +46,13 @@ import org.lamsfoundation.lams.lesson.dto.LessonDTO; import org.lamsfoundation.lams.usermanagement.User; import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.audit.IAuditService; import org.lamsfoundation.lams.util.wddx.FlashMessage; import org.lamsfoundation.lams.util.wddx.WDDXProcessor; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; /** @@ -93,7 +96,9 @@ // Class level constants - Struts forward //--------------------------------------------------------------------- private static final String DISPLAY_ACTIVITY = "displayActivity"; - + + private static IAuditService auditService; + private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url) throws IOException, ServletException { if ( url != null ) { String fullURL = WebUtil.convertToFullURL(url); @@ -116,6 +121,9 @@ log.error("Exception thrown "+methodKey,e); String[] msg = new String[1]; msg[0] = e.getMessage(); + + getAuditService().log(LearnerAction.class.getName()+":"+methodKey, e.toString()); + return new FlashMessage(methodKey, learnerService.getMessageService().getMessage("error.system.learner", msg), FlashMessage.CRITICAL_ERROR); @@ -436,4 +444,17 @@ String url = getLearnerActivityURL(request, activityId); return redirectToURL(mapping, response, url); } + + /** + * Get AuditService bean. + * @return + */ + private IAuditService getAuditService(){ + if(auditService==null){ + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext()); + auditService = (IAuditService) ctx.getBean("auditService"); + } + return auditService; + } + } \ No newline at end of file