Source Code Cross Referenced for BlogEntry.java in  » Content-Management-System » openedit » com » openedit » blog » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » openedit » com.openedit.blog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Feb 18, 2005
003:         */
004:        package com.openedit.blog;
005:
006:        import java.io.Serializable;
007:        import java.text.ParseException;
008:        import java.text.SimpleDateFormat;
009:        import java.util.ArrayList;
010:        import java.util.Date;
011:        import java.util.HashMap;
012:        import java.util.Iterator;
013:        import java.util.List;
014:        import java.util.Map;
015:
016:        import org.apache.commons.logging.Log;
017:        import org.apache.commons.logging.LogFactory;
018:        import org.openedit.blog.archive.CommentArchive;
019:        import org.openedit.links.LinkTree;
020:
021:        import com.openedit.OpenEditException;
022:        import com.openedit.OpenEditRuntimeException;
023:        import com.openedit.page.manage.PageManager;
024:        import com.openedit.users.User;
025:        import com.sun.syndication.feed.synd.SyndContentImpl;
026:        import com.sun.syndication.feed.synd.SyndEntryImpl;
027:
028:        /**
029:         * @author cburkey
030:         *
031:         */
032:        public class BlogEntry extends SyndEntryImpl implements  Serializable,
033:                Comparable {
034:            protected String fieldPath;
035:            protected List fieldComments;
036:            transient protected PageManager fieldPageManager;
037:            protected LinkTree fieldLinkTree;
038:            protected boolean fieldVisible = false;
039:            protected static SimpleDateFormat fieldGmtStandard;
040:            protected User fieldUser;
041:            protected List fieldNotify;
042:            protected CommentArchive fieldCommentArchive;
043:            private static final Log log = LogFactory.getLog(BlogEntry.class);
044:            protected Map fieldProperties;
045:
046:            public BlogEntry() {
047:            }
048:
049:            public String getPath() {
050:                return fieldPath;
051:            }
052:
053:            /**
054:             * A path is just the end part of a link
055:             * @param inPath
056:             */
057:
058:            public void setPath(String inPath) {
059:                fieldPath = inPath;
060:            }
061:
062:            public String published(String inFormat) {
063:                SimpleDateFormat format = new SimpleDateFormat(inFormat);
064:                return format.format(getPublishedDate());
065:            }
066:
067:            public String getId() {
068:                return getPath();
069:            }
070:
071:            /**
072:             * Returns the total number of comments on this blog entry, both visible
073:             * (published) and invisible (unpublished).
074:             * 
075:             * @return  The number of comments
076:             * 
077:             * @throws OpenEditException
078:             *     If the comments needed to be loaded and could not be
079:             */
080:            public int countComments() throws OpenEditException {
081:                return getComments().size();
082:            }
083:
084:            /**
085:             * Returns the number of visible (published) comments on this blog entry.
086:             * 
087:             * @return  The number of visible comments
088:             * 
089:             * @throws OpenEditException
090:             *     If the comments needed to be loaded and could not be
091:             */
092:            public int countVisibleComments() throws OpenEditException {
093:                return getVisibleComments().size();
094:            }
095:
096:            /**
097:             * Returns all the comments on this blog, published or unpublished.
098:             * 
099:             * @return  A {@link List} of {@link Comment}s
100:             * 
101:             * @throws OpenEditException
102:             *     If the comments needed to be loaded and could not be
103:             */
104:            public List getComments() throws OpenEditException {
105:                if (fieldComments == null) {
106:                    fieldComments = new ArrayList();
107:                    getCommentArchive().loadComments(this );
108:                }
109:                return fieldComments;
110:            }
111:
112:            /**
113:             * Returns all comments on this blog entry that are visible (published).
114:             * 
115:             * @return  A {@link List} of {@link Comment}s
116:             * 
117:             * @throws OpenEditException
118:             *     If the comments needed to be loaded and could not be
119:             */
120:            public List getVisibleComments() throws OpenEditException {
121:                List comments = getComments();
122:                List visibleComments = new ArrayList();
123:                for (Iterator iter = comments.iterator(); iter.hasNext();) {
124:                    Comment comment = (Comment) iter.next();
125:                    if (comment.isVisible()) {
126:                        visibleComments.add(comment);
127:                    }
128:                }
129:                return visibleComments;
130:            }
131:
132:            public List getAllowedComments(User inUser)
133:                    throws OpenEditException {
134:                List comments = getComments();
135:                List allowedComments = new ArrayList();
136:                for (Iterator iter = comments.iterator(); iter.hasNext();) {
137:                    Comment comment = (Comment) iter.next();
138:                    if (comment.isVisible() || comment.canEdit(inUser)) {
139:                        allowedComments.add(comment);
140:                    }
141:                }
142:                return allowedComments;
143:            }
144:
145:            public PageManager getPageManager() {
146:                return fieldPageManager;
147:            }
148:
149:            public void setPageManager(PageManager inPageManager) {
150:                fieldPageManager = inPageManager;
151:            }
152:
153:            public LinkTree getLinkTree() {
154:                return fieldLinkTree;
155:            }
156:
157:            public void setLinkTree(LinkTree inLinkTree) {
158:                fieldLinkTree = inLinkTree;
159:            }
160:
161:            /**
162:             * Adds a comment to this blog entry.  The comment's data, including the
163:             * ID, must already be populated.
164:             * 
165:             * @param inComment  The new comment
166:             */
167:            public void addComment(Comment inComment) throws OpenEditException {
168:                // TODO: check for dups
169:                getComments().add(inComment);
170:            }
171:
172:            /**
173:             * Returns the comment with the given comment ID.
174:             * 
175:             * @param inId  The comment ID
176:             * 
177:             * @return  The comment, or <code>null</code> if this entry does not have a
178:             *          comment with the given ID
179:             */
180:            public Comment getComment(String inId) throws OpenEditException {
181:                for (Iterator iter = getComments().iterator(); iter.hasNext();) {
182:                    Comment comment = (Comment) iter.next();
183:                    if (comment.getId().equals(inId)) {
184:                        return comment;
185:                    }
186:                }
187:                return null;
188:            }
189:
190:            public void removeComment(String inId) throws OpenEditException {
191:                Comment comment = getComment(inId);
192:                removeComment(comment);
193:            }
194:
195:            public void removeComment(Comment inComment)
196:                    throws OpenEditException {
197:                if (inComment != null) {
198:                    getComments().remove(inComment);
199:                }
200:            }
201:
202:            /**
203:             * @param inContent
204:             */
205:            public void setDescription(String inContent) {
206:                SyndContentImpl content = new SyndContentImpl();
207:                content.setType("text/html");
208:                content.setValue(inContent);
209:                setDescription(content);
210:            }
211:
212:            public boolean isVisible() {
213:                return fieldVisible;
214:            }
215:
216:            public void setVisible(boolean invisible) {
217:                this .fieldVisible = invisible;
218:            }
219:
220:            public SimpleDateFormat getGmtStandard() {
221:                if (fieldGmtStandard == null) {
222:                    fieldGmtStandard = new SimpleDateFormat(
223:                            "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
224:                }
225:                return fieldGmtStandard;
226:            }
227:
228:            public Date parse(String inDate) {
229:                try {
230:                    if (inDate.startsWith("2")) {
231:                        return getGmtStandard().parse(inDate);
232:                    } else {
233:                        return SimpleDateFormat.getDateTimeInstance().parse(
234:                                inDate);
235:                    }
236:                } catch (ParseException ex) {
237:                    throw new OpenEditRuntimeException(ex);
238:                }
239:            }
240:
241:            public void setGmtStandard(SimpleDateFormat inGmtStandard) {
242:                fieldGmtStandard = inGmtStandard;
243:            }
244:
245:            public User getUser() {
246:                return fieldUser;
247:            }
248:
249:            public void setUser(User inUser) {
250:                fieldUser = inUser;
251:            }
252:
253:            public List getNotify() {
254:                return fieldNotify;
255:            }
256:
257:            public void setNotify(List inNotify) {
258:                fieldNotify = inNotify;
259:            }
260:
261:            public CommentArchive getCommentArchive() {
262:                return fieldCommentArchive;
263:            }
264:
265:            public void setCommentArchive(CommentArchive inCommentArchive) {
266:                fieldCommentArchive = inCommentArchive;
267:            }
268:
269:            public int compareTo(Object inEntry) {
270:                BlogEntry in = (BlogEntry) inEntry;
271:                return getPublishedDate().compareTo(in.getPublishedDate());
272:            }
273:
274:            public Map getProperties() {
275:                if (fieldProperties == null) {
276:                    fieldProperties = new HashMap();
277:
278:                }
279:
280:                return fieldProperties;
281:            }
282:
283:            public void setProperties(Map fieldProperties) {
284:                this .fieldProperties = fieldProperties;
285:            }
286:
287:            public void addProperty(String key, String value) {
288:                getProperties().put(key, value);
289:            }
290:
291:            public String getProperty(String key) {
292:                return (String) getProperties().get(key);
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.