Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java =================================================================== diff -u -r23cc48af323d7e89505f681f7a23392c8340190e -r04834bb552a5b48b08bcf8ce40ac27084a8439dc --- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 23cc48af323d7e89505f681f7a23392c8340190e) +++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 04834bb552a5b48b08bcf8ce40ac27084a8439dc) @@ -134,8 +134,8 @@ /** * request for learner environment */ - public ActionForward learner(ActionMapping mapping, ActionForm form, HttpServletRequest req, - HttpServletResponse res) throws IOException, ServletException { + public ActionForward learner(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) + throws IOException, ServletException { try { Long lessonId = WebUtil.readLongParam(req, AttributeNames.PARAM_LESSON_ID); UserDTO user = getUser(); @@ -207,10 +207,10 @@ req.setAttribute(AttributeNames.PARAM_MODE, mode); } - Boolean isPortfolioEnabled = lesson.getLearnerExportAvailable() != null ? lesson.getLearnerExportAvailable() - : Boolean.TRUE; + Boolean isPortfolioEnabled = lesson.getLearnerExportAvailable() != null ? lesson + .getLearnerExportAvailable() : Boolean.TRUE; Organisation organisation = lesson.getOrganisation(); - // in case of preview lesson (organisation is null) don't check organisation's settings + //in case of preview lesson (organisation is null) don't check organisation's settings if (organisation != null) { isPortfolioEnabled &= organisation.getEnableExportPortfolio(); } @@ -228,8 +228,8 @@ // forward to /lams/learning/main.jsp String serverURLContextPath = Configuration.get(ConfigurationKeys.SERVER_URL_CONTEXT_PATH); - serverURLContextPath = serverURLContextPath.startsWith("/") ? serverURLContextPath - : "/" + serverURLContextPath; + serverURLContextPath = serverURLContextPath.startsWith("/") ? serverURLContextPath : "/" + + serverURLContextPath; serverURLContextPath += serverURLContextPath.endsWith("/") ? "" : "/"; getServlet().getServletContext().getContext(serverURLContextPath + "learning") .getRequestDispatcher("/main.jsp").forward(req, res); @@ -243,14 +243,58 @@ /** * request for author environment - * - * @throws IOException */ public ActionForward author(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) - throws IOException { - String url = Configuration.get(ConfigurationKeys.SERVER_URL) + "authoring/author.do?method=openAuthoring"; - res.sendRedirect(url); - return null; + throws IOException, ServletException { + try { + UserDTO user = getUser(); + if (user == null) { + HomeAction.log.error("admin: User missing from session. "); + return mapping.findForward("error"); + } + + Long learningDesignID = null; + String layout = null; + String serverUrl = Configuration.get(ConfigurationKeys.SERVER_URL); + req.setAttribute("serverUrl", serverUrl); + + String requestSrc = req.getParameter("requestSrc"); + String notifyCloseURL = req.getParameter(AttributeNames.PARAM_NOTIFY_CLOSE_URL); + String isPostMessageToParent = req.getParameter("isPostMessageToParent"); + String customCSV = req.getParameter(AttributeNames.PARAM_CUSTOM_CSV); + String extLmsId = req.getParameter(AttributeNames.PARAM_EXT_LMS_ID); + + if (req.getParameter("learningDesignID") != null) { + learningDesignID = WebUtil.readLongParam(req, "learningDesignID"); + } + + if (req.getParameter("layout") != null) { + layout = WebUtil.readStrParam(req, "layout"); + } + + if (layout != null) { + req.setAttribute("layout", layout); + } + + if (req.getParameter("learningDesignID") != null) { + learningDesignID = WebUtil.readLongParam(req, "learningDesignID"); + } + + if (learningDesignID != null) { + req.setAttribute("learningDesignID", learningDesignID); + } + + req.setAttribute("requestSrc", requestSrc); + req.setAttribute(AttributeNames.PARAM_NOTIFY_CLOSE_URL, notifyCloseURL); + req.setAttribute("isPostMessageToParent", isPostMessageToParent); + req.setAttribute(AttributeNames.PARAM_CUSTOM_CSV, customCSV); + req.setAttribute(AttributeNames.PARAM_EXT_LMS_ID, extLmsId); + + return mapping.findForward("author"); + } catch (Exception e) { + HomeAction.log.error("Failed to load author", e); + return mapping.findForward("error"); + } } /** @@ -264,7 +308,7 @@ HomeAction.log.error("User missing from session. Can not open Lesson Monitor."); return mapping.findForward("error"); } - + Lesson lesson = lessonId == null ? null : getLessonService().getLesson(lessonId); if (lesson == null) { HomeAction.log.error("Lesson " + lessonId + " does not exist. Can not open Lesson Monitor."); @@ -280,8 +324,8 @@ @SuppressWarnings("unchecked") public ActionForward addLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req, - HttpServletResponse res) - throws IOException, UserAccessDeniedException, JSONException, RepositoryCheckedException { + HttpServletResponse res) throws IOException, UserAccessDeniedException, JSONException, + RepositoryCheckedException { UserDTO userDTO = getUser(); Integer organisationID = new Integer(WebUtil.readIntParam(req, "organisationID")); @@ -347,8 +391,8 @@ * Gets subfolder contents in Add Lesson screen. */ public ActionForward getFolderContents(ActionMapping mapping, ActionForm form, HttpServletRequest req, - HttpServletResponse res) - throws UserAccessDeniedException, JSONException, IOException, RepositoryCheckedException { + HttpServletResponse res) throws UserAccessDeniedException, JSONException, IOException, + RepositoryCheckedException { Integer folderID = WebUtil.readIntParam(req, "folderID", true); boolean allowInvalidDesigns = WebUtil.readBooleanParam(req, "allowInvalidDesigns", false); String folderContentsJSON = getWorkspaceManagementService().getFolderContentsJSON(folderID, @@ -375,8 +419,8 @@ // should the image be downloaded or a part of page? if (download) { - String name = getLearningDesignService() - .getLearningDesignDTO(learningDesignId, getUser().getLocaleLanguage()).getTitle(); + String name = getLearningDesignService().getLearningDesignDTO(learningDesignId, + getUser().getLocaleLanguage()).getTitle(); name += "." + (format == SVGGenerator.OUTPUT_FORMAT_PNG ? "png" : "svg"); name = FileUtil.encodeFilenameForDownload(req, name); res.setContentType("application/x-download"); @@ -427,44 +471,44 @@ private IUserManagementService getService() { if (HomeAction.service == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.service = (IUserManagementService) ctx.getBean("userManagementService"); } return HomeAction.service; } private ILessonService getLessonService() { if (HomeAction.lessonService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.lessonService = (ILessonService) ctx.getBean("lessonService"); } return HomeAction.lessonService; } private ILearningDesignService getLearningDesignService() { if (HomeAction.learningDesignService == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.learningDesignService = (ILearningDesignService) ctx.getBean("learningDesignService"); } return HomeAction.learningDesignService; } private IGroupUserDAO getGroupUserDAO() { if (HomeAction.groupUserDAO == null) { - WebApplicationContext ctx = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.groupUserDAO = (IGroupUserDAO) ctx.getBean("groupUserDAO"); } return HomeAction.groupUserDAO; } private IWorkspaceManagementService getWorkspaceManagementService() { if (HomeAction.workspaceManagementService == null) { - WebApplicationContext webContext = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.workspaceManagementService = (IWorkspaceManagementService) webContext .getBean("workspaceManagementService"); } @@ -474,8 +518,8 @@ private ISecurityService getSecurityService() { if (HomeAction.securityService == null) { - WebApplicationContext webContext = WebApplicationContextUtils - .getRequiredWebApplicationContext(getServlet().getServletContext()); + WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); HomeAction.securityService = (ISecurityService) webContext.getBean("securityService"); }