Index: lams_central/src/java/org/lamsfoundation/lams/web/QuestionsController.java =================================================================== diff -u -r738886899fd098b8cc2112c5e7974a9921a29c25 -r7c0aefd996982f4c4412973df9695d5c3fed8635 --- lams_central/src/java/org/lamsfoundation/lams/web/QuestionsController.java (.../QuestionsController.java) (revision 738886899fd098b8cc2112c5e7974a9921a29c25) +++ lams_central/src/java/org/lamsfoundation/lams/web/QuestionsController.java (.../QuestionsController.java) (revision 7c0aefd996982f4c4412973df9695d5c3fed8635) @@ -3,15 +3,11 @@ import java.io.File; import java.io.InputStream; import java.util.Collections; -import java.util.List; import java.util.Set; import java.util.TreeSet; import javax.servlet.http.HttpServletRequest; -import org.apache.commons.fileupload.FileItem; -import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.lang.StringUtils; import org.lamsfoundation.lams.questions.Question; import org.lamsfoundation.lams.questions.QuestionParser; @@ -24,6 +20,8 @@ import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.multipart.MultipartFile; /** * Runs extraction of chosen IMS QTI zip file and prepares form for user to manually choose interesting question. @@ -36,34 +34,21 @@ MessageService messageService; @RequestMapping("/questions") - public String execute(HttpServletRequest request) throws Exception { - + public String execute(@RequestParam(name = "file", required = false) MultipartFile file, + @RequestParam String returnURL, @RequestParam("limitType") String limitTypeParam, + HttpServletRequest request) throws Exception { + String tempDirName = Configuration.get(ConfigurationKeys.LAMS_TEMP_DIR); File tempDir = new File(tempDirName); if (!tempDir.exists()) { tempDir.mkdirs(); } - - DiskFileItemFactory fileItemFactory = new DiskFileItemFactory(); - fileItemFactory.setRepository(tempDir); - ServletFileUpload fileUpload = new ServletFileUpload(fileItemFactory); - List fileItems = fileUpload.parseRequest(request); - String returnURL = null; - String limitTypeParam = null; InputStream uploadedFileStream = null; String packageName = null; - for (FileItem fileItem : fileItems) { - String fieldName = fileItem.getFieldName(); - if ("returnURL".equals(fieldName)) { - // this can be empty; if so, another method of delivering results is used - returnURL = fileItem.getString(); - } else if ("limitType".equals(fieldName)) { - limitTypeParam = fileItem.getString(); - } else if ("file".equals(fieldName) && !StringUtils.isBlank(fileItem.getName())) { - packageName = fileItem.getName().toLowerCase(); - uploadedFileStream = fileItem.getInputStream(); - } + if (file != null) { + packageName = file.getOriginalFilename().toLowerCase(); + uploadedFileStream = file.getInputStream(); } // this parameter is not really used at the moment @@ -74,7 +59,6 @@ // user did not choose a file if ((uploadedFileStream == null) || !(packageName.endsWith(".zip") || packageName.endsWith(".xml"))) { - MultiValueMap errorMap = new LinkedMultiValueMap<>(); errorMap.add("GLOBAL", messageService.getMessage("label.questions.file.missing")); request.setAttribute("errorMap", errorMap); Index: lams_central/web/WEB-INF/web.xml =================================================================== diff -u -r33829c670fd8c90447d62ea3300498a103905e7a -r7c0aefd996982f4c4412973df9695d5c3fed8635 --- lams_central/web/WEB-INF/web.xml (.../web.xml) (revision 33829c670fd8c90447d62ea3300498a103905e7a) +++ lams_central/web/WEB-INF/web.xml (.../web.xml) (revision 7c0aefd996982f4c4412973df9695d5c3fed8635) @@ -69,10 +69,6 @@ org.lamsfoundation.lams.web.filter.LocaleFilter - - springMultipartFilter - org.springframework.web.multipart.support.MultipartFilter - UrlRewriteFilter @@ -151,19 +147,7 @@ LocaleFilter /ckeditor/* - - springMultipartFilter - /ckeditor/filemanager/browser/default/connectors/jsp/connector - - - springMultipartFilter - /ckeditor/filemanager/upload/simpleuploader - - - springMultipartFilter - /questions.do - - + org.springframework.web.context.ContextLoaderListener