Ejemplo n.º 1
0
 @RequestMapping("/form-view")
 @Permission(
     value = {"profile-add", "profile-edit"},
     userRequired = true)
 public String doFormView(@RequestParam Long profileId, Model model) {
   Profile profile = profileService.getProfile(profileId);
   model.addAttribute(AttributeKeys.PROFILE_KEY_READABLE, profile);
   return "profile/logo-form";
 }
Ejemplo 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());
 }