public static void uploadFileToTempDir(HandlerContext handlerCtx) {
Logger logger = GuiUtil.getLogger();
if (logger.isLoggable(Level.FINE)){
logger.fine(GuiUtil.getCommonMessage("log.inUploadFileToTmpDir"));
}
UploadedFile uploadedFile = (UploadedFile) handlerCtx.getInputValue("file");
File tmpFile = null;
String uploadTmpFile = "";
if (uploadedFile != null) {
String name = uploadedFile.getOriginalName();
logger.info("uploadFileName="+name);
//see bug# 6498910, for IE, getOriginalName() returns the full path, including the drive.
//for any other browser, it just returns the file name.
int lastIndex = name.lastIndexOf("\\");
if (lastIndex != -1) {
name = name.substring(lastIndex + 1, name.length());
}
int index = name.indexOf(".");
if (index <= 0) {
logger.info("name="+name + ",index="+index);
String mesg = GuiUtil.getMessage("msg.deploy.nullArchiveError");
GuiUtil.handleError(handlerCtx, mesg);
return;
}
String suffix = name.substring(index);
String prefix = name.substring(0, index);
handlerCtx.setOutputValue("origPath", prefix);
try {
//createTempFile requires min. of 3 char for prefix.
if (prefix.length() <= 2) {
prefix = prefix + new Random().nextInt(100000);
}
tmpFile = File.createTempFile(prefix, suffix);
tmpFile.deleteOnExit();
if (logger.isLoggable(Level.FINE)){
logger.fine(GuiUtil.getCommonMessage("log.writeToTmpFile"));
}
uploadedFile.write(tmpFile);
if (logger.isLoggable(Level.FINE)){
logger.fine(GuiUtil.getCommonMessage("log.afterWriteToTmpFile"));
}
uploadTmpFile = tmpFile.getCanonicalPath();
} catch (IOException ioex) {