Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentController.java =================================================================== diff -u -raa5d6d2ab7a3d3b7b9fe4e910578c1393bf5ed3d -r37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentController.java (.../ImportToolContentController.java) (revision aa5d6d2ab7a3d3b7b9fe4e910578c1393bf5ed3d) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentController.java (.../ImportToolContentController.java) (revision 37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b) @@ -44,7 +44,6 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.multipart.MultipartFile; /** * Import tool content servlet. It needs an uploaded learning design zip file. @@ -81,11 +80,13 @@ if (customCSV != null) { request.setAttribute(AttributeNames.PARAM_CUSTOM_CSV, customCSV); } + request.setAttribute("tmpFileUploadId", FileUtil.generateTmpFileUploadId()); return "toolcontent/import"; } + @SuppressWarnings("unchecked") @RequestMapping("") - public String importLD(@RequestParam("UPLOAD_FILE") MultipartFile file, HttpServletRequest request) { + public String importLD(@RequestParam String tmpFileUploadId, HttpServletRequest request) { List ldErrorMsgs = new ArrayList<>(); List toolsErrorMsgs = new ArrayList<>(); @@ -98,24 +99,35 @@ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); User user = (User) userManagementService.findById(User.class, userDto.getUserID()); + File file = null; + File uploadDir = FileUtil.getTmpFileUploadDir(tmpFileUploadId); + if (uploadDir.canRead()) { + File[] files = uploadDir.listFiles(); + if (files.length > 1) { + ldErrorMsgs.add("Uploaded more than 1 file"); + } else if (files.length == 1) { + file = files[0]; + } + } + if (file == null) { MessageService msgService = authoringMessageService; log.error("Upload file missing"); String msg = msgService.getMessage(KEY_MSG_IMPORT_FILE_NOT_FOUND); ldErrorMsgs.add(msg != null ? msg : "Upload file missing"); + } - } else { + if (ldErrorMsgs.isEmpty()) { // get customCSV for tool adapters if it was an external LMS request String customCSV = request.getParameter(AttributeNames.PARAM_CUSTOM_CSV); - String uploadPath = FileUtil.createTempDirectory("_uploaded_learningdesign"); - String filename = FileUtil.getFileName(file.getOriginalFilename()); - File designFile = new File(uploadPath, filename); - file.transferTo(designFile); - Object[] ldResults = exportToolContentService.importLearningDesign(designFile, user, null, - toolsErrorMsgs, customCSV); + + Object[] ldResults = exportToolContentService.importLearningDesign(file, user, null, toolsErrorMsgs, + customCSV); ldId = (Long) ldResults[0]; ldErrorMsgs = (List) ldResults[1]; toolsErrorMsgs = (List) ldResults[2]; + + FileUtil.deleteTmpFileUploadDir(tmpFileUploadId); } } catch (Exception e) { @@ -136,6 +148,5 @@ } return ("toolcontent/importresult"); - } } Index: lams_central/web/includes/javascript/authoring/authoringMenu.js =================================================================== diff -u -ra65568cc36db07abf19550359c0db03a9561c964 -r37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b --- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision a65568cc36db07abf19550359c0db03a9561c964) +++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b) @@ -403,7 +403,7 @@ } var dialog = showDialog("dialogImportLearningDesign", { 'modal' : true, - 'height' : 350, + 'height' : 500, 'width' : 850, 'title' : LABELS.IMPORT_DIALOG_TITLE, 'open' : function() { Index: lams_central/web/toolcontent/import.jsp =================================================================== diff -u -re6dc4db4137cfd6b07a4aa79711b9d12b39fb78e -r37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b --- lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision e6dc4db4137cfd6b07a4aa79711b9d12b39fb78e) +++ lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision 37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b) @@ -4,49 +4,119 @@ <%@ page import="org.lamsfoundation.lams.util.ConfigurationKeys" %> <%@ page import="org.lamsfoundation.lams.util.FileValidatorUtil" %> <%=Configuration.get(ConfigurationKeys.UPLOAD_FILE_LARGE_MAX_SIZE)%> -<%=FileValidatorUtil.formatSize(Configuration.getAsInt(ConfigurationKeys.UPLOAD_FILE_LARGE_MAX_SIZE))%> <%=Configuration.get(ConfigurationKeys.EXE_EXTENSIONS)%> <%=Configuration.get(ConfigurationKeys.ANTIVIRUS_ENABLE)%> + <fmt:message key="title.import" /> + + + + + + + + + + + + + + - @@ -67,16 +137,16 @@
" method="post" enctype="multipart/form-data" id="importForm">
- +
- - - + +
+
-
Index: lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp =================================================================== diff -u -r6132d98ee813109713fda3579007d4359596fc1e -r37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b --- lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp (.../msgattachment.jsp) (revision 6132d98ee813109713fda3579007d4359596fc1e) +++ lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp (.../msgattachment.jsp) (revision 37ecd2fb49ed11a7f9e1d6fc4df7a5cad551868b) @@ -32,7 +32,7 @@