if (contentType == null || !contentType.toLowerCase().startsWith("multipart/form-data")) {
return null;
}
RequestFacadeImpl facade = new RequestFacadeImpl(request);
MultiPartHandler multiReq = new MultiPartHandler(facade, tmpDir.getAbsolutePath(), Utils.getMaxUploadSize());
try{
multiReq.parseMultipartUpload();
}finally{
facade.getInput().getInputStream().close();
}
// the file is uploaded as arguments "logs"
File appFile = multiReq.getFile("logs"); // NOI18N
if (appFile == null) {
return null;
}
File result = move(appFile, Utils.getRootUploadDirPath());
File messagesFile = multiReq.getFile("messages");
if (messagesFile != null){
String messagesRootUploadDir = Utils.getMessagesRootUploadDir();
String messagesUploadDir = Utils.getUploadDirPath(messagesRootUploadDir, getId(appFile));
File targetFile = new File(messagesUploadDir, result.getName());
if (!messagesFile.renameTo(targetFile)) {
LOG.severe("moving " + messagesFile.getPath() + " to " + targetFile.getPath() + " failed");
} else {
LOG.fine("moving " + messagesFile.getPath() + " to " + targetFile.getPath() + " done");
}
}
moveAdditional(multiReq.getFile("slowness"), appFile, result.getName(), Utils.getSlownessRootUploadDir());
moveAdditional(multiReq.getFile("heapdump"), appFile, result.getName(), Utils.getHeapRootUploadDir());
return result;
}