protected void upload()
{
accessChecker.checkIsLoggedInUserMemberOfGroup(ProjectForgeGroup.FINANCE_GROUP, ProjectForgeGroup.CONTROLLING_GROUP);
accessChecker.checkRestrictedOrDemoUser();
log.info("upload");
final FileUpload fileUpload = form.fileUploadField.getFileUpload();
if (fileUpload != null) {
final boolean delete = false;
try {
final InputStream is = fileUpload.getInputStream();
final String clientFileName = fileUpload.getClientFileName();
if (clientFileName.endsWith(".jrxml") == true) {
log.error("Jasper reports not supported.");
// delete = true;
// final JasperReport report = JasperCompileManager.compileReport(is);
// if (report != null) {
// getReportScriptingStorage().setJasperReport(report, clientFileName);
// }
} else if (clientFileName.endsWith(".xls") == true) {
final StringBuffer buf = new StringBuffer();
buf.append("report_").append(FileHelper.createSafeFilename(PFUserContext.getUser().getUsername(), 20)).append(".xls");
final File file = new File(ConfigXml.getInstance().getWorkingDirectory(), buf.toString());
fileUpload.writeTo(file);
getReportScriptingStorage().setFilename(clientFileName, file.getAbsolutePath());
} else {
log.error("File extension not supported: " + clientFileName);
}
} catch (final Exception ex) {
log.error(ex.getMessage(), ex);
error("An error occurred (see log files for details): " + ex.getMessage());
} finally {
if (delete == true) {
fileUpload.delete();
}
}
}
}