Fisheye: Tag 8234cab4a97871d21c395ff619b5722db1f35f0d refers to a dead (removed) revision in file `lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerAction.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/LaunchLearnerUrlServlet.java (revision 8234cab4a97871d21c395ff619b5722db1f35f0d) @@ -0,0 +1,130 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.web; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Date; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.lesson.Lesson; +import org.lamsfoundation.lams.lesson.service.ILessonService; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsAction; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * Sends redirect to lams learner. Format: launchlearner.do?lessonID= + * + * @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/includes/javascript/openUrls.js =================================================================== diff -u -rb6da459880f7f3c999a630c24e066902102768c8 -r8234cab4a97871d21c395ff619b5722db1f35f0d --- lams_central/web/includes/javascript/openUrls.js (.../openUrls.js) (revision b6da459880f7f3c999a630c24e066902102768c8) +++ lams_central/web/includes/javascript/openUrls.js (.../openUrls.js) (revision 8234cab4a97871d21c395ff619b5722db1f35f0d) @@ -182,18 +182,18 @@ { if(isMac) { - learnWin = window.open('home.do?method=learner&lessonID='+lessonId,'lWindow','width=' + learner_width + ',height=' + learner_height + ',resizable,status=yes'); + learnWin = window.open('../home.do?method=learner&lessonID='+lessonId,'lWindow','width=' + learner_width + ',height=' + learner_height + ',resizable,status=yes'); } else { if(learnWin && !learnWin.closed ) { - learnWin.location = 'home.do?method=learner&lessonID='+lessonId; + learnWin.location = '../home.do?method=learner&lessonID='+lessonId; learnWin.focus(); } else { - learnWin = window.open('home.do?method=learner&lessonID='+lessonId,'lWindow','width=' + learner_width + ',height=' + learner_height + ',resizable,status=yes'); + learnWin = window.open('../home.do?method=learner&lessonID='+lessonId,'lWindow','width=' + learner_width + ',height=' + learner_height + ',resizable,status=yes'); } } } Index: lams_central/web/launchlearner.jsp =================================================================== diff -u -racc8d2acf5b6b0002e0c8129947040a779ab4077 -r8234cab4a97871d21c395ff619b5722db1f35f0d --- lams_central/web/launchlearner.jsp (.../launchlearner.jsp) (revision acc8d2acf5b6b0002e0c8129947040a779ab4077) +++ lams_central/web/launchlearner.jsp (.../launchlearner.jsp) (revision 8234cab4a97871d21c395ff619b5722db1f35f0d) @@ -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 @@ <fmt:message key="index.welcome" /> - - - + + + @@ -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 =================================================================== diff -u -r6cea41c13ae7d7ef330284fa195209b9c201e5d2 -r8234cab4a97871d21c395ff619b5722db1f35f0d --- lams_central/web/login.jsp (.../login.jsp) (revision 6cea41c13ae7d7ef330284fa195209b9c201e5d2) +++ lams_central/web/login.jsp (.../login.jsp) (revision 8234cab4a97871d21c395ff619b5722db1f35f0d) @@ -34,9 +34,9 @@ - - - + + +