Пример #1
0
 @Transient
 public Long getRealFileId() {
   if (realFileId == null && realFile != null) {
     realFileId = realFile.getId();
   }
   return realFileId;
 }
Пример #2
0
 @RequestMapping(value = "/form-action", method = RequestMethod.POST)
 @Permission(
     value = {"profile-add", "profile-edit"},
     userRequired = true)
 public @ResponseBody Object doFormAction(
     @RequestParam MultipartFile file, @RequestParam Long profileId) throws IOException {
   Attachment attachment = AttachmentUtil.parse(file);
   attachmentService.createAttachment(attachment);
   // write attachment content to local file
   AttachmentUtil.write(attachment);
   Profile profile = profileService.getProfile(profileId);
   Attachment logo = profile.getLogo();
   // delete logo
   if (logo != null) {
     // delete from disk
     AttachmentUtil.delete(logo);
     // delete from database
     attachmentService.deleteAttachment(logo.getId());
   }
   profile.setLogo(attachment);
   profileService.updateProfile(profile);
   return Collections.singletonMap("id", profile.getId());
 }
Пример #3
0
 public String getName() {
   if (StringUtils.isBlank(name) && realFile != null) {
     this.name = realFile.getName();
   }
   return name;
 }