+ *
+ * @web:servlet name="LaunchLearnerUrlServlet"
+ * @web:servlet-mapping url-pattern="/r/*"
+ */
+public class LaunchLearnerUrlServlet extends HttpServlet {
+
+ private static Logger log = Logger.getLogger(LaunchLearnerUrlServlet.class);
+
+ private static ILessonService lessonService;
+
+ private ILessonService getLessonService() {
+ if (lessonService == null) {
+ WebApplicationContext ctx = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(getServletContext());
+ lessonService = (ILessonService) ctx.getBean("lessonService");
+ }
+ return lessonService;
+ }
+
+ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ String encodedLessonId = request.getPathInfo();
+
+ // redirect to login page if accessing / URL
+ if (StringUtils.isBlank(encodedLessonId) || encodedLessonId.length() < 2) {
+ String lamsUrl = Configuration.get(ConfigurationKeys.SERVER_URL);
+ response.sendRedirect(lamsUrl);
+ return;
+ }
+
+ // cut off the first '/'
+ encodedLessonId = encodedLessonId.substring(1);
+
+ Long lessonId;
+ try {
+ String decodedLessonId = WebUtil.decodeLessonId(encodedLessonId);
+ lessonId = Long.valueOf(decodedLessonId);
+
+ } catch (IllegalArgumentException e) {
+ log.warn("Supplied lessonId: " + encodedLessonId + " has wrong format.");
+ response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Supplied lessonId: " + encodedLessonId + " has wrong format.");
+// return mapping.findForward("error");
+// displayMessage(request, response, "error.lessonid.has.wrong.format");
+ return;
+ }
+
+
+
+ Lesson lesson = lessonId != null ? getLessonService().getLesson(lessonId) : null;
+ if (lesson != null) {
+ // return displayMessage(mapping, req, "message.lesson.not.started.cannot.participate");
+ }
+
+ request.setAttribute("name", lesson.getLessonName());
+ request.setAttribute("description", lesson.getLessonDescription());
+ request.setAttribute("status", lesson.getLessonStateId());
+ request.setAttribute(AttributeNames.PARAM_LESSON_ID, lessonId);
+
+ request.getRequestDispatcher("/launchlearner.jsp").forward(request, response);
+
+ // getServletContext().getContext(serverURLContextPath + "learning")
+ // .getRequestDispatcher("/main.jsp").forward(req, res);
+ // return null;
+ //
+ //
+ // request.setAttribute( AttributeNames.PARAM_LESSON_ID, encodedLessonId);
+ // request.getRequestDispatcher("/launchlearner.do").forward(request, response);
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ doPost(request, response);
+ }
+
+ private void displayMessage(HttpServletRequest request, HttpServletResponse response, String messageKey)
+ throws ServletException, IOException {
+ request.setAttribute("messageKey", messageKey);
+ request.getRequestDispatcher("/.message").forward(request, response);
+ }
+}
\ No newline at end of file
Index: lams_central/web/launchlearner.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/launchlearner.jsp,v
diff -u -r1.6 -r1.7
--- lams_central/web/launchlearner.jsp 2 Jul 2009 08:19:14 -0000 1.6
+++ lams_central/web/launchlearner.jsp 4 Dec 2014 23:06:54 -0000 1.7
@@ -1,5 +1,4 @@
-
+
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" %>
<%@ page import="org.lamsfoundation.lams.lesson.Lesson" %>
@@ -11,9 +10,9 @@
-
-
-
+
+
+
@@ -26,50 +25,51 @@
-
- <%= Lesson.CREATED %>
- <%= Lesson.NOT_STARTED_STATE %>
- <%= Lesson.STARTED_STATE %>
- <%= Lesson.FINISHED_STATE %>
- <%= Lesson.SUSPENDED_STATE %>
- <%= Lesson.ARCHIVED_STATE %>
- <%= Lesson.REMOVED_STATE %>
+
+
+ <%= Lesson.CREATED %>
+ <%= Lesson.NOT_STARTED_STATE %>
+ <%= Lesson.STARTED_STATE %>
+ <%= Lesson.FINISHED_STATE %>
+ <%= Lesson.SUSPENDED_STATE %>
+ <%= Lesson.ARCHIVED_STATE %>
+ <%= Lesson.REMOVED_STATE %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -80,6 +80,4 @@
-
-
\ No newline at end of file
Index: lams_central/web/login.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_central/web/login.jsp,v
diff -u -r1.52 -r1.53
--- lams_central/web/login.jsp 8 Oct 2014 05:50:55 -0000 1.52
+++ lams_central/web/login.jsp 4 Dec 2014 23:06:55 -0000 1.53
@@ -39,8 +39,8 @@
-
-
+
+