Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java,v diff -u -r1.52 -r1.53 --- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 25 Jul 2013 05:55:30 -0000 1.52 +++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java 8 Aug 2013 11:51:12 -0000 1.53 @@ -30,7 +30,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.Set; import java.util.TreeSet; @@ -91,7 +90,6 @@ * @struts:action-forward name="learner" path="/learner.jsp" * @struts:action-forward name="lessonIntro" path="/lessonIntro.jsp" * @struts:action-forward name="author" path="/author.jsp" - * @struts:action-forward name="monitorLesson" path="/monitorLesson.jsp" * @struts:action-forward name="addLesson" path="/addLesson.jsp" * @struts:action-forward name="error" path=".error" * @struts:action-forward name="message" path=".message" @@ -180,8 +178,8 @@ } } - - //check lesson's state if its suitable for learner's access + + // check lesson's state if its suitable for learner's access if (!lesson.isLessonAccessibleForLearner()) { return displayMessage(mapping, req, "error.lesson.not.accessible.for.learners"); } @@ -296,43 +294,29 @@ } /** - * request for monitor environment + * Request for Monitor environment. */ public ActionForward monitorLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { - - try { - HomeAction.log.debug("request monitorLesson"); - Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID); - UserDTO user = getUser(); - if (user == null) { - HomeAction.log.error("admin: User missing from session. "); + if (HomeAction.log.isDebugEnabled()) { + HomeAction.log.debug("Requested Lesson Monitor"); + } + Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID); + UserDTO user = getUser(); + if (user == null) { + HomeAction.log.error("User missing from session. Can not open Lesson Monitor."); + return mapping.findForward("error"); + } else { + Lesson lesson = lessonId == null ? null : getLessonService().getLesson(lessonId); + if (lesson == null) { + HomeAction.log.error("Lesson " + lessonId + " does not exist. Can not open Lesson Monitor."); return mapping.findForward("error"); - } else { - Lesson lesson = lessonId != null ? getLessonService().getLesson(lessonId) : null; - if (lesson == null) { - HomeAction.log.error("monitorLesson: Lesson " + lessonId - + " does not exist. Unable to monitor lesson"); - return mapping.findForward("error"); - } - - if ((lesson.getLessonClass() == null) - || (!lesson.getLessonClass().isStaffMember(getRealUser(user)) && !req - .isUserInRole(Role.GROUP_MANAGER))) { - HomeAction.log.error("learner: User " + user.getLogin() - + " is not a learner in the requested lesson. Cannot access the lesson."); - return displayMessage(mapping, req, "error.authorisation"); - } - - HomeAction.log.debug("user is staff"); - String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); - req.setAttribute("serverUrl", serverUrl); - req.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId); - return mapping.findForward("monitorLesson"); } - } catch (Exception e) { - HomeAction.log.error("Failed to load monitor lesson", e); - return mapping.findForward("error"); + + String url = Configuration.get(ConfigurationKeys.SERVER_URL) + + "monitoring/monitoring.do?method=monitorLesson&lessonID=" + lessonId; + res.sendRedirect(url); + return null; } } 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.100 -r1.101 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 29 Jul 2013 12:15:47 -0000 1.100 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/IMonitoringService.java 8 Aug 2013 11:51:16 -0000 1.101 @@ -55,6 +55,18 @@ */ public interface IMonitoringService { + /** + * Checks whether the user is a staff member for the lesson, the creator of the lesson or simply a group manager. If + * not, throws a UserAccessDeniedException exception + */ + public void checkOwnerOrStaffMember(Integer userId, Long lessonId, String actionDescription); + + /** + * Checks whether the user is a staff member for the lesson, the creator of the lesson or simply a group manager. If + * not, throws a UserAccessDeniedException exception + */ + public void checkOwnerOrStaffMember(Integer userId, Lesson lesson, String actionDescription); + /** Get the message service, which gives access to the I18N text */ public MessageService getMessageService(); 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.180 -r1.181 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 29 Jul 2013 12:15:47 -0000 1.180 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/service/MonitoringService.java 8 Aug 2013 11:51:16 -0000 1.181 @@ -374,11 +374,15 @@ auditService.log("Monitoring", message); } + public void checkOwnerOrStaffMember(Integer userId, Long lessonId, String actionDescription) { + checkOwnerOrStaffMember(userId, lessonDAO.getLesson(lessonId), actionDescription); + } + /** * Checks whether the user is a staff member for the lesson, the creator of the lesson or simply a group manager. If * not, throws a UserAccessDeniedException exception */ - private void checkOwnerOrStaffMember(Integer userId, Lesson lesson, String actionDescription) { + public void checkOwnerOrStaffMember(Integer userId, Lesson lesson, String actionDescription) { User user = (User) baseDAO.find(User.class, userId); if ((lesson.getUser() != null) && lesson.getUser().getUserId().equals(userId)) { @@ -495,10 +499,9 @@ throw new MonitoringServiceException("Learning design for id=" + learningDesignID + " is missing. Unable to initialize lesson."); } - Lesson lesson = createNewLesson(lessonName, lessonDescription, user, learningDesign, - enableLessonIntro, displayDesignImage, learnerExportAvailable, learnerPresenceAvailable, - learnerImAvailable, liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, - precedingLesson); + Lesson lesson = createNewLesson(lessonName, lessonDescription, user, learningDesign, enableLessonIntro, + displayDesignImage, learnerExportAvailable, learnerPresenceAvailable, learnerImAvailable, + liveEditEnabled, enableLessonNotifications, scheduledNumberDaysToLessonFinish, precedingLesson); auditAction(MonitoringService.AUDIT_LESSON_CREATED_KEY, new Object[] { lessonName, learningDesign.getTitle(), learnerExportAvailable }); return lesson; 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.97 -r1.98 --- lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 1 Aug 2013 13:51:04 -0000 1.97 +++ lams_monitoring/src/java/org/lamsfoundation/lams/monitoring/web/MonitoringAction.java 8 Aug 2013 11:51:16 -0000 1.98 @@ -1167,6 +1167,8 @@ IMonitoringService monitoringService = MonitoringServiceProxy.getMonitoringService(getServlet() .getServletContext()); + monitoringService.checkOwnerOrStaffMember(user.getUserID(), lessonId, "monitor lesson"); + List contributeActivities = monitoringService.getAllContributeActivityDTO(lessonId); if (contributeActivities != null) {