/** * Render the page with the form for the reply with quoting to original message. * The form has the next filled fields: recipient, title, message * * @param id {@link PrivateMessage} id * @return {@code ModelAndView} with the message having filled recipient, title, message fields * @throws NotFoundException when message not found */ @RequestMapping(value = "/quote/{pmId}", method = RequestMethod.GET) public ModelAndView quotePage(@PathVariable(PM_ID) Long id) throws NotFoundException { PrivateMessage pm = pmService.get(id); PrivateMessageDto dto = PrivateMessageDto.getReplyDtoFor(pm); dto.setBody(bbCodeService.quote(pm.getBody(), pm.getUserFrom())); return new ModelAndView(PM_FORM).addObject(DTO, dto); }
/** * Create the full private message dto from {@link PrivateMessage} * * @param pm private message for conversion * @return dto for full private message */ public static PrivateMessageDto getFullPmDtoFor(PrivateMessage pm) { PrivateMessageDto dto = new PrivateMessageDto(); dto.setBody(pm.getBody()); dto.setTitle(pm.getTitle()); if (pm.getUserTo() != null) { dto.setRecipient(pm.getUserTo().getUsername()); } dto.setId(pm.getId()); return dto; }