Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -r0a0679b24e6381c68c65ae4fd0df911b15e62851 -rc4e67ef9e2b2cbed54f54e96807f820a4a2e9e1f Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java =================================================================== diff -u -r04324aeb5a29d6d1748ef57d871f24003fd32502 -rc4e67ef9e2b2cbed54f54e96807f820a4a2e9e1f --- lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java (.../LoginRequestServlet.java) (revision 04324aeb5a29d6d1748ef57d871f24003fd32502) +++ lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java (.../LoginRequestServlet.java) (revision c4e67ef9e2b2cbed54f54e96807f820a4a2e9e1f) @@ -104,8 +104,7 @@ // LDEV-2196 preserve character encoding if necessary if (request.getCharacterEncoding() == null) { - LoginRequestServlet.log.debug( - "request.getCharacterEncoding is empty, parsing username and courseName as 8859_1 to UTF-8..."); + log.debug("request.getCharacterEncoding is empty, parsing username and courseName as 8859_1 to UTF-8..."); extUsername = new String(extUsername.getBytes("8859_1"), "UTF-8"); if (courseName != null) { courseName = new String(courseName.getBytes("8859_1"), "UTF-8"); @@ -123,9 +122,10 @@ lastName, langIsoCode, countryIsoCode, email, prefix, isUpdateUserDetails); } - //in case of request for learner with strict authentication check cache should also contain lsid + // in case of request for learner with strict authentication check cache should also contain lsid String lsId = request.getParameter(LoginRequestDispatcher.PARAM_LESSON_ID); - if (LoginRequestDispatcher.METHOD_LEARNER_STRICT_AUTHENTICATION.equals(method) && lsId == null) { + if ((LoginRequestDispatcher.METHOD_LEARNER_STRICT_AUTHENTICATION.equals(method) + || LoginRequestDispatcher.METHOD_MONITOR.equals(method)) && lsId == null) { response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Login Failed - lsId parameter missing"); return; } @@ -147,6 +147,12 @@ getIntegrationService().getExtCourseClassMap(serverMap, userMap, extCourseId, countryIsoCode, langIsoCode, courseName, method, prefix); } + + // in case of method=monitor is requested, check whether the user is lesson's monitor. And if not - add him + if (LoginRequestDispatcher.METHOD_MONITOR.equals(method)) { + getIntegrationService().getLessonService().addStaffMember(Long.parseLong(lsId), + userMap.getUser().getUserId()); + } User user = userMap.getUser(); String login = user.getLogin(); @@ -174,15 +180,15 @@ response.sendRedirect("login.jsp?redirectURL=" + redirectURL); } catch (AuthenticationException e) { - LoginRequestServlet.log.error("Authentication error: ", e); + log.error("Authentication error: ", e); response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Login Failed - authentication error. " + e.getMessage()); } catch (UserInfoFetchException e) { - LoginRequestServlet.log.error("User fetch info error: ", e); + log.error("User fetch info error: ", e); response.sendError(HttpServletResponse.SC_BAD_GATEWAY, "Login Failed - failed to fetch user info from the third party server"); } catch (UserInfoValidationException e) { - LoginRequestServlet.log.error("User validation error: ", e); + log.error("User validation error: ", e); response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage()); } } @@ -207,10 +213,10 @@ } private IntegrationService getIntegrationService() { - if (LoginRequestServlet.integrationService == null) { - LoginRequestServlet.integrationService = (IntegrationService) WebApplicationContextUtils + if (integrationService == null) { + integrationService = (IntegrationService) WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService"); } - return LoginRequestServlet.integrationService; + return integrationService; } } Index: lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java =================================================================== diff -u -r04324aeb5a29d6d1748ef57d871f24003fd32502 -rc4e67ef9e2b2cbed54f54e96807f820a4a2e9e1f --- lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision 04324aeb5a29d6d1748ef57d871f24003fd32502) +++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java (.../IntegrationService.java) (revision c4e67ef9e2b2cbed54f54e96807f820a4a2e9e1f) @@ -789,4 +789,8 @@ public void setLessonService(ILessonService lessonService) { this.lessonService = lessonService; } + + public ILessonService getLessonService() { + return lessonService; + } } \ No newline at end of file