001: /*
002: * Copyright (c) JForum Team
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms,
006: * with or without modification, are permitted provided
007: * that the following conditions are met:
008: *
009: * 1) Redistributions of source code must retain the above
010: * copyright notice, this list of conditions and the
011: * following disclaimer.
012: * 2) Redistributions in binary form must reproduce the
013: * above copyright notice, this list of conditions and
014: * the following disclaimer in the documentation and/or
015: * other materials provided with the distribution.
016: * 3) Neither the name of "Rafael Steil" nor
017: * the names of its contributors may be used to endorse
018: * or promote products derived from this software without
019: * specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
022: * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
023: * EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
024: * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
025: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR
026: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
027: * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
028: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
029: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES
030: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
031: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
032: * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
033: * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
034: * IN CONTRACT, STRICT LIABILITY, OR TORT
035: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
036: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
037: * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
038: *
039: * Created on 22/10/2004 00:51:36
040: * The JForum Project
041: * http://www.jforum.net
042: */
043: package net.jforum.util.rss;
044:
045: import java.util.Iterator;
046: import java.util.List;
047:
048: import net.jforum.entities.Post;
049: import net.jforum.util.preferences.ConfigKeys;
050: import net.jforum.util.preferences.SystemGlobals;
051: import net.jforum.view.forum.common.PostCommon;
052: import net.jforum.view.forum.common.ViewCommon;
053:
054: /**
055: * RSS for the messages of some topic
056: *
057: * @author Rafael Steil
058: * @version $Id: TopicPostsRSS.java,v 1.12 2007/08/20 20:21:58 rafaelsteil Exp $
059: */
060: public class TopicPostsRSS extends GenericRSS {
061: private List posts;
062: protected RSS rss;
063: protected String forumLink;
064:
065: public TopicPostsRSS(String title, String description, int topicId,
066: List posts) {
067: this .forumLink = ViewCommon.getForumLink();
068:
069: this .posts = posts;
070: this .rss = new RSS(title, description, SystemGlobals
071: .getValue(ConfigKeys.ENCODING), this .forumLink
072: + "posts/list/" + topicId
073: + SystemGlobals.getValue(ConfigKeys.SERVLET_EXTENSION));
074: this .prepareRSS();
075: }
076:
077: private void prepareRSS() {
078: for (Iterator iter = this .posts.iterator(); iter.hasNext();) {
079: Post p = (Post) iter.next();
080:
081: p.setBbCodeEnabled(false);
082: p.setHtmlEnabled(false);
083: p.setHtmlEnabled(false);
084:
085: RSSItem item = new RSSItem();
086: item.setAuthor(p.getPostUsername());
087: item.setContentType(RSSAware.CONTENT_HTML);
088: item.setDescription(PostCommon.preparePostForDisplay(p)
089: .getText());
090: item.setPublishDate(RSSUtils.formatDate(p.getTime()));
091: item.setTitle(p.getSubject());
092: item.setLink(this .forumLink
093: + "posts/preList/"
094: + p.getTopicId()
095: + "/"
096: + p.getId()
097: + SystemGlobals
098: .getValue(ConfigKeys.SERVLET_EXTENSION));
099:
100: this.rss.addItem(item);
101: }
102:
103: super.setRSS(this.rss);
104: }
105: }
|