use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class LuceneContentCollector method retrieveRealPosts.
private List retrieveRealPosts(int[] postIds, Query query) throws IOException {
List posts = DataAccessDriver.getInstance().newLuceneDAO().getPostsData(postIds);
for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
Post post = (Post) iter.next();
Scorer scorer = new QueryScorer(query);
Highlighter highlighter = new Highlighter(scorer);
TokenStream tokenStream = this.settings.analyzer().tokenStream(SearchFields.Indexed.CONTENTS, new StringReader(post.getText()));
String fragment = highlighter.getBestFragment(tokenStream, post.getText());
post.setText(fragment != null ? fragment : post.getText());
}
return posts;
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class TopicPostsRSS method prepareRSS.
private void prepareRSS() {
for (Iterator iter = this.posts.iterator(); iter.hasNext(); ) {
Post p = (Post) iter.next();
p.setBbCodeEnabled(false);
p.setHtmlEnabled(false);
p.setHtmlEnabled(false);
RSSItem item = new RSSItem();
item.setAuthor(p.getPostUsername());
item.setContentType(RSSAware.CONTENT_HTML);
item.setDescription(PostCommon.preparePostForDisplay(p).getText());
item.setPublishDate(RSSUtils.formatDate(p.getTime()));
item.setTitle(p.getSubject());
item.setLink(this.forumLink + "posts/preList/" + p.getTopicId() + "/" + p.getId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION));
this.rss.addItem(item);
}
super.setRSS(this.rss);
}
Aggregations