Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r5e63656a12c02f7476564e278b43ff4ce86ac930 -re60597c15c579c615cc2e9969a7ed6547132cd91
--- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 5e63656a12c02f7476564e278b43ff4ce86ac930)
+++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision e60597c15c579c615cc2e9969a7ed6547132cd91)
@@ -474,6 +474,7 @@
authoring.fla.sequence.not.valid =The sequence is not valid.
It needs to be corrected before it can be used in lessons.
authoring.fla.sequence.validation.issues =While saving the sequence there were following validation issues:
authoring.fla.save.successful =Congratulations! Your design is valid and has been saved.
+authoring.fla.liveedit.save.successful =Changes were successfully applied.
authoring.fla.navigate.away.confirm =Your design is not saved.\\nAny changes you made since you last saved will be lost.
authoring.fla.delete.node.confirm =Are you sure you want to delete this
authoring.fla.sequence.overwrite.confirm =Are you sure you want to overwrite the existing sequence?
@@ -485,7 +486,8 @@
authoring.fla.title.validation.error =The title can not contain any of these characters < > ^ * @ % $
authoring.fla.folder.exists.error =A folder with this name already exists.
authoring.fla.sequence.exists.error =A sequence with this name already exists.
-authoring.fla.sequence.save.error =Error while loading sequence
+authoring.fla.sequence.save.error =Error while saving sequence
+authoring.fla.svg.save.error =Error while saving sequence thumbnail
authoring.fla.sequence.not.selected.error =Please choose a sequence
authoring.fla.sequence.load.error =Error while loading the sequence
authoring.fla.transition.from.exists.error =Transition from this activity already exists
Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java
===================================================================
diff -u -rf295ad79de8fe9d221c166fa90587d0be2fdda5b -re60597c15c579c615cc2e9969a7ed6547132cd91
--- lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision f295ad79de8fe9d221c166fa90587d0be2fdda5b)
+++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/AuthoringAction.java (.../AuthoringAction.java) (revision e60597c15c579c615cc2e9969a7ed6547132cd91)
@@ -38,7 +38,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
-import javax.xml.bind.DatatypeConverter;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@@ -497,11 +496,11 @@
if (AuthoringAction.log.isDebugEnabled()) {
AuthoringAction.log.debug("Created a single activity lesson with ID: " + lesson.getLessonId());
}
-
+
response.setContentType("text/plain;charset=utf-8");
response.getWriter().write(learningDesignID.toString());
}
-
+
return null;
}
@@ -583,23 +582,27 @@
/**
* Stores the binary code of an Learning Design thumbnail, created in Flashless Authoring.
+ *
+ * @throws IOException
*/
public ActionForward saveLearningDesignImage(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ HttpServletResponse response) throws IOException {
Long learningDesignID = WebUtil.readLongParam(request, AttributeNames.PARAM_LEARNINGDESIGN_ID);
- String extension = request.getParameter("extension");
String image = request.getParameter("image");
- AuthoringAction.saveLearningDesignImage(learningDesignID, extension, image);
-
+ boolean saveSuccesful = AuthoringAction.saveLearningDesignImage(learningDesignID, image);
+ if (!saveSuccesful) {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
return null;
}
/**
* Stores the binary code of an Learning Design thumbnail, created in Flashless Authoring.
*/
- private static void saveLearningDesignImage(long learningDesignID, String extension, String image) {
- if (StringUtils.isBlank(image) || (!"SVG".equalsIgnoreCase(extension) && !"PNG".equalsIgnoreCase(extension))) {
- return;
+ private static boolean saveLearningDesignImage(long learningDesignID, String image) {
+ if (StringUtils.isBlank(image)) {
+ AuthoringAction.log.error("No SVG code to save for LD: " + learningDesignID);
+ return false;
}
// prepare the dir and the file
@@ -609,38 +612,18 @@
}
String absoluteFilePath = FileUtil.getFullPath(IAuthoringService.LEARNING_DESIGN_IMAGES_FOLDER,
- learningDesignID + "." + extension.toLowerCase());
+ learningDesignID + ".svg");
// write out the content
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(absoluteFilePath);
- if (extension.equalsIgnoreCase("png")) {
- // if it comes from Flashless Authoring, it can have a prefix we need to remove
- if (image.contains("base64")) {
- image = image.substring(image.indexOf(",") + 1);
- }
- byte[] bytes = DatatypeConverter.parseBase64Binary(image);
- fos.write(bytes);
- } else {
- // encoding is important, especially for Raphael-generated SVGs
- Writer writer = new OutputStreamWriter(fos, "UTF8");
- writer.write(image);
- writer.close();
- }
+ try (FileOutputStream fos = new FileOutputStream(absoluteFilePath);
+ Writer writer = new OutputStreamWriter(fos, "UTF8")) {
+ // encoding is important, especially for Raphael-generated SVGs
+ writer.write(image);
} catch (IOException e) {
- AuthoringAction.log.error(
- "Error while writing " + extension.toUpperCase() + " thumbnail of LD " + learningDesignID + ".", e);
- } finally {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- AuthoringAction.log.error("Error while closing stream to " + extension.toUpperCase()
- + " thumbnail of LD " + learningDesignID);
- }
- }
+ AuthoringAction.log.error("Error while writing SVG thumbnail of LD " + learningDesignID + ".", e);
+ return false;
}
+ return true;
}
/**
Index: lams_central/web/authoring/authoring.jsp
===================================================================
diff -u -rf295ad79de8fe9d221c166fa90587d0be2fdda5b -re60597c15c579c615cc2e9969a7ed6547132cd91
--- lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision f295ad79de8fe9d221c166fa90587d0be2fdda5b)
+++ lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision e60597c15c579c615cc2e9969a7ed6547132cd91)
@@ -113,6 +113,8 @@
SEQUENCE_VALIDATION_ISSUES : '',
SAVE_SUCCESSFUL : decoderDiv.html('').text(),
+
+ LIVEEDIT_SAVE_SUCCESSFUL : decoderDiv.html('').text(),
DELETE_NODE_CONFIRM : decoderDiv.html('').text(),
@@ -137,6 +139,8 @@
SEQUENCE_EXISTS_ERROR : decoderDiv.html('').text(),
SEQUENCE_SAVE_ERROR : decoderDiv.html('').text(),
+
+ SVG_SAVE_ERROR : decoderDiv.html('').text(),
SEQUENCE_NOT_SELECTED_ERROR : decoderDiv.html('').text(),
Index: lams_central/web/includes/javascript/authoring/authoringGeneral.js
===================================================================
diff -u -rf295ad79de8fe9d221c166fa90587d0be2fdda5b -re60597c15c579c615cc2e9969a7ed6547132cd91
--- lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision f295ad79de8fe9d221c166fa90587d0be2fdda5b)
+++ lams_central/web/includes/javascript/authoring/authoringGeneral.js (.../authoringGeneral.js) (revision e60597c15c579c615cc2e9969a7ed6547132cd91)
@@ -2662,13 +2662,18 @@
this.draw();
});
+ // create the updated LD image
+ var svgSaveSuccessful = GeneralLib.saveLearningDesignImage();
+ if (!svgSaveSuccessful) {
+ alert(LABELS.SVG_SAVE_ERROR);
+ return;
+ }
+
// set as not modified so dialog will not prompt user on close
GeneralLib.setModified(false);
- // create the updated LD image
- GeneralLib.saveLearningDesignImage();
// close the Live Edit dialog
- alert('Changes were successfully applied.');
+ alert(LABELS.LIVEEDIT_SAVE_SUCCESSFUL);
window.parent.closeDialog('dialogFlashlessAuthoring');
}
});
@@ -2677,7 +2682,11 @@
return;
}
- GeneralLib.saveLearningDesignImage();
+ var svgSaveSuccessful = GeneralLib.saveLearningDesignImage();
+ if (!svgSaveSuccessful) {
+ alert(LABELS.SVG_SAVE_ERROR);
+ return;
+ }
if (response.validation.length == 0) {
alert(LABELS.SAVE_SUCCESSFUL);
@@ -2702,17 +2711,22 @@
* Stores SVG LD thumbnail on server.
*/
saveLearningDesignImage : function() {
+ var result = false;
$.ajax({
type : 'POST',
url : LAMS_URL + 'authoring/author.do',
async: false,
data : {
'method' : 'saveLearningDesignImage',
'learningDesignID' : layout.ld.learningDesignID,
- 'extension' : 'SVG',
'image' : MenuLib.exportSVG()
+ },
+ success : function(){
+ result = true;
}
});
+
+ return result;
},