HttpServletRequest request, HttpServletResponse response)
throws Exception {
checkAuthorization(userHasPrivilege(request.getSession(),
getPrivileges()));
ScienceProjectService service = getService(ScienceProjectService.class);
//This segment valildates the UploadFormFile form manually because automatic Struts validation does not work.
ActionErrors errors = new ActionErrors();
String typeId = ((UploadFileForm) form).getMyFileTypeId().trim();
if(typeId.length()< 1){
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("uploadFile.typeId"));
}
if(((UploadFileForm) form).getMyFile().getFileSize()< 1){
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("uploadFile.file"));
}
if(service.loadScienceProjectByStudentUserId(getAuthenticatedUser(request).getUserId())== null){
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("uploadFile.no.project"));
}
if(!errors.isEmpty()){
saveErrors(request, errors);
return mapping.getInputForward();
}
UploadFileVo ufvo = new UploadFileVo();
BeanUtils.copyProperties(ufvo, form);
//set the ID of the project which will be associated with this file.
ufvo.setUserId(getAuthenticatedUser(request).getUserId());
service.saveProjectFile(ufvo);
return mapping.findForward(WebConstants.FORWARD_VIEW);
}