Index: lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java =================================================================== diff -u -r3dbf966d900adefc34cdad501d3c392118451cd9 -r27a58f395dec9927221147dac08a0b75213fd354 --- lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 3dbf966d900adefc34cdad501d3c392118451cd9) +++ lams_central/src/java/org/lamsfoundation/lams/web/HomeAction.java (.../HomeAction.java) (revision 27a58f395dec9927221147dac08a0b75213fd354) @@ -23,6 +23,7 @@ /* $$Id$$ */ package org.lamsfoundation.lams.web; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.OutputStream; @@ -61,7 +62,6 @@ import org.lamsfoundation.lams.usermanagement.Organisation; import org.lamsfoundation.lams.usermanagement.Role; import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.dto.UserBasicDTO; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.usermanagement.exception.UserAccessDeniedException; import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; @@ -268,7 +268,7 @@ @SuppressWarnings("unchecked") public ActionForward addLesson(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) - throws IOException, UserAccessDeniedException, JSONException, RepositoryCheckedException { + throws IOException, UserAccessDeniedException, JSONException, RepositoryCheckedException { UserDTO userDTO = getUser(); Integer organisationID = new Integer(WebUtil.readIntParam(req, "organisationID")); @@ -336,7 +336,7 @@ */ public ActionForward getFolderContents(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) - throws UserAccessDeniedException, JSONException, IOException, RepositoryCheckedException { + throws UserAccessDeniedException, JSONException, IOException, RepositoryCheckedException { Integer folderID = WebUtil.readIntParam(req, "folderID", true); boolean allowInvalidDesigns = WebUtil.readBooleanParam(req, "allowInvalidDesigns", false); String folderContentsJSON = getWorkspaceManagementService().getFolderContentsJSON(folderID, @@ -350,6 +350,13 @@ public ActionForward getLearningDesignThumbnail(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws JDOMException, IOException { Long learningDesignId = WebUtil.readLongParam(req, CentralConstants.PARAM_LEARNING_DESIGN_ID); + String imagePath = LearningDesignService.getLearningDesignSVGPath(learningDesignId); + File imageFile = new File(imagePath); + if (!imageFile.canRead()) { + res.sendError(HttpServletResponse.SC_NOT_FOUND); + return null; + } + boolean download = WebUtil.readBooleanParam(req, "download", false); // should the image be downloaded or a part of page? if (download) { @@ -363,7 +370,6 @@ res.setContentType("image/svg+xml"); } - String imagePath = LearningDesignService.getLearningDesignSVGPath(learningDesignId); FileInputStream input = new FileInputStream(imagePath); OutputStream output = res.getOutputStream(); IOUtils.copy(input, output); Index: lams_central/web/includes/javascript/addLesson.js =================================================================== diff -u -r9bb68cb1df5f57c18e966963fd308e9a82743671 -r27a58f395dec9927221147dac08a0b75213fd354 --- lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 9bb68cb1df5f57c18e966963fd308e9a82743671) +++ lams_central/web/includes/javascript/addLesson.js (.../addLesson.js) (revision 27a58f395dec9927221147dac08a0b75213fd354) @@ -17,6 +17,23 @@ var resized = resizeImage('ldScreenshotAuthor', 477); toggleCanvasResize(resized ? CANVAS_RESIZE_OPTION_FIT : CANVAS_RESIZE_OPTION_NONE); + }).error(function(){ + // the LD SVG is missing, try to re-generate it + var image = $(this), + learningDesignID = $(this).data('learningDesignID'); + + // iframe just to load Authoring for a single purpose, generate the SVG + $('