private MentionedUsers(Post post) { this.post = post; this.postContent = post.getPostContent(); }
/** * @return content of the first post of the topic */ public String getBodyText() { Post firstPost = getFirstPost(); return firstPost.getPostContent(); }
/** * Change BB user tag to mark user as already notified * * @param username this user was mentioned * @param postDao service for working with Post objects */ private void markUserAsAlreadyNotified(String username, PostDao postDao) { String initialUserMentioning = format(MENTIONED_NOT_NOTIFIED_USER_TEMPLATE, username); String notifiedUserMentioning = format(MENTIONED_AND_NOTIFIED_USER_TEMPLATE, username); String newPostContent = post.getPostContent().replace(initialUserMentioning, notifiedUserMentioning); post.setPostContent(newPostContent); postDao.saveOrUpdate(post); }
/** * Get quote text. * If user select nothing JS will substitute whole post contents here * <p/> * Supports post method to pass large quotations. * * @param postId identifier os the post we're quoting * @param selection text selected by user for the quotation * @throws NotFoundException when topic was not found */ @RequestMapping(method = RequestMethod.POST, value = "/posts/{postId}/quote") @ResponseBody public JsonResponse getQuote(@PathVariable(POST_ID) Long postId, @RequestParam("selection") String selection) throws NotFoundException { Post source = postService.get(postId); String content = StringUtils.defaultString(selection, source.getPostContent()); return new JsonResponse(JsonResponseStatus.SUCCESS, bbCodeService.quote(content, source.getUserCreated())); }
/** * Create dto * * @param post post for conversion * @return dto for post */ public static PostDto getDtoFor(Post post) { PostDto dto = new PostDto(); dto.setBodyText(post.getPostContent()); dto.setId(post.getId()); dto.setTopicId(post.getTopic().getId()); dto.setCreationDate(post.getCreationDate()); dto.setModificationDate(post.getModificationDate()); return dto; }
/** * Creates feed item with information about the post * * @param post post to add to the feed * @param componentUrl base url of the forum component * @return item for the RSS feed */ private Item createFeedItem(Post post, String componentUrl) { Item item = new Item(); Content content = new Content(); content.setType(Content.TEXT); content.setValue(post.getPostContent()); item.setContent(content); item.setTitle(post.getTopic().getTitle()); item.setAuthor(post.getUserCreated().getUsername()); item.setLink(componentUrl + "/posts/" + post.getId()); item.setPubDate(post.getCreationDate().toDate()); return item; }
/** * Create news item * * @param topic news topic * @param url building URL * @return item for news feed */ private Item createFeedItem(Topic topic, String url) { Item item = new Item(); Description description = new Description(); description.setType("text"); String postContent = topic.getLastPost().getPostContent(); postContent = RssUtils.skipInValidXMLChars(postContent); description.setValue(postContent); Content content = new Content(); item.setContent(content); item.setTitle(topic.getTitle()); item.setAuthor(topic.getLastPost().getUserCreated().getUsername()); item.setLink(url + "/posts/" + topic.getLastPost().getId()); item.setComments(topic.getTopicStarter().getSignature()); item.setDescription(description); item.setPubDate(topic.getModificationDate().toDate()); return item; }