Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java =================================================================== diff -u -r647e8fcb6089018627f3ea32e32c5e242cf60040 -rb5111f65440dc52e81d6fdf29fea71a8d9595eb8 --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java (.../ImportToolContentAction.java) (revision 647e8fcb6089018627f3ea32e32c5e242cf60040) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/ImportToolContentAction.java (.../ImportToolContentAction.java) (revision b5111f65440dc52e81d6fdf29fea71a8d9595eb8) @@ -24,7 +24,9 @@ /* $Id$ */ package org.lamsfoundation.lams.authoring.web; +import java.io.File; import java.io.BufferedReader; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -78,7 +80,6 @@ public static final String ATTR_LD_ID = "learningDesignID"; private static final String KEY_MSG_IMPORT_FILE_NOT_FOUND = "msg.import.file.not.found"; - private static final String KEY_MSG_IMPORT_FILE_FORMAT = "msg.import.file.format"; private static final String KEY_MSG_IMPORT_FAILED_UNKNOWN_REASON = "msg.import.failed.unknown.reason"; @@ -103,10 +104,11 @@ * @param request */ private void importLD(HttpServletRequest request) { + List ldErrorMsgs = new ArrayList(); List toolsErrorMsgs = new ArrayList(); Long ldId = null; - + try { Integer workspaceFolderUid = null; @@ -116,7 +118,7 @@ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER); User user = (User)getUserService().findById(User.class,userDto.getUserID()); - FileItem file = null; + File designFile = null; Map params = new HashMap(); String filename = null; @@ -126,7 +128,7 @@ // maximum size that will be stored in memory fu.setSizeThreshold(4096); // the location for saving data that is larger than getSizeThreshold() - fu.setRepositoryPath(uploadPath); + // fu.setRepositoryPath(uploadPath); List fileItems = fu.parseRequest(request); Iterator iter = fileItems.iterator(); @@ -138,40 +140,28 @@ else { // filename on the client filename = FileUtil.getFileName(fi.getName()); - file = fi; + designFile = new File(uploadPath + filename); + fi.write(designFile); + } workspaceFolderUid = NumberUtils.createInteger((String) params.get("WORKSPACE_FOLDER_UID")); } - if (file == null) { + if (designFile == null) { MessageService msgService = getMessageService(); log.error("Upload file missing. Filename was "+filename); String msg = msgService.getMessage(KEY_MSG_IMPORT_FILE_NOT_FOUND); ldErrorMsgs.add(msg != null ? msg : "Upload file missing"); } else { - - // if it is a .las file then it must be a 1.0.x file. Otherwise assume it is a 2.0 formatting zip file. - String extension = filename != null && filename.length() >= 4 ? filename.substring(filename.length()-4) : ""; - - if ( extension.equalsIgnoreCase(".las") ) { - // process 1.0.x file. - String wddxPacket = getPacket(file.getInputStream()); - if ( wddxPacket == null || ! ( wddxPacket.startsWith(") ldResults[1]; + toolsErrorMsgs = (List) ldResults[2]; + + } } catch (Exception e) { @@ -194,13 +184,6 @@ } - - private void badFileType(List ldErrorMsgs, String filename, String errDescription) { - log.error("Uploaded file not an expected type. Filename was "+filename+" "+errDescription); - MessageService msgService = getMessageService(); - String msg = msgService.getMessage(KEY_MSG_IMPORT_FILE_FORMAT); - ldErrorMsgs.add(msg != null ? msg : "Uploaded file not an expected type."); - } //*************************************************************************************** // Private method @@ -218,22 +201,6 @@ return (MessageService) webContext.getBean(MESSAGE_SERVICE_BEAN_NAME); } - protected String getPacket(InputStream sis) - throws IOException - { - BufferedReader buff = new BufferedReader(new InputStreamReader(sis)); - - StringBuffer tempStrBuf = new StringBuffer( 200 ); - String tempStr; - tempStr = buff.readLine(); - while ( tempStr != null ) - { - tempStrBuf.append(tempStr); - tempStr = buff.readLine(); - } - - return(tempStrBuf.toString()); - } }