Exemplo n.º 1
0
 @Transient
 public Long getRealFileId() {
   if (realFileId == null && realFile != null) {
     realFileId = realFile.getId();
   }
   return realFileId;
 }
Exemplo n.º 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());
 }