Object command,
BindException errors) throws Exception {
ModelAndView mav = new ModelAndView(getSuccessView());
CompanyLicense companyLicense = (CompanyLicense) command;
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("photo.file");
if (companyLicense.getLicenseId() != null) {
String comment = companyLicense.getPhoto().getComment();
companyLicense = companyLicenseManager.getById(companyLicense.getLicenseId());
Photo photo = photoManager.getByIdPhoto(companyLicense.getPhoto().getPhotoId());
photo.setComment(comment);
photoManager.update(photo, file, FileHelper.getCurrentPath(request),400,400);
companyLicenseManager.update(companyLicense);
return new ModelAndView("redirect:/companyLicenseList.html");
} else {
if (file.getSize() > 0) {
Photo photo = photoManager.insertPhoto(file, FileHelper.getCurrentPath(request),400,400);
photo.setComment(companyLicense.getPhoto().getComment());
companyLicense.setPhoto(photo);
}
companyLicenseManager.insert(companyLicense);
mav.addObject("result", new Integer(1));
}
CompanyLicense com = new CompanyLicense();
// com.setPhoto(new Photo());
mav.addObject("companyLicense", com);
return mav;
}