// Put a valid UploadedFile instance into the map that contains all of the
// uploaded file's attributes, along with a successful status.
Map<String, Object> attributeMap = new HashMap<String, Object>();
String id = Long.toString(((long) hashCode()) + System.currentTimeMillis());
String message = null;
UploadedFile uploadedFile = uploadedFileFactory.getUploadedFile(copiedFileAbsolutePath,
attributeMap, charSet, contentType, headersMap, id, message, fileName,
part.getSize(), UploadedFile.Status.FILE_SAVED);
addUploadedFile(uploadedFileMap, fieldName, uploadedFile);
logger.debug("Received uploaded file fieldName=[{0}] fileName=[{1}]", fieldName, fileName);
// Delete temporary file created by the Servlet API.
part.delete();
}
catch (IOException e) {
UploadedFile uploadedFile = uploadedFileFactory.getUploadedFile(e);
addUploadedFile(uploadedFileMap, fieldName, uploadedFile);
}
}
}
catch (Exception e) {
logger.error(e);
UploadedFile uploadedFile = uploadedFileFactory.getUploadedFile(e);
String fieldName = Integer.toString(totalFiles);
addUploadedFile(uploadedFileMap, fieldName, uploadedFile);
}
}
}
// If there was an error in parsing the request for file parts, then put a bogus UploadedFile instance in
// the map so that the developer can have some idea that something went wrong.
catch (Exception e) {
logger.error(e);
UploadedFile uploadedFile = uploadedFileFactory.getUploadedFile(e);
addUploadedFile(uploadedFileMap, "unknown", uploadedFile);
}
return uploadedFileMap;
}