Source Code Cross Referenced for Blog.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.util.ArrayList;
007:        import java.util.Collections;
008:        import java.util.Date;
009:        import java.util.List;
010:        import java.util.Map;
011:        import java.util.Random;
012:
013:        import org.apache.commons.collections.map.ReferenceMap;
014:        import org.apache.commons.logging.Log;
015:        import org.apache.commons.logging.LogFactory;
016:        import org.openedit.blog.archive.EntryArchive;
017:        import org.openedit.links.Link;
018:        import org.openedit.links.LinkTree;
019:
020:        import com.openedit.BaseWebPageRequest;
021:        import com.openedit.OpenEditException;
022:        import com.openedit.page.Page;
023:        import com.openedit.page.manage.PageManager;
024:        import com.openedit.users.User;
025:        import com.openedit.users.UserManager;
026:        import com.openedit.util.strainer.Filter;
027:
028:        /**
029:         * @author cburkey
030:         */
031:        public class Blog {
032:            protected PageManager fieldPageManager;
033:            protected LinkTree fieldLinkTree;
034:            protected String fieldBlogHome;
035:            protected String fieldArchiveRootDirectory;
036:            protected String fieldHostName;
037:            protected String fieldDescription;
038:            protected String fieldTitle;
039:
040:            protected String fieldAuthor;
041:            protected int fieldRecentMaxCount = 5;
042:            protected String fieldPermission;
043:            protected boolean fieldAllowAnonymous;
044:            protected boolean fieldAutoPublishingComments;
045:            protected boolean fieldAutoPublishEntries;
046:            protected boolean fieldIsUsingNotification;
047:
048:            protected Map fieldCache;
049:            protected UserManager fieldUserManager;
050:            protected EntryArchive fieldEntryArchive;
051:            protected Date fieldLastModified;
052:
053:            Random fieldRandom;
054:
055:            private static final Log log = LogFactory.getLog(Blog.class);
056:
057:            public List getRecentEntries() throws OpenEditException {
058:                return getRecentEntries(getRecentMaxCount());
059:            }
060:
061:            public List getVisibleEntries(int start, int end)
062:                    throws OpenEditException {
063:                return getEntries(start, end, true, false);
064:            }
065:
066:            /**
067:             * Returns the given number of most recent entries.
068:             * 
069:             * @param inCount  The number of entries to return
070:             * 
071:             * @return  A {@link List} of {@link BlogEntry}s
072:             */
073:            public List getRecentEntries(int inCount) throws OpenEditException {
074:                return getEntries(0, inCount, false, false);
075:            }
076:
077:            public List getRecentVisibleEntries(int inI)
078:                    throws OpenEditException {
079:                return getEntries(0, inI, true, false);
080:            }
081:
082:            public List getRandomRecentEntries(int inCount)
083:                    throws OpenEditException {
084:                return getEntries(0, inCount, false, true);
085:            }
086:
087:            public List getRandomRecentVisibleEntries(int inI)
088:                    throws OpenEditException {
089:                return getEntries(0, inI, true, true);
090:            }
091:
092:            public List getEntries(int start, int end, boolean visibleOnly,
093:                    boolean sortRandom) throws OpenEditException {
094:                int num;
095:                if (getLinkTree().getRootLink() == null) {
096:                    return Collections.EMPTY_LIST;
097:                }
098:                // added "new ArrayList" because when i call more than once without it, links get empty
099:                List links = new ArrayList(getLinkTree().getRootLink()
100:                        .getChildren());
101:                start = Math.min(start, links.size());
102:                if (end > links.size()) {
103:                    end = links.size();
104:                }
105:                if (end == 0) //end == 0 means get all entries
106:                {
107:                    end = links.size();
108:                }
109:                //read in the links xml file and take off the top entries
110:                //then for each link go get the entry from the xconf file
111:                List entries = new ArrayList();
112:                for (int i = start; i < end; i++) {
113:                    if (sortRandom) {
114:                        num = getRandom().nextInt(links.size());
115:                    } else {
116:                        num = i;
117:                    }
118:                    Link link = (Link) links.get(num);
119:                    BlogEntry entry = getEntry(link.getUrl());
120:                    if (entry != null && (!visibleOnly || entry.isVisible())) {
121:                        entries.add(entry);
122:                        if (sortRandom) {
123:                            links.remove(num);
124:                        }
125:                    } else {
126:                        if (end < links.size()) {
127:                            end++;
128:                        }
129:                    }
130:                }
131:                return entries;
132:
133:            }
134:
135:            public Random getRandom() {
136:                if (fieldRandom == null) {
137:                    fieldRandom = new Random();
138:                }
139:                return fieldRandom;
140:            }
141:
142:            public void setRandom(Random inRandom) {
143:                fieldRandom = inRandom;
144:            }
145:
146:            public void removeEntry(BlogEntry inEntry) throws OpenEditException {
147:                Link link = getLinkTree().getLink(inEntry.getId());
148:                getLinkTree().removeLink(link);
149:            }
150:
151:            public List sortByRank(List inEntries) {
152:                return inEntries;
153:            }
154:
155:            public LinkTree getLinkTree() {
156:                return fieldLinkTree;
157:            }
158:
159:            public void setLinkTree(LinkTree inLinkTree) {
160:                fieldLinkTree = inLinkTree;
161:            }
162:
163:            public PageManager getPageManager() {
164:                return fieldPageManager;
165:            }
166:
167:            public void setPageManager(PageManager inPageManager) {
168:                fieldPageManager = inPageManager;
169:            }
170:
171:            public String getLink() {
172:                return getBlogHome();
173:            }
174:
175:            public String getBlogHome() {
176:                return fieldBlogHome;
177:            }
178:
179:            public void setBlogHome(String inBlogRoot) {
180:                fieldBlogHome = inBlogRoot;
181:            }
182:
183:            public String getHostName() {
184:                return fieldHostName;
185:            }
186:
187:            public void setHostName(String inHostName) {
188:                fieldHostName = inHostName;
189:            }
190:
191:            public String getDescription() {
192:                return fieldDescription;
193:            }
194:
195:            public void setDescription(String inDescription) {
196:                fieldDescription = inDescription;
197:            }
198:
199:            public String getTitle() {
200:                return fieldTitle;
201:            }
202:
203:            public void setTitle(String inTitle) {
204:                fieldTitle = inTitle;
205:            }
206:
207:            public int getRecentMaxCount() {
208:                return fieldRecentMaxCount;
209:            }
210:
211:            public void setRecentMaxCount(int inRecentMaxCount) {
212:                fieldRecentMaxCount = inRecentMaxCount;
213:            }
214:
215:            /**
216:             * @param inEntryId
217:             * @return
218:             */
219:            public BlogEntry getEntry(String inPath) throws OpenEditException {
220:                Page page = getPageManager().getPage(inPath);
221:                if (!page.exists()) {
222:                    //strip off the ending and look in the archive root
223:                    if (inPath.startsWith(getArchiveRootDirectory())) {
224:                        String ending = inPath.substring(
225:                                getArchiveRootDirectory().length(), inPath
226:                                        .length());
227:                        //entry.setPath(ending);
228:                        inPath = ending;
229:                        page = getPageManager().getPage(inPath);
230:                    }
231:                }
232:
233:                BlogEntry entry = (BlogEntry) getCache().get(inPath);
234:                if (entry == null) {
235:                    entry = getEntryArchive().createEntry(this , page);
236:                    getCache().put(inPath, entry);
237:                }
238:                return entry;
239:            }
240:
241:            public BlogEntry createNewEntry(User inUser)
242:                    throws OpenEditException {
243:                return getEntryArchive().createEntry(this , inUser);
244:            }
245:
246:            public boolean canEdit(User inUser) throws OpenEditException {
247:                if (inUser == null) {
248:                    return false;
249:                }
250:                String slink = getBlogHome() + "/permalinks.xml";
251:
252:                Page linkpage = getPageManager().getPage(slink);
253:                Filter filter = linkpage.getEditFilter();
254:                BaseWebPageRequest req = new BaseWebPageRequest();
255:                req.setUser(inUser);
256:                req.setContentPage(linkpage);
257:                req.setPage(linkpage);
258:                boolean value = ((filter == null) || filter.passes(req));
259:
260:                return value;
261:            }
262:
263:            public String getAuthor() {
264:                return fieldAuthor;
265:            }
266:
267:            public void setAuthor(String inAuthor) {
268:                fieldAuthor = inAuthor;
269:            }
270:
271:            public String getEditPermission() {
272:                return fieldPermission;
273:            }
274:
275:            public void setEditPermission(String inEditors) {
276:                fieldPermission = inEditors;
277:            }
278:
279:            public boolean getAllowAnonymous() {
280:                return fieldAllowAnonymous;
281:            }
282:
283:            public void setAllowAnonymous(boolean inAllowAnonymous) {
284:                fieldAllowAnonymous = inAllowAnonymous;
285:            }
286:
287:            public boolean isAutoPublishingComments() {
288:                return fieldAutoPublishingComments;
289:            }
290:
291:            public void setAutoPublishingComments(
292:                    boolean inAutoPublishingComments) {
293:                fieldAutoPublishingComments = inAutoPublishingComments;
294:            }
295:
296:            public Comment createNewComment(User inAuthor, String inContent) {
297:                Comment comment = new Comment();
298:                comment.setAuthor(inAuthor.getShortDescription());
299:                comment.setUser(inAuthor);
300:                comment.setContent(inContent);
301:                comment.setDateTime(new Date());
302:                comment.setId(String.valueOf(System.currentTimeMillis()));
303:                comment.setVisible(isAutoPublishingComments());
304:                return comment;
305:            }
306:
307:            public boolean isAutoPublishEntries() {
308:                return fieldAutoPublishEntries;
309:            }
310:
311:            public void setAutoPublishEntries(boolean inAutoPublishEntries) {
312:                fieldAutoPublishEntries = inAutoPublishEntries;
313:            }
314:
315:            public String getArchiveRootDirectory() {
316:                return fieldArchiveRootDirectory;
317:            }
318:
319:            public void setArchiveRootDirectory(String inArchiveRootDirectory) {
320:                fieldArchiveRootDirectory = inArchiveRootDirectory;
321:            }
322:
323:            public Map getCache() {
324:                if (fieldCache == null) {
325:                    fieldCache = new ReferenceMap(ReferenceMap.HARD,
326:                            ReferenceMap.HARD);
327:                }
328:                return fieldCache;
329:            }
330:
331:            public void setCache(Map inCache) {
332:                fieldCache = inCache;
333:            }
334:
335:            public UserManager getUserManager() {
336:                return fieldUserManager;
337:            }
338:
339:            public void setUserManager(UserManager inUserManager) {
340:                fieldUserManager = inUserManager;
341:            }
342:
343:            public boolean isUseNotification() {
344:                return fieldIsUsingNotification;
345:            }
346:
347:            public void setUseNotification(boolean inBol) {
348:                fieldIsUsingNotification = inBol;
349:            }
350:
351:            public EntryArchive getEntryArchive() {
352:                return fieldEntryArchive;
353:            }
354:
355:            public void setEntryArchive(EntryArchive inEntryArchive) {
356:                fieldEntryArchive = inEntryArchive;
357:            }
358:
359:            public Date getLastModified() {
360:                return fieldLastModified;
361:            }
362:
363:            public void setLastModified(Date inLastModified) {
364:                fieldLastModified = inLastModified;
365:            }
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.