Index: lams_build/lib/lams/lams.jar =================================================================== RCS file: /usr/local/cvsroot/lams_build/lib/lams/lams.jar,v diff -u -r1.420.2.85 -r1.420.2.86 Binary files differ Index: lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java,v diff -u -r1.21.2.15 -r1.21.2.16 --- lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java 19 Jul 2016 09:14:26 -0000 1.21.2.15 +++ lams_central/src/java/org/lamsfoundation/lams/web/LoginRequestServlet.java 5 Aug 2016 11:04:03 -0000 1.21.2.16 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java,v diff -u -r1.33.2.9 -r1.33.2.10 --- lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java 19 Jul 2016 09:14:27 -0000 1.33.2.9 +++ lams_common/src/java/org/lamsfoundation/lams/integration/service/IntegrationService.java 5 Aug 2016 11:04:01 -0000 1.33.2.10 @@ -789,4 +789,8 @@ public void setLessonService(ILessonService lessonService) { this.lessonService = lessonService; } + + public ILessonService getLessonService() { + return lessonService; + } } \ No newline at end of file