The action servlet that interacts with learner to start a lams learner - * module, join a user to the lesson and allows a user to exit a lesson.
+ *+ * The action servlet that interacts with learner to start a lams learner module, join a user to the lesson and allows a + * user to exit a lesson. + *
* - *It is also responsible for the interaction between lams server and - * flash. Flash will call method implemented in this class to get progress - * data or trigger a lams server calculation here
+ *+ * It is also responsible for the interaction between lams server and flash. Flash will call method implemented in this + * class to get progress data or trigger a lams server calculation here + *
* - * Note:It needs to extend theLamsDispatchAction
which has
- * been customized to accomodate struts features to solve duplicate
- * submission problem.
+ * Note:It needs to extend the LamsDispatchAction
which has been customized to accomodate struts
+ * features to solve duplicate submission problem.
*
* @author Jacky Fang
* @since 3/03/2005
* @version 1.1
*
* ----------------XDoclet Tags--------------------
*
- * @struts:action path="/learner"
- * parameter="method"
- * validate="false"
- * @struts:action-forward name="displayActivity" path="/DisplayActivity.do"
- * @struts:action-forward name="displayProgress" path="/progress.jsp"
- * ----------------XDoclet Tags--------------------
+ * @struts:action path="/learner" parameter="method" validate="false"
+ * @struts:action-forward name="displayActivity" path="/DisplayActivity.do"
+ * @struts:action-forward name="displayProgress" path="/progress.jsp" ----------------XDoclet Tags--------------------
*
*/
-public class LearnerAction extends LamsDispatchAction
-{
- //---------------------------------------------------------------------
+public class LearnerAction extends LamsDispatchAction {
+ // ---------------------------------------------------------------------
// Instance variables
- //---------------------------------------------------------------------
- private static Logger log = Logger.getLogger(LearnerAction.class);
-
- //---------------------------------------------------------------------
+ // ---------------------------------------------------------------------
+ private static Logger log = Logger.getLogger(LearnerAction.class);
+
+ // ---------------------------------------------------------------------
// Class level constants - Struts forward
- //---------------------------------------------------------------------
-
- private static IAuditService auditService;
-
- private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url) throws IOException, ServletException {
- if ( url != null ) {
- String fullURL = WebUtil.convertToFullURL(url);
- response.sendRedirect(response.encodeRedirectURL(fullURL));
- } else {
- throw new ServletException("Tried to redirect to url but url is null");
- }
- return null;
- }
+ // ---------------------------------------------------------------------
- /** Handle an exception - either thrown by the service or by the web layer. Allows the exception
- * to be logged properly and ensure that an actual message goes back to Flash.
- *
- * @param e
- * @param methodKey
- * @param learnerService
- * @return
- */
- protected FlashMessage handleException(Exception e, String methodKey, ICoreLearnerService learnerService) {
- 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);
+ private static IAuditService auditService;
+
+ private ActionForward redirectToURL(ActionMapping mapping, HttpServletResponse response, String url)
+ throws IOException, ServletException {
+ if (url != null) {
+ String fullURL = WebUtil.convertToFullURL(url);
+ response.sendRedirect(response.encodeRedirectURL(fullURL));
+ } else {
+ throw new ServletException("Tried to redirect to url but url is null");
}
+ return null;
+ }
/**
- * The structs dispatch action that joins a learner into a lesson. This - * call is used for a user to start a lesson.
+ * Handle an exception - either thrown by the service or by the web layer. Allows the exception to be logged + * properly and ensure that an actual message goes back to Flash. * - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. + * @param e + * @param methodKey + * @param learnerService + * @return + */ + protected FlashMessage handleException(Exception e, String methodKey, ICoreLearnerService learnerService) { + LearnerAction.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); + } + + /** + *+ * The structs dispatch action that joins a learner into a lesson. This call is used for a user to start a lesson. + *
* - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. * + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. + * * @throws IOException * @throws ServletException */ - public ActionForward joinLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - //initialize service object - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - Integer learner = null; - try { - - //get user and lesson based on request. - learner = LearningWebUtil.getUserId(); - long lessonID = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - - - if(log.isDebugEnabled()) - log.debug("The learner ["+learner+"] is joining the lesson ["+lessonID+"]"); - - //join user to the lesson on the server - LearnerProgress learnerProgress = learnerService.joinLesson(learner,lessonID); - - if(log.isDebugEnabled()) - log.debug("The learner ["+learner+"] joined lesson. The" - +"progress data is:"+learnerProgress.toString()); - - LearningWebUtil.putLearnerProgressInRequest(request,learnerProgress); - - ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); - String url = "learning/" + activityMapping.getDisplayActivityAction(lessonID); - - redirectToURL(mapping, response, url); - - } catch (Exception e ) { - log.error("An error occurred while learner "+learner+" attempting to join the lesson.",e); - return mapping.findForward(ActivityMapping.ERROR); - } - - return null; + public ActionForward joinLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + // initialize service object + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + Integer learner = null; + try { + + // get user and lesson based on request. + learner = LearningWebUtil.getUserId(); + long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("The learner [" + learner + "] is joining the lesson [" + lessonID + "]"); + } + + // join user to the lesson on the server + LearnerProgress learnerProgress = learnerService.joinLesson(learner, lessonID); + + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("The learner [" + learner + "] joined lesson. The" + "progress data is:" + + learnerProgress.toString()); + } + + LearningWebUtil.putLearnerProgressInRequest(request, learnerProgress); + + ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet() + .getServletContext()); + String url = "learning/" + activityMapping.getDisplayActivityAction(lessonID); + + redirectToURL(mapping, response, url); + + } catch (Exception e) { + LearnerAction.log + .error("An error occurred while learner " + learner + " attempting to join the lesson.", e); + return mapping.findForward(ActivityMapping.ERROR); + } + + return null; } - + /** - *The structs dispatch action that joins a learner into a lesson. This - * call is used for a user to resume a lesson.
+ *+ * The structs dispatch action that joins a learner into a lesson. This call is used for a user to resume a lesson. + *
* - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * * @throws IOException * @throws ServletException */ - public ActionForward resumeLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - //initialize service object - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + public ActionForward resumeLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + // initialize service object + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - FlashMessage message = null; - try { - - //get user and lesson based on request. - Integer learner = LearningWebUtil.getUserId(); - long lessonID = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - - - if(log.isDebugEnabled()) - log.debug("The learner ["+learner+"] is joining the lesson ["+lessonID+"]"); - - //join user to the lesson on the server - LearnerProgress learnerProgress = learnerService.joinLesson(learner,lessonID); - - if(log.isDebugEnabled()) - log.debug("The learner ["+learner+"] joined lesson. The" - +"porgress data is:"+learnerProgress.toString()); - - LearningWebUtil.putLearnerProgressInRequest(request,learnerProgress); - - //serialize a acknowledgement flash message with the path of display next - //activity - - ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); - message = new FlashMessage("joinLesson", activityMapping.getDisplayActivityAction(null)); - - } catch (Exception e ) { - message = handleException(e, "joinLesson", learnerService); - } - - String wddxPacket = WDDXProcessor.serialize(message); - if(log.isDebugEnabled()) - log.debug("Sending Lesson joined acknowledge message to flash:"+wddxPacket); - - //we hand over the control to flash. - response.getWriter().print(wddxPacket); - return null; + FlashMessage message = null; + try { + + // get user and lesson based on request. + Integer learner = LearningWebUtil.getUserId(); + long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("The learner [" + learner + "] is joining the lesson [" + lessonID + "]"); + } + + // join user to the lesson on the server + LearnerProgress learnerProgress = learnerService.joinLesson(learner, lessonID); + + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("The learner [" + learner + "] joined lesson. The" + "porgress data is:" + + learnerProgress.toString()); + } + + LearningWebUtil.putLearnerProgressInRequest(request, learnerProgress); + + // serialize a acknowledgement flash message with the path of display next + // activity + + ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet() + .getServletContext()); + message = new FlashMessage("joinLesson", activityMapping.getDisplayActivityAction(null)); + + } catch (Exception e) { + message = handleException(e, "joinLesson", learnerService); + } + + String wddxPacket = WDDXProcessor.serialize(message); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Sending Lesson joined acknowledge message to flash:" + wddxPacket); + } + + // we hand over the control to flash. + response.getWriter().print(wddxPacket); + return null; } /** - *Exit the current lesson that is running in the leaner window. It - * expects lesson id passed as parameter from flash component. + *
+ * Exit the current lesson that is running in the leaner window. It expects lesson id passed as parameter from flash + * component. * - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * * @throws IOException * @throws ServletException */ - public ActionForward exitLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - //initialize service object - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + public ActionForward exitLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + // initialize service object + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - FlashMessage message = null; - try { - // get user and lesson based on request. - Integer learner = LearningWebUtil.getUserId(); - Long lessonID = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); - - if(log.isDebugEnabled()) - log.debug("Exiting lesson, lesson id is: "+lessonID); - - learnerService.exitLesson(learner, lessonID); - - //send acknowledgment to flash as it is triggered by flash - message = new FlashMessage("exitLesson", true); + FlashMessage message = null; + try { + // get user and lesson based on request. + Integer learner = LearningWebUtil.getUserId(); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - } catch (Exception e ) { - message = handleException(e, "exitLesson", learnerService); - } - - String wddxPacket = WDDXProcessor.serialize(message); - if(log.isDebugEnabled()) - log.debug("Sending Exit Lesson acknowledge message to flash:"+wddxPacket); - response.getWriter().print(wddxPacket); - return null; + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Exiting lesson, lesson id is: " + lessonID); + } + + learnerService.exitLesson(learner, lessonID); + + // send acknowledgment to flash as it is triggered by flash + message = new FlashMessage("exitLesson", true); + + } catch (Exception e) { + message = handleException(e, "exitLesson", learnerService); + } + + String wddxPacket = WDDXProcessor.serialize(message); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Sending Exit Lesson acknowledge message to flash:" + wddxPacket); + } + response.getWriter().print(wddxPacket); + return null; } - + /** - * Gets the basic lesson details (name, descripton, etc) for a lesson. Contains a LessonDTO. - * Takes a single parameter lessonID + * Gets the basic lesson details (name, descripton, etc) for a lesson. Contains a LessonDTO. Takes a single + * parameter lessonID */ - public ActionForward getLesson(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { + public ActionForward getLesson(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { - //initialize service object - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + // initialize service object + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - FlashMessage message = null; - try { + FlashMessage message = null; + try { - Long lessonID = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID); + Long lessonID = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); - if(log.isDebugEnabled()) - log.debug("get lesson..."+lessonID); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("get lesson..." + lessonID); + } - LessonDTO dto = learnerService.getLessonData(lessonID); - - //send acknowledgment to flash as it is triggerred by flash - message = new FlashMessage("getLesson",dto); + LessonDTO dto = learnerService.getLessonData(lessonID); - } catch (Exception e ) { - message = handleException(e, "getLesson", learnerService); - } - - String wddxPacket = WDDXProcessor.serialize(message); - if(log.isDebugEnabled()) - log.debug("Sending getLesson data message to flash:"+wddxPacket); - response.getWriter().print(wddxPacket); - return null; + // send acknowledgment to flash as it is triggerred by flash + message = new FlashMessage("getLesson", dto); + + } catch (Exception e) { + message = handleException(e, "getLesson", learnerService); + } + + String wddxPacket = WDDXProcessor.serialize(message); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Sending getLesson data message to flash:" + wddxPacket); + } + response.getWriter().print(wddxPacket); + return null; } - + /** - *
The struts dispatch action to retrieve the progress data from the - * server and tailor it into the object struture that expected by flash. - * A wddx packet with object data struture is sent back in the end of this - * call. It is used to construct or restore the flash learner progress - * bar
+ *+ * The struts dispatch action to retrieve the progress data from the server and tailor it into the object struture + * that expected by flash. A wddx packet with object data struture is sent back in the end of this call. It is used + * to construct or restore the flash learner progress bar + *
* - *Gets the most recent copy from the database - not the cached version. - * That way if the cached version has problems, at least we start off right! + *
+ * Gets the most recent copy from the database - not the cached version. That way if the cached version has + * problems, at least we start off right! *
* - *As this process is expensive, the server is only expecting this call - * whenever is necessary. For example, starting, resuming and restoring - * a new lesson. And it should not happen every time that learner is - * progressing to next activity.
+ *+ * As this process is expensive, the server is only expecting this call whenever is necessary. For example, + * starting, resuming and restoring a new lesson. And it should not happen every time that learner is progressing to + * next activity. + *
* - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * @throws IOException * @throws ServletException */ - public ActionForward getFlashProgressData(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - if(log.isDebugEnabled()) - log.debug("Getting Flash progress data..."); - - FlashMessage message = null; - try { - - //SessionBean sessionBean = LearningWebUtil.getSessionBean(request,getServlet().getServletContext()); - - Integer learnerId = LearningWebUtil.getUserId(); - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - - Long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID ); - LearnerProgressDTO learnerProgress = learnerService.getProgressDTOByLessonId(lessonId, learnerId); - - message = new FlashMessage("getFlashProgressData",learnerProgress); + public ActionForward getFlashProgressData(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Getting Flash progress data..."); + } - } catch (Exception e ) { - message = handleException(e, "getFlashProgressData", LearnerServiceProxy.getLearnerService(getServlet().getServletContext())); - } - - String wddxPacket = WDDXProcessor.serialize(message); - if(log.isDebugEnabled()) - log.debug("Sending learner progress data to flash:"+wddxPacket); - response.getWriter().print(wddxPacket); + FlashMessage message = null; + try { - //don't need to return a action forward because it sent the wddx packet - //back already. - return null; + // SessionBean sessionBean = LearningWebUtil.getSessionBean(request,getServlet().getServletContext()); + + Integer learnerId = LearningWebUtil.getUserId(); + ICoreLearnerService learnerService = LearnerServiceProxy + .getLearnerService(getServlet().getServletContext()); + + Long lessonId = WebUtil.readLongParam(request, AttributeNames.PARAM_LESSON_ID); + LearnerProgressDTO learnerProgress = learnerService.getProgressDTOByLessonId(lessonId, learnerId); + + message = new FlashMessage("getFlashProgressData", learnerProgress); + + } catch (Exception e) { + message = handleException(e, "getFlashProgressData", LearnerServiceProxy.getLearnerService(getServlet() + .getServletContext())); + } + + String wddxPacket = WDDXProcessor.serialize(message); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Sending learner progress data to flash:" + wddxPacket); + } + response.getWriter().print(wddxPacket); + + // don't need to return a action forward because it sent the wddx packet + // back already. + return null; } - + /** - *The struts dispatch action to view the activity. This will be called - * by flash progress bar to check up the activity component. The lams side - * will calculate the url and send a flash message back to the - * flash component.
+ *+ * The struts dispatch action to view the activity. This will be called by flash progress bar to check up the + * activity component. The lams side will calculate the url and send a flash message back to the flash component. + *
* - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. * - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * @throws IOException * @throws ServletException */ - public ActionForward getLearnerActivityURL(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - if(log.isDebugEnabled()) - log.debug("Getting url for learner activity..."); + public ActionForward getLearnerActivityURL(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException, ServletException { + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Getting url for learner activity..."); + } - FlashMessage message = null; - try { + FlashMessage message = null; + try { - // get the activity id and calculate the url for this activity. - long activityId = WebUtil.readLongParam(request,AttributeNames.PARAM_ACTIVITY_ID); - String url = getLearnerActivityURL(request, activityId); - - //send data back to flash. - ProgressActivityDTO activityDTO = new ProgressActivityDTO(new Long(activityId),url); - message = new FlashMessage("getLearnerActivityURL",activityDTO); + // get the activity id and calculate the url for this activity. + long activityId = WebUtil.readLongParam(request, AttributeNames.PARAM_ACTIVITY_ID); + String url = getLearnerActivityURL(request, activityId); - } catch (Exception e ) { - message = handleException(e, "getLearnerActivityURL", LearnerServiceProxy.getLearnerService(getServlet().getServletContext())); - } - - String wddxPacket = WDDXProcessor.serialize(message); - if(log.isDebugEnabled()) - log.debug("Sending learner activity url data to flash:"+wddxPacket); - - response.getWriter().print(wddxPacket); - return null; + // send data back to flash. + ProgressActivityDTO activityDTO = new ProgressActivityDTO(new Long(activityId), url); + message = new FlashMessage("getLearnerActivityURL", activityDTO); + + } catch (Exception e) { + message = handleException(e, "getLearnerActivityURL", LearnerServiceProxy.getLearnerService(getServlet() + .getServletContext())); + } + + String wddxPacket = WDDXProcessor.serialize(message); + if (LearnerAction.log.isDebugEnabled()) { + LearnerAction.log.debug("Sending learner activity url data to flash:" + wddxPacket); + } + + response.getWriter().print(wddxPacket); + return null; } - /** - * @param request - * @param activityId - * @return - */ - private String getLearnerActivityURL(HttpServletRequest request, long activityId) { - //initialize service object - ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); + /** + * @param request + * @param activityId + * @return + */ + private String getLearnerActivityURL(HttpServletRequest request, long activityId) { + // initialize service object + ActivityMapping activityMapping = LearnerServiceProxy.getActivityMapping(this.getServlet().getServletContext()); + ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - //getting requested object according to coming parameters - Integer learnerId = LearningWebUtil.getUserId(); - User learner = (User)LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()).findById(User.class,learnerId); + // getting requested object according to coming parameters + Integer learnerId = LearningWebUtil.getUserId(); + User learner = (User) LearnerServiceProxy.getUserManagementService(getServlet().getServletContext()).findById( + User.class, learnerId); - Activity requestedActivity = learnerService.getActivity(new Long(activityId)); - Lesson lesson = learnerService.getLessonByActivity(requestedActivity); - String url = activityMapping.calculateActivityURLForProgressView(lesson,learner,requestedActivity); - return url; - } - + Activity requestedActivity = learnerService.getActivity(new Long(activityId)); + Lesson lesson = learnerService.getLessonByActivity(requestedActivity); + String url = activityMapping.calculateActivityURLForProgressView(lesson, learner, requestedActivity); + return url; + } + /** - * Gets the same url as getLearnerActivityURL() but forwards directly to the url, rather than - * returning the url in a Flash packet. + * Gets the same url as getLearnerActivityURL() but forwards directly to the url, rather than returning the url in a + * Flash packet. * - * @param mapping An ActionMapping class that will be used by the Action class to tell - * the ActionServlet where to send the end-user. - * @param form The ActionForm class that will contain any data submitted - * by the end-user via a form. - * @param request A standard Servlet HttpServletRequest class. - * @param response A standard Servlet HttpServletResponse class. - * @return An ActionForward class that will be returned to the ActionServlet indicating where - * the user is to go next. + * @param mapping + * An ActionMapping class that will be used by the Action class to tell the ActionServlet where to + * send the end-user. + * @param form + * The ActionForm class that will contain any data submitted by the end-user via a form. + * @param request + * A standard Servlet HttpServletRequest class. + * @param response + * A standard Servlet HttpServletResponse class. + * @return An ActionForward class that will be returned to the ActionServlet indicating where the user is to go + * next. * @throws IOException * @throws ServletException */ - public ActionForward displayProgress(ActionMapping mapping, - ActionForm form, - HttpServletRequest request, - HttpServletResponse response) throws IOException, - ServletException - { - Integer learnerId = LearningWebUtil.getUserId(); - Long lessonId = WebUtil.readLongParam(request,AttributeNames.PARAM_LESSON_ID ); - - ICoreLearnerService learnerService = LearnerServiceProxy.getLearnerService(getServlet().getServletContext()); - Object[] ret = learnerService.getStructuredActivityURLs(learnerId, lessonId);; - request.setAttribute("progressList", (List