use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class GenericModerationDAO method getPost.
protected Post getPost(ResultSet rs) throws SQLException {
Post p = new Post();
p.setPostUsername(rs.getString("username"));
p.setId(rs.getInt("post_id"));
p.setUserId(rs.getInt("user_id"));
p.setBbCodeEnabled(rs.getInt("enable_bbcode") == 1);
p.setHtmlEnabled(rs.getInt("enable_html") == 1);
p.setSmiliesEnabled(rs.getInt("enable_smilies") == 1);
p.setSubject(rs.getString("post_subject"));
p.setText(this.getPostTextFromResultSet(rs));
return p;
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class GenericPrivateMessageDAO method getPm.
protected PrivateMessage getPm(ResultSet rs, boolean full) throws SQLException {
PrivateMessage pm = new PrivateMessage();
Post p = new Post();
pm.setId(rs.getInt("privmsgs_id"));
pm.setType(rs.getInt("privmsgs_type"));
p.setTime(new Date(rs.getTimestamp("privmsgs_date").getTime()));
p.setSubject(rs.getString("privmsgs_subject"));
SimpleDateFormat df = new SimpleDateFormat(SystemGlobals.getValue(ConfigKeys.DATE_TIME_FORMAT));
pm.setFormatedDate(df.format(p.getTime()));
if (full) {
UserDAO um = DataAccessDriver.getInstance().newUserDAO();
pm.setFromUser(um.selectById(rs.getInt("privmsgs_from_userid")));
pm.setToUser(um.selectById(rs.getInt("privmsgs_to_userid")));
p.setBbCodeEnabled(rs.getInt("privmsgs_enable_bbcode") == 1);
p.setSignatureEnabled(rs.getInt("privmsgs_attach_sig") == 1);
p.setHtmlEnabled(rs.getInt("privmsgs_enable_html") == 1);
p.setSmiliesEnabled(rs.getInt("privmsgs_enable_smilies") == 1);
p.setText(this.getPmText(rs));
}
pm.setPost(p);
return pm;
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class TopicRSS method prepareRSS.
protected void prepareRSS() {
for (Iterator iter = posts.iterator(); iter.hasNext(); ) {
Post post = (Post) iter.next();
post.setBbCodeEnabled(false);
post.setSmiliesEnabled(false);
RSSItem item = new RSSItem();
item.setAuthor(post.getPostUsername());
item.setPublishDate(RSSUtils.formatDate(post.getTime()));
item.setLink(this.forumLink + "posts/preList/" + post.getTopicId() + "/" + post.getId() + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION));
item.setTitle(post.getSubject());
item.setContentType(RSSAware.CONTENT_HTML);
item.setDescription(PostCommon.preparePostForDisplay(post).getText());
this.rss.addItem(item);
}
super.setRSS(this.rss);
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class SummaryTest method testListPosts.
public void testListPosts() throws Exception {
SummaryModel model = new SummaryModel();
// Gets a Date seven days before now
long weekBefore = Calendar.getInstance().getTimeInMillis() - (7 * 1000 * 60 * 60 * 24);
Date firstDate = new Date(weekBefore);
System.out.println(firstDate);
Collection posts = model.listPosts(firstDate, new Date());
Iterator iter = posts.iterator();
while (iter.hasNext()) {
Post post = (Post) iter.next();
System.out.println(post.getSubject());
}
assertTrue(posts.size() > 0);
}
use of net.jforum.entities.Post in project jforum2 by rafaelsteil.
the class POPListenerTestCase method testInReplyToCreateNewTopicThenReply.
/**
* Create a new topic, then send a message with the In-Reply-To header,
* which should create an answer to the previously created topic
* @throws Exception
*/
public void testInReplyToCreateNewTopicThenReply() throws Exception {
int beforeTopicId = this.maxTopicId();
String sender = "ze@zinho.com";
String subject = "Mail Message " + new Date();
String forumAddress = "forum_test@jforum.testcase";
String contents = "Mail message contents " + new Date();
this.sendMessage(sender, subject, forumAddress, contents, null);
int afterTopicId = this.maxTopicId();
assertTrue("The message was not inserted", afterTopicId > beforeTopicId);
try {
this.assertPost(afterTopicId, sender, subject, contents);
// Ok, now send a new message, replying to the previously topic
subject = "Reply subject for topic " + afterTopicId;
contents = "Changed contents, replying tpoic " + afterTopicId;
this.sendMessage(sender, subject, forumAddress, contents, MessageId.buildMessageId(7777, afterTopicId, 999999));
assertTrue("A new message was created, instead of a reply", afterTopicId == maxTopicId());
PostDAO postDAO = DataAccessDriver.getInstance().newPostDAO();
List posts = postDAO.selectAllByTopic(afterTopicId);
assertTrue("There should be two posts", posts.size() == 2);
// The first message was already validated
Post p = (Post) posts.get(1);
User user = DataAccessDriver.getInstance().newUserDAO().selectById(p.getUserId());
assertNotNull("User should not be null", user);
assertEquals("sender", sender, user.getEmail());
assertEquals("subject", subject, p.getSubject());
assertEquals("text", contents, p.getText());
} finally {
this.deleteTopic(afterTopicId);
}
}
Aggregations