Source Code Cross Referenced for WebsiteData.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » pojos » 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 » Blogger System » apache roller 3.1 » org.apache.roller.pojos 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  The ASF licenses this file to You
0004:         * under the Apache License, Version 2.0 (the "License"); you may not
0005:         * use this file except in compliance with the License.
0006:         * You may obtain a copy of the License at
0007:         *
0008:         *     http://www.apache.org/licenses/LICENSE-2.0
0009:         *
0010:         * Unless required by applicable law or agreed to in writing, software
0011:         * distributed under the License is distributed on an "AS IS" BASIS,
0012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013:         * See the License for the specific language governing permissions and
0014:         * limitations under the License.  For additional information regarding
0015:         * copyright in this work, please see the NOTICE file in the top level
0016:         * directory of this distribution.
0017:         */
0018:
0019:        package org.apache.roller.pojos;
0020:
0021:        import java.io.Serializable;
0022:        import java.util.ArrayList;
0023:        import java.util.Calendar;
0024:        import java.util.Collections;
0025:        import java.util.Date;
0026:        import java.util.Iterator;
0027:        import java.util.List;
0028:        import java.util.Locale;
0029:        import java.util.Map;
0030:        import java.util.TimeZone;
0031:        import java.util.TreeMap;
0032:        import org.apache.commons.lang.StringUtils;
0033:        import org.apache.roller.RollerException;
0034:        import org.apache.roller.business.referrers.RefererManager;
0035:        import org.apache.roller.business.RollerFactory;
0036:        import org.apache.roller.util.PojoUtil;
0037:        import org.apache.commons.logging.Log;
0038:        import org.apache.commons.logging.LogFactory;
0039:        import org.apache.roller.business.ThemeNotFoundException;
0040:        import org.apache.roller.config.RollerRuntimeConfig;
0041:        import org.apache.roller.business.BookmarkManager;
0042:        import org.apache.roller.business.PluginManager;
0043:        import org.apache.roller.business.Roller;
0044:        import org.apache.roller.business.ThemeManager;
0045:        import org.apache.roller.business.UserManager;
0046:        import org.apache.roller.business.WeblogManager;
0047:
0048:        /**
0049:         * Website has many-to-many association with users. Website has one-to-many and
0050:         * one-direction associations with weblog entries, weblog categories, folders and
0051:         * other objects. Use UserManager to create, fetch, update and retreive websites.
0052:         *
0053:         * @author David M Johnson
0054:         *
0055:         * @ejb:bean name="WebsiteData"
0056:         * @struts.form include-all="true"
0057:         * @hibernate.class lazy="false"  table="website"
0058:         * @hibernate.cache usage="read-write"
0059:         */
0060:        public class WebsiteData extends
0061:                org.apache.roller.pojos.PersistentObject implements 
0062:                Serializable {
0063:            public static final long serialVersionUID = 206437645033737127L;
0064:
0065:            private static Log log = LogFactory.getLog(WebsiteData.class);
0066:
0067:            // Simple properties
0068:            private String id = null;
0069:            private String handle = null;
0070:            private String name = null;
0071:            private String description = null;
0072:            private String defaultPageId = "dummy";
0073:            private String weblogDayPageId = "dummy";
0074:            private Boolean enableBloggerApi = Boolean.TRUE;
0075:            private String editorPage = null;
0076:            private String blacklist = null;
0077:            private Boolean allowComments = Boolean.TRUE;
0078:            private Boolean emailComments = Boolean.FALSE;
0079:            private String emailFromAddress = null;
0080:            private String emailAddress = null;
0081:            private String editorTheme = null;
0082:            private String locale = null;
0083:            private String timeZone = null;
0084:            private String defaultPlugins = null;
0085:            private Boolean enabled = Boolean.TRUE;
0086:            private Boolean active = Boolean.TRUE;
0087:            private Date dateCreated = new java.util.Date();
0088:            private Boolean defaultAllowComments = Boolean.TRUE;
0089:            private int defaultCommentDays = 0;
0090:            private Boolean moderateComments = Boolean.FALSE;
0091:            private int entryDisplayCount = 15;
0092:            private Date lastModified = new Date();
0093:            private String pageModels = new String();
0094:            private boolean enableMultiLang = false;
0095:            private boolean showAllLangs = true;
0096:
0097:            // Associated objects
0098:            private UserData creator = null;
0099:            private List permissions = new ArrayList();
0100:            private WeblogCategoryData bloggerCategory = null;
0101:            private WeblogCategoryData defaultCategory = null;
0102:
0103:            private Map initializedPlugins = null;
0104:
0105:            public WebsiteData() {
0106:            }
0107:
0108:            public WebsiteData(String handle, UserData creator, String name,
0109:                    String desc, String email, String emailFrom,
0110:                    String editorTheme, String locale, String timeZone) {
0111:
0112:                this .handle = handle;
0113:                this .creator = creator;
0114:                this .name = name;
0115:                this .description = desc;
0116:                this .emailAddress = email;
0117:                this .emailFromAddress = emailFrom;
0118:                this .editorTheme = editorTheme;
0119:                this .locale = locale;
0120:                this .timeZone = timeZone;
0121:            }
0122:
0123:            public WebsiteData(WebsiteData otherData) {
0124:                this .setData(otherData);
0125:            }
0126:
0127:            /**
0128:             * @hibernate.bag lazy="true" inverse="true" cascade="delete"
0129:             * @hibernate.collection-key column="website_id"
0130:             * @hibernate.collection-one-to-many
0131:             *    class="org.apache.roller.pojos.PermissionsData"
0132:             */
0133:            public List getPermissions() {
0134:                return permissions;
0135:            }
0136:
0137:            public void setPermissions(List perms) {
0138:                permissions = perms;
0139:            }
0140:
0141:            /**
0142:             * Remove permission from collection.
0143:             */
0144:            public void removePermission(PermissionsData perms) {
0145:                permissions.remove(perms);
0146:            }
0147:
0148:            /**
0149:             * Lookup the default page for this website.
0150:             */
0151:            public Template getDefaultPage() throws RollerException {
0152:
0153:                Template template = null;
0154:
0155:                // first check if this user has selected a theme
0156:                // if so then return the themes Weblog template
0157:                if (this .editorTheme != null
0158:                        && !this .editorTheme.equals(Theme.CUSTOM)) {
0159:                    try {
0160:                        ThemeManager themeMgr = RollerFactory.getRoller()
0161:                                .getThemeManager();
0162:                        Theme usersTheme = themeMgr.getTheme(this .editorTheme);
0163:
0164:                        // this is a bit iffy :/
0165:                        // we assume that all theme use "Weblog" for a default template
0166:                        template = usersTheme.getTemplate("Weblog");
0167:
0168:                    } catch (ThemeNotFoundException tnfe) {
0169:                        // i sure hope not!
0170:                        log.error(tnfe);
0171:                    }
0172:                }
0173:
0174:                // if we didn't get the Template from a theme then look in the db
0175:                if (template == null) {
0176:                    UserManager userMgr = RollerFactory.getRoller()
0177:                            .getUserManager();
0178:                    template = userMgr.getPage(this .defaultPageId);
0179:                }
0180:
0181:                if (template != null)
0182:                    log.debug("returning default template id ["
0183:                            + template.getId() + "]");
0184:
0185:                return template;
0186:            }
0187:
0188:            /**
0189:             * Lookup a Template for this website by id.
0190:             */
0191:            public Template getPageById(String id) throws RollerException {
0192:
0193:                if (id == null)
0194:                    return null;
0195:
0196:                Template template = null;
0197:
0198:                // first check if this user has selected a theme
0199:                // if so then return the proper theme template
0200:                if (this .editorTheme != null
0201:                        && !this .editorTheme.equals(Theme.CUSTOM)) {
0202:
0203:                    // we don't actually expect to get lookups for theme pages by id
0204:                    // but we have to be thorough and check anyways
0205:                    String[] split = id.split(":", 2);
0206:
0207:                    // only continue if this looks like a theme id
0208:                    // and the theme name matches this users current theme
0209:                    if (split.length == 2 && split[0].equals(this .editorTheme)) {
0210:                        try {
0211:                            ThemeManager themeMgr = RollerFactory.getRoller()
0212:                                    .getThemeManager();
0213:                            Theme usersTheme = themeMgr
0214:                                    .getTheme(this .editorTheme);
0215:                            template = usersTheme.getTemplate(split[1]);
0216:
0217:                        } catch (ThemeNotFoundException tnfe) {
0218:                            // i sure hope not!
0219:                            log.error(tnfe);
0220:                        }
0221:                    }
0222:
0223:                }
0224:
0225:                // if we didn't get the Template from a theme then look in the db
0226:                if (template == null) {
0227:                    UserManager userMgr = RollerFactory.getRoller()
0228:                            .getUserManager();
0229:                    template = userMgr.getPageByName(this , name);
0230:                }
0231:
0232:                return template;
0233:            }
0234:
0235:            /**
0236:             * Lookup a Template for this website by name.
0237:             * @roller.wrapPojoMethod type="pojo"
0238:             */
0239:            public Template getPageByName(String name) throws RollerException {
0240:
0241:                if (name == null)
0242:                    return null;
0243:
0244:                log.debug("looking up template [" + name + "]");
0245:
0246:                Template template = null;
0247:
0248:                // first check if this user has selected a theme
0249:                // if so then return the proper theme template
0250:                if (this .editorTheme != null
0251:                        && !this .editorTheme.equals(Theme.CUSTOM)) {
0252:
0253:                    try {
0254:                        ThemeManager themeMgr = RollerFactory.getRoller()
0255:                                .getThemeManager();
0256:                        Theme usersTheme = themeMgr.getTheme(this .editorTheme);
0257:                        template = usersTheme.getTemplate(name);
0258:
0259:                    } catch (ThemeNotFoundException tnfe) {
0260:                        // i sure hope not!
0261:                        log.error(tnfe);
0262:                    }
0263:
0264:                }
0265:
0266:                // if we didn't get the Template from a theme then look in the db
0267:                if (template == null) {
0268:                    UserManager userMgr = RollerFactory.getRoller()
0269:                            .getUserManager();
0270:                    template = userMgr.getPageByName(this , name);
0271:                }
0272:
0273:                if (template != null)
0274:                    log.debug("returning template [" + template.getId() + "]");
0275:
0276:                return template;
0277:            }
0278:
0279:            /**
0280:             * Lookup a template for this website by link.
0281:             * @roller.wrapPojoMethod type="pojo"
0282:             */
0283:            public Template getPageByLink(String link) throws RollerException {
0284:
0285:                if (link == null)
0286:                    return null;
0287:
0288:                log.debug("looking up template [" + link + "]");
0289:
0290:                Template template = null;
0291:
0292:                // first check if this user has selected a theme
0293:                // if so then return the proper theme template
0294:                if (this .editorTheme != null
0295:                        && !this .editorTheme.equals(Theme.CUSTOM)) {
0296:
0297:                    try {
0298:                        ThemeManager themeMgr = RollerFactory.getRoller()
0299:                                .getThemeManager();
0300:                        Theme usersTheme = themeMgr.getTheme(this .editorTheme);
0301:                        template = usersTheme.getTemplateByLink(link);
0302:
0303:                    } catch (ThemeNotFoundException tnfe) {
0304:                        // i sure hope not!
0305:                        log.error(tnfe);
0306:                    }
0307:
0308:                }
0309:
0310:                // if we didn't get the Template from a theme then look in the db
0311:                if (template == null) {
0312:                    UserManager userMgr = RollerFactory.getRoller()
0313:                            .getUserManager();
0314:                    template = userMgr.getPageByLink(this , link);
0315:                }
0316:
0317:                if (template != null)
0318:                    log.debug("returning template [" + template.getId() + "]");
0319:
0320:                return template;
0321:            }
0322:
0323:            /**
0324:             * Get a list of all pages that are part of this website.
0325:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.Template"
0326:             */
0327:            public List getPages() {
0328:
0329:                Map pages = new TreeMap();
0330:
0331:                // first get the pages from the db
0332:                try {
0333:                    Template template = null;
0334:                    UserManager userMgr = RollerFactory.getRoller()
0335:                            .getUserManager();
0336:                    Iterator dbPages = userMgr.getPages(this ).iterator();
0337:                    while (dbPages.hasNext()) {
0338:                        template = (Template) dbPages.next();
0339:                        pages.put(template.getName(), template);
0340:                    }
0341:                } catch (Exception e) {
0342:                    // db error
0343:                    log.error(e);
0344:                }
0345:
0346:                // now get theme pages if needed and put them in place of db pages
0347:                if (this .editorTheme != null
0348:                        && !this .editorTheme.equals(Theme.CUSTOM)) {
0349:                    try {
0350:                        Template template = null;
0351:                        ThemeManager themeMgr = RollerFactory.getRoller()
0352:                                .getThemeManager();
0353:                        Theme usersTheme = themeMgr.getTheme(this .editorTheme);
0354:                        Iterator themePages = usersTheme.getTemplates()
0355:                                .iterator();
0356:                        while (themePages.hasNext()) {
0357:                            template = (Template) themePages.next();
0358:
0359:                            // note that this will put theme pages over custom
0360:                            // pages in the pages list, which is what we want
0361:                            pages.put(template.getName(), template);
0362:                        }
0363:                    } catch (Exception e) {
0364:                        // how??
0365:                        log.error(e);
0366:                    }
0367:                }
0368:
0369:                return new ArrayList(pages.values());
0370:            }
0371:
0372:            /**
0373:             * Id of the Website.
0374:             *
0375:             * @roller.wrapPojoMethod type="simple"
0376:             * @ejb:persistent-field
0377:             * @hibernate.id column="id"
0378:             *  generator-class="uuid.hex" unsaved-value="null"
0379:             */
0380:            public String getId() {
0381:                return this .id;
0382:            }
0383:
0384:            /** @ejb:persistent-field */
0385:            public void setId(String id) {
0386:                this .id = id;
0387:            }
0388:
0389:            /**
0390:             * Short URL safe string that uniquely identifies the website.
0391:             * @ejb:persistent-field
0392:             * @hibernate.property column="handle" non-null="true" unique="true"
0393:             * @roller.wrapPojoMethod type="simple"
0394:             */
0395:            public String getHandle() {
0396:                return this .handle;
0397:            }
0398:
0399:            /** @ejb:persistent-field */
0400:            public void setHandle(String handle) {
0401:                this .handle = handle;
0402:            }
0403:
0404:            /**
0405:             * Name of the Website.
0406:             *
0407:             * @roller.wrapPojoMethod type="simple"
0408:             * @ejb:persistent-field
0409:             * @hibernate.property column="name" non-null="true" unique="false"
0410:             */
0411:            public String getName() {
0412:                return this .name;
0413:            }
0414:
0415:            /** @ejb:persistent-field */
0416:            public void setName(String name) {
0417:                this .name = name;
0418:            }
0419:
0420:            /**
0421:             * Description
0422:             *
0423:             * @roller.wrapPojoMethod type="simple"
0424:             * @ejb:persistent-field
0425:             * @hibernate.property column="description" non-null="true" unique="false"
0426:             */
0427:            public String getDescription() {
0428:                return this .description;
0429:            }
0430:
0431:            /** @ejb:persistent-field */
0432:            public void setDescription(String description) {
0433:                this .description = description;
0434:            }
0435:
0436:            /**
0437:             * Original creator of website
0438:             *
0439:             * @roller.wrapPojoMethod type="pojo"
0440:             * @ejb:persistent-field
0441:             * @hibernate.many-to-one column="userid" cascade="none" not-null="true"
0442:             */
0443:            public org.apache.roller.pojos.UserData getCreator() {
0444:                return creator;
0445:            }
0446:
0447:            /** @ejb:persistent-field */
0448:            public void setCreator(org.apache.roller.pojos.UserData ud) {
0449:                creator = ud;
0450:            }
0451:
0452:            /**
0453:             * @roller.wrapPojoMethod type="simple"
0454:             * @ejb:persistent-field
0455:             * @hibernate.property column="defaultpageid" non-null="true" unique="false"
0456:             */
0457:            public String getDefaultPageId() {
0458:                return this .defaultPageId;
0459:            }
0460:
0461:            /**
0462:             * @ejb:persistent-field
0463:             */
0464:            public void setDefaultPageId(String defaultPageId) {
0465:                this .defaultPageId = defaultPageId;
0466:            }
0467:
0468:            /**
0469:             * @roller.wrapPojoMethod type="simple"
0470:             * @deprecated
0471:             * @ejb:persistent-field
0472:             * @hibernate.property column="weblogdayid" non-null="true" unique="false"
0473:             */
0474:            public String getWeblogDayPageId() {
0475:                return this .weblogDayPageId;
0476:            }
0477:
0478:            /**
0479:             * @deprecated
0480:             * @ejb:persistent-field
0481:             */
0482:            public void setWeblogDayPageId(String weblogDayPageId) {
0483:                this .weblogDayPageId = weblogDayPageId;
0484:            }
0485:
0486:            /**
0487:             * @roller.wrapPojoMethod type="simple"
0488:             * @ejb:persistent-field
0489:             * @hibernate.property column="enablebloggerapi" non-null="true" unique="false"
0490:             */
0491:            public Boolean getEnableBloggerApi() {
0492:                return this .enableBloggerApi;
0493:            }
0494:
0495:            /** @ejb:persistent-field */
0496:            public void setEnableBloggerApi(Boolean enableBloggerApi) {
0497:                this .enableBloggerApi = enableBloggerApi;
0498:            }
0499:
0500:            /**
0501:             * @roller.wrapPojoMethod type="simple"
0502:             * @ejb:persistent-field
0503:             * @hibernate.many-to-one column="bloggercatid" non-null="false"
0504:             */
0505:            public WeblogCategoryData getBloggerCategory() {
0506:                return bloggerCategory;
0507:            }
0508:
0509:            /** @ejb:persistent-field */
0510:            public void setBloggerCategory(WeblogCategoryData bloggerCategory) {
0511:                this .bloggerCategory = bloggerCategory;
0512:            }
0513:
0514:            /**
0515:             * By default,the default category for a weblog is the root and all macros
0516:             * work with the top level categories that are immediately under the root.
0517:             * Setting a different default category allows you to partition your weblog.
0518:             *
0519:             * @roller.wrapPojoMethod type="pojo"
0520:             * @ejb:persistent-field
0521:             * @hibernate.many-to-one column="defaultcatid" non-null="false"
0522:             */
0523:            public WeblogCategoryData getDefaultCategory() {
0524:                return defaultCategory;
0525:            }
0526:
0527:            /** @ejb:persistent-field */
0528:            public void setDefaultCategory(WeblogCategoryData defaultCategory) {
0529:                this .defaultCategory = defaultCategory;
0530:            }
0531:
0532:            /**
0533:             * @roller.wrapPojoMethod type="simple"
0534:             * @ejb:persistent-field
0535:             * @hibernate.property column="editorpage" non-null="true" unique="false"
0536:             */
0537:            public String getEditorPage() {
0538:                return this .editorPage;
0539:            }
0540:
0541:            /** @ejb:persistent-field */
0542:            public void setEditorPage(String editorPage) {
0543:                this .editorPage = editorPage;
0544:            }
0545:
0546:            /**
0547:             * @roller.wrapPojoMethod type="simple"
0548:             * @ejb:persistent-field
0549:             * @hibernate.property column="blacklist" non-null="true" unique="false"
0550:             */
0551:            public String getBlacklist() {
0552:                return this .blacklist;
0553:            }
0554:
0555:            /** @ejb:persistent-field */
0556:            public void setBlacklist(String blacklist) {
0557:                this .blacklist = blacklist;
0558:            }
0559:
0560:            /**
0561:             * @roller.wrapPojoMethod type="simple"
0562:             * @ejb:persistent-field
0563:             * @hibernate.property column="allowcomments" non-null="true" unique="false"
0564:             */
0565:            public Boolean getAllowComments() {
0566:                return this .allowComments;
0567:            }
0568:
0569:            /** @ejb:persistent-field */
0570:            public void setAllowComments(Boolean allowComments) {
0571:                this .allowComments = allowComments;
0572:            }
0573:
0574:            /**
0575:             * @roller.wrapPojoMethod type="simple"
0576:             * @ejb:persistent-field
0577:             * @hibernate.property column="defaultallowcomments" non-null="true" unique="false"
0578:             */
0579:            public Boolean getDefaultAllowComments() {
0580:                return defaultAllowComments;
0581:            }
0582:
0583:            /** @ejb:persistent-field */
0584:            public void setDefaultAllowComments(Boolean defaultAllowComments) {
0585:                this .defaultAllowComments = defaultAllowComments;
0586:            }
0587:
0588:            /**
0589:             * @roller.wrapPojoMethod type="simple"
0590:             * @ejb:persistent-field
0591:             * @hibernate.property column="defaultcommentdays" non-null="true" unique="false"
0592:             */
0593:            public int getDefaultCommentDays() {
0594:                return defaultCommentDays;
0595:            }
0596:
0597:            /** @ejb:persistent-field */
0598:            public void setDefaultCommentDays(int defaultCommentDays) {
0599:                this .defaultCommentDays = defaultCommentDays;
0600:            }
0601:
0602:            /**
0603:             * @roller.wrapPojoMethod type="simple"
0604:             * @ejb:persistent-field
0605:             * @hibernate.property column="commentmod" non-null="true" unique="false"
0606:             */
0607:            public Boolean getModerateComments() {
0608:                return moderateComments;
0609:            }
0610:
0611:            /** @ejb:persistent-field */
0612:            public void setModerateComments(Boolean moderateComments) {
0613:                this .moderateComments = moderateComments;
0614:            }
0615:
0616:            /**
0617:             * @roller.wrapPojoMethod type="simple"
0618:             * @ejb:persistent-field
0619:             * @hibernate.property column="emailcomments" non-null="true" unique="false"
0620:             */
0621:            public Boolean getEmailComments() {
0622:                return this .emailComments;
0623:            }
0624:
0625:            /** @ejb:persistent-field */
0626:            public void setEmailComments(Boolean emailComments) {
0627:                this .emailComments = emailComments;
0628:            }
0629:
0630:            /**
0631:             * @roller.wrapPojoMethod type="simple"
0632:             * @ejb:persistent-field
0633:             * @hibernate.property column="emailfromaddress" non-null="true" unique="false"
0634:             */
0635:            public String getEmailFromAddress() {
0636:                return this .emailFromAddress;
0637:            }
0638:
0639:            /** @ejb:persistent-field */
0640:            public void setEmailFromAddress(String emailFromAddress) {
0641:                this .emailFromAddress = emailFromAddress;
0642:            }
0643:
0644:            /**
0645:             * @ejb:persistent-field
0646:             * @roller.wrapPojoMethod type="simple"
0647:             * @hibernate.property column="emailaddress" non-null="true" unique="false"
0648:             */
0649:            public String getEmailAddress() {
0650:                return this .emailAddress;
0651:            }
0652:
0653:            /** @ejb:persistent-field */
0654:            public void setEmailAddress(String emailAddress) {
0655:                this .emailAddress = emailAddress;
0656:            }
0657:
0658:            /**
0659:             * EditorTheme of the Website.
0660:             *
0661:             * @roller.wrapPojoMethod type="simple"
0662:             * @ejb:persistent-field
0663:             * @hibernate.property column="editortheme" non-null="true" unique="false"
0664:             */
0665:            public String getEditorTheme() {
0666:                return this .editorTheme;
0667:            }
0668:
0669:            /** @ejb:persistent-field */
0670:            public void setEditorTheme(String editorTheme) {
0671:                this .editorTheme = editorTheme;
0672:            }
0673:
0674:            /**
0675:             * Locale of the Website.
0676:             *
0677:             * @roller.wrapPojoMethod type="simple"
0678:             * @ejb:persistent-field
0679:             * @hibernate.property column="locale" non-null="true" unique="false"
0680:             */
0681:            public String getLocale() {
0682:                return this .locale;
0683:            }
0684:
0685:            /** @ejb:persistent-field */
0686:            public void setLocale(String locale) {
0687:                this .locale = locale;
0688:            }
0689:
0690:            /**
0691:             * Timezone of the Website.
0692:             *
0693:             * @roller.wrapPojoMethod type="simple"
0694:             * @ejb:persistent-field
0695:             * @hibernate.property column="timeZone" non-null="true" unique="false"
0696:             */
0697:            public String getTimeZone() {
0698:                return this .timeZone;
0699:            }
0700:
0701:            /** @ejb:persistent-field */
0702:            public void setTimeZone(String timeZone) {
0703:                this .timeZone = timeZone;
0704:            }
0705:
0706:            /**
0707:             * @ejb:persistent-field
0708:             * @hibernate.property column="datecreated" non-null="true" unique="false"
0709:             * @roller.wrapPojoMethod type="simple"
0710:             */
0711:            public Date getDateCreated() {
0712:                if (dateCreated == null) {
0713:                    return null;
0714:                } else {
0715:                    return (Date) dateCreated.clone();
0716:                }
0717:            }
0718:
0719:            /** @ejb:persistent-field */
0720:            public void setDateCreated(final Date date) {
0721:                if (date != null) {
0722:                    dateCreated = (Date) date.clone();
0723:                } else {
0724:                    dateCreated = null;
0725:                }
0726:            }
0727:
0728:            /**
0729:             * Comma-delimited list of user's default Plugins.
0730:             *
0731:             * @roller.wrapPojoMethod type="simple"
0732:             * @ejb:persistent-field
0733:             * @hibernate.property column="defaultplugins" non-null="false" unique="false"
0734:             */
0735:            public String getDefaultPlugins() {
0736:                return defaultPlugins;
0737:            }
0738:
0739:            /** @ejb:persistent-field */
0740:            public void setDefaultPlugins(String string) {
0741:                defaultPlugins = string;
0742:            }
0743:
0744:            public String toString() {
0745:                StringBuffer str = new StringBuffer("{");
0746:
0747:                str.append("id=" + id + " " + "name=" + name + " "
0748:                        + "description=" + description + " " + "defaultPageId="
0749:                        + defaultPageId + " " + "weblogDayPageId="
0750:                        + weblogDayPageId + " " + "enableBloggerApi="
0751:                        + enableBloggerApi + " " + "bloggerCategory="
0752:                        + bloggerCategory + " " + "defaultCategory="
0753:                        + defaultCategory + " " + "editorPage=" + editorPage
0754:                        + " " + "blacklist=" + blacklist + " "
0755:                        + "allowComments=" + allowComments + " "
0756:                        + "emailAddress=" + emailAddress + " "
0757:                        + "emailComments=" + emailComments + " "
0758:                        + "emailFromAddress=" + emailFromAddress + " "
0759:                        + "editorTheme=" + editorTheme + " " + "locale="
0760:                        + locale + " " + "timeZone=" + timeZone + " "
0761:                        + "defaultPlugins=" + defaultPlugins);
0762:                str.append('}');
0763:
0764:                return (str.toString());
0765:            }
0766:
0767:            public boolean equals(Object pOther) {
0768:                if (pOther instanceof  WebsiteData) {
0769:                    WebsiteData lTest = (WebsiteData) pOther;
0770:                    boolean lEquals = true;
0771:                    lEquals = PojoUtil.equals(lEquals, this .getId(), lTest
0772:                            .getId());
0773:                    lEquals = PojoUtil.equals(lEquals, this .getName(), lTest
0774:                            .getName());
0775:                    lEquals = PojoUtil.equals(lEquals, this .getDescription(),
0776:                            lTest.getDescription());
0777:                    lEquals = PojoUtil.equals(lEquals, this .getCreator(), lTest
0778:                            .getCreator());
0779:                    lEquals = PojoUtil.equals(lEquals, this .getDefaultPageId(),
0780:                            lTest.getDefaultPageId());
0781:                    lEquals = PojoUtil.equals(lEquals, this 
0782:                            .getWeblogDayPageId(), lTest.getWeblogDayPageId());
0783:                    lEquals = PojoUtil
0784:                            .equals(lEquals, this .getEnableBloggerApi(), lTest
0785:                                    .getEnableBloggerApi());
0786:                    lEquals = PojoUtil.equals(lEquals, this 
0787:                            .getBloggerCategory(), lTest.getBloggerCategory());
0788:                    lEquals = PojoUtil.equals(lEquals, this 
0789:                            .getDefaultCategory(), lTest.getDefaultCategory());
0790:                    lEquals = PojoUtil.equals(lEquals, this .getEditorPage(),
0791:                            lTest.getEditorPage());
0792:                    lEquals = PojoUtil.equals(lEquals, this .getBlacklist(),
0793:                            lTest.getBlacklist());
0794:                    lEquals = PojoUtil.equals(lEquals, this .getAllowComments(),
0795:                            lTest.getAllowComments());
0796:                    lEquals = PojoUtil.equals(lEquals, this .getEmailComments(),
0797:                            lTest.getEmailComments());
0798:                    lEquals = PojoUtil.equals(lEquals, this .getEmailAddress(),
0799:                            lTest.getEmailAddress());
0800:                    lEquals = PojoUtil
0801:                            .equals(lEquals, this .getEmailFromAddress(), lTest
0802:                                    .getEmailFromAddress());
0803:                    lEquals = PojoUtil.equals(lEquals, this .getEditorTheme(),
0804:                            lTest.getEditorTheme());
0805:                    lEquals = PojoUtil.equals(lEquals, this .getLocale(), lTest
0806:                            .getLocale());
0807:                    lEquals = PojoUtil.equals(lEquals, this .getTimeZone(),
0808:                            lTest.getTimeZone());
0809:                    lEquals = PojoUtil
0810:                            .equals(lEquals, this .getDefaultPlugins(), lTest
0811:                                    .getDefaultPlugins());
0812:                    return lEquals;
0813:                } else {
0814:                    return false;
0815:                }
0816:            }
0817:
0818:            public int hashCode() {
0819:                int result = 17;
0820:                result = PojoUtil.addHashCode(result, this .id);
0821:                result = PojoUtil.addHashCode(result, this .name);
0822:                result = PojoUtil.addHashCode(result, this .description);
0823:                result = PojoUtil.addHashCode(result, this .creator);
0824:                result = PojoUtil.addHashCode(result, this .defaultPageId);
0825:                result = PojoUtil.addHashCode(result, this .weblogDayPageId);
0826:                result = PojoUtil.addHashCode(result, this .enableBloggerApi);
0827:                //result = PojoUtil.addHashCode(result, this.bloggerCategory);
0828:                //result = PojoUtil.addHashCode(result, this.defaultCategory);
0829:                result = PojoUtil.addHashCode(result, this .editorPage);
0830:                result = PojoUtil.addHashCode(result, this .blacklist);
0831:                result = PojoUtil.addHashCode(result, this .allowComments);
0832:                result = PojoUtil.addHashCode(result, this .emailComments);
0833:                result = PojoUtil.addHashCode(result, this .emailAddress);
0834:                result = PojoUtil.addHashCode(result, this .emailFromAddress);
0835:                result = PojoUtil.addHashCode(result, this .editorTheme);
0836:                result = PojoUtil.addHashCode(result, this .locale);
0837:                result = PojoUtil.addHashCode(result, this .timeZone);
0838:                result = PojoUtil.addHashCode(result, this .defaultPlugins);
0839:
0840:                return result;
0841:            }
0842:
0843:            /**
0844:             * Setter is needed in RollerImpl.storePersistentObject()
0845:             */
0846:            public void setData(
0847:                    org.apache.roller.pojos.PersistentObject otherData) {
0848:                WebsiteData other = (WebsiteData) otherData;
0849:
0850:                this .id = other.getId();
0851:                this .name = other.getName();
0852:                this .handle = other.getHandle();
0853:                this .description = other.getDescription();
0854:                this .creator = other.getCreator();
0855:                this .defaultPageId = other.getDefaultPageId();
0856:                this .weblogDayPageId = other.getWeblogDayPageId();
0857:                this .enableBloggerApi = other.getEnableBloggerApi();
0858:                this .bloggerCategory = other.getBloggerCategory();
0859:                this .defaultCategory = other.getDefaultCategory();
0860:                this .editorPage = other.getEditorPage();
0861:                this .blacklist = other.getBlacklist();
0862:                this .allowComments = other.getAllowComments();
0863:                this .emailComments = other.getEmailComments();
0864:                this .emailAddress = other.getEmailAddress();
0865:                this .emailFromAddress = other.getEmailFromAddress();
0866:                this .editorTheme = other.getEditorTheme();
0867:                this .locale = other.getLocale();
0868:                this .timeZone = other.getTimeZone();
0869:                this .defaultPlugins = other.getDefaultPlugins();
0870:                this .enabled = other.getEnabled();
0871:                this .dateCreated = other.getDateCreated();
0872:                this .entryDisplayCount = other.getEntryDisplayCount();
0873:                this .active = other.getActive();
0874:                this .lastModified = other.getLastModified();
0875:            }
0876:
0877:            /**
0878:             * Parse locale value and instantiate a Locale object,
0879:             * otherwise return default Locale.
0880:             *
0881:             * @roller.wrapPojoMethod type="simple"
0882:             * @return Locale
0883:             */
0884:            public Locale getLocaleInstance() {
0885:                if (locale != null) {
0886:                    String[] localeStr = StringUtils.split(locale, "_");
0887:                    if (localeStr.length == 1) {
0888:                        if (localeStr[0] == null)
0889:                            localeStr[0] = "";
0890:                        return new Locale(localeStr[0]);
0891:                    } else if (localeStr.length == 2) {
0892:                        if (localeStr[0] == null)
0893:                            localeStr[0] = "";
0894:                        if (localeStr[1] == null)
0895:                            localeStr[1] = "";
0896:                        return new Locale(localeStr[0], localeStr[1]);
0897:                    } else if (localeStr.length == 3) {
0898:                        if (localeStr[0] == null)
0899:                            localeStr[0] = "";
0900:                        if (localeStr[1] == null)
0901:                            localeStr[1] = "";
0902:                        if (localeStr[2] == null)
0903:                            localeStr[2] = "";
0904:                        return new Locale(localeStr[0], localeStr[1],
0905:                                localeStr[2]);
0906:                    }
0907:                }
0908:                return Locale.getDefault();
0909:            }
0910:
0911:            /**
0912:             * Return TimeZone instance for value of timeZone,
0913:             * otherwise return system default instance.
0914:             *
0915:             * @roller.wrapPojoMethod type="simple"
0916:             * @return TimeZone
0917:             */
0918:            public TimeZone getTimeZoneInstance() {
0919:                if (timeZone == null) {
0920:                    if (TimeZone.getDefault() != null) {
0921:                        this .setTimeZone(TimeZone.getDefault().getID());
0922:                    } else {
0923:                        this .setTimeZone("America/New_York");
0924:                    }
0925:                }
0926:                return TimeZone.getTimeZone(timeZone);
0927:            }
0928:
0929:            /**
0930:             * Returns true if user has all permissions specified by mask.
0931:             */
0932:            public boolean hasUserPermissions(UserData user, short mask) {
0933:                // look for user in website's permissions
0934:                PermissionsData userPerms = null;
0935:                Iterator iter = getPermissions().iterator();
0936:                while (iter.hasNext()) {
0937:                    PermissionsData perms = (PermissionsData) iter.next();
0938:                    if (perms.getUser().getId().equals(user.getId())) {
0939:                        userPerms = perms;
0940:                        break;
0941:                    }
0942:                }
0943:                // if we found one, does it satisfy the mask?
0944:                if (userPerms != null && !userPerms.isPending()) {
0945:                    if (userPerms != null
0946:                            && (userPerms.getPermissionMask() & mask) == mask) {
0947:                        return true;
0948:                    }
0949:                }
0950:                // otherwise, check to see if user is a global admin
0951:                if (user != null && user.hasRole("admin"))
0952:                    return true;
0953:                return false;
0954:            }
0955:
0956:            /** Get number of users associated with website */
0957:            public int getUserCount() {
0958:                return getPermissions().size();
0959:            }
0960:
0961:            /** No-op needed to please XDoclet generated code */
0962:            private int userCount = 0;
0963:
0964:            public void setUserCount(int userCount) {
0965:                // no-op
0966:            }
0967:
0968:            public int getAdminUserCount() {
0969:                int count = 0;
0970:                PermissionsData userPerms = null;
0971:                Iterator iter = getPermissions().iterator();
0972:                while (iter.hasNext()) {
0973:                    PermissionsData perms = (PermissionsData) iter.next();
0974:                    if (perms.getPermissionMask() == PermissionsData.ADMIN) {
0975:                        count++;
0976:                    }
0977:                }
0978:                return count;
0979:            }
0980:
0981:            /** No-op needed to please XDoclet generated code */
0982:            private int adminUserCount = 0;
0983:
0984:            public void setAdminUserCount(int adminUserCount) {
0985:                // no-op
0986:            }
0987:
0988:            /**
0989:             * @roller.wrapPojoMethod type="simple"
0990:             * @ejb:persistent-field
0991:             * @hibernate.property column="displaycnt" not-null="true"
0992:             */
0993:            public int getEntryDisplayCount() {
0994:                return entryDisplayCount;
0995:            }
0996:
0997:            /**
0998:             * @ejb:persistent-field
0999:             */
1000:            public void setEntryDisplayCount(int entryDisplayCount) {
1001:                this .entryDisplayCount = entryDisplayCount;
1002:            }
1003:
1004:            /**
1005:             * Set to FALSE to completely disable and hide this weblog from public view.
1006:             *
1007:             * @roller.wrapPojoMethod type="simple"
1008:             * @ejb:persistent-field
1009:             * @hibernate.property column="isenabled" non-null="true" unique="false"
1010:             */
1011:            public Boolean getEnabled() {
1012:                return this .enabled;
1013:            }
1014:
1015:            /** @ejb:persistent-field */
1016:            public void setEnabled(Boolean enabled) {
1017:                this .enabled = enabled;
1018:            }
1019:
1020:            /**
1021:             * Set to FALSE to exclude this weblog from community areas such as the
1022:             * front page and the planet page.
1023:             *
1024:             * @roller.wrapPojoMethod type="simple"
1025:             * @ejb:persistent-field
1026:             * @hibernate.property column="isactive" not-null="true"
1027:             */
1028:            public Boolean getActive() {
1029:                return active;
1030:            }
1031:
1032:            public void setActive(Boolean active) {
1033:                this .active = active;
1034:            }
1035:
1036:            /**
1037:             * Returns true if comment moderation is required by website or config.
1038:             */
1039:            public boolean getCommentModerationRequired() {
1040:                return (getModerateComments().booleanValue() || RollerRuntimeConfig
1041:                        .getBooleanProperty("users.moderation.required"));
1042:            }
1043:
1044:            /** No-op */
1045:            public void setCommentModerationRequired(boolean modRequired) {
1046:            }
1047:
1048:            /**
1049:             * The last time any visible part of this weblog was modified.
1050:             * This includes a change to weblog settings, entries, themes, templates, 
1051:             * comments, categories, bookmarks, folders, etc.
1052:             *
1053:             * Pings and Referrers are explicitly not included because pings to not
1054:             * affect visible changes to a weblog, and referrers change so often that
1055:             * it would diminish the usefulness of the attribute.
1056:             *
1057:             * @roller.wrapPojoMethod type="simple"
1058:             * @ejb:persistent-field
1059:             * @hibernate.property column="lastmodified" not-null="true"
1060:             */
1061:            public Date getLastModified() {
1062:                return lastModified;
1063:            }
1064:
1065:            public void setLastModified(Date lastModified) {
1066:                this .lastModified = lastModified;
1067:            }
1068:
1069:            /**
1070:             * Is multi-language blog support enabled for this weblog?
1071:             *
1072:             * If false then urls with various locale restrictions should fail.
1073:             *
1074:             * @roller.wrapPojoMethod type="simple"
1075:             * @ejb:persistent-field
1076:             * @hibernate.property column="enablemultilang" not-null="true"
1077:             */
1078:            public boolean isEnableMultiLang() {
1079:                return enableMultiLang;
1080:            }
1081:
1082:            public void setEnableMultiLang(boolean enableMultiLang) {
1083:                this .enableMultiLang = enableMultiLang;
1084:            }
1085:
1086:            /**
1087:             * Should the default weblog view show entries from all languages?
1088:             *
1089:             * If false then the default weblog view only shows entry from the
1090:             * default locale chosen for this weblog.
1091:             *
1092:             * @roller.wrapPojoMethod type="simple"
1093:             * @ejb:persistent-field
1094:             * @hibernate.property column="showalllangs" not-null="true"
1095:             */
1096:            public boolean isShowAllLangs() {
1097:                return showAllLangs;
1098:            }
1099:
1100:            public void setShowAllLangs(boolean showAllLangs) {
1101:                this .showAllLangs = showAllLangs;
1102:            }
1103:
1104:            /** 
1105:             * @roller.wrapPojoMethod type="simple"
1106:             */
1107:            public String getURL() {
1108:                // TODO: ATLAS reconcile entry.getPermaLink() with new URLs
1109:                String relPath = RollerRuntimeConfig.getRelativeContextURL();
1110:                return relPath + "/" + getHandle();
1111:                //return URLUtilities.getWeblogURL(this, null, false);
1112:            }
1113:
1114:            public void setURL(String url) {
1115:                // noop
1116:            }
1117:
1118:            /** 
1119:             * @roller.wrapPojoMethod type="simple"
1120:             */
1121:            public String getAbsoluteURL() {
1122:                // TODO: ATLAS reconcile entry.getPermaLink() with new URLs
1123:                String relPath = RollerRuntimeConfig.getAbsoluteContextURL();
1124:                return relPath + "/" + getHandle();
1125:                //return URLUtilities.getWeblogURL(this, null, true);
1126:            }
1127:
1128:            public void setAbsoluteURL(String url) {
1129:                // noop
1130:            }
1131:
1132:            /**
1133:             * Comma-separated list of additional page models to be created when this
1134:             * weblog is rendered.
1135:             *
1136:             * @ejb:persistent-field
1137:             * @hibernate.property column="pagemodels" not-null="false"
1138:             */
1139:            public String getPageModels() {
1140:                return pageModels;
1141:            }
1142:
1143:            public void setPageModels(String pageModels) {
1144:                this .pageModels = pageModels;
1145:            }
1146:
1147:            /**
1148:             * Get initialized plugins for use during rendering process.
1149:             */
1150:            public Map getInitializedPlugins() {
1151:                if (initializedPlugins == null) {
1152:                    try {
1153:                        Roller roller = RollerFactory.getRoller();
1154:                        PluginManager ppmgr = roller.getPagePluginManager();
1155:                        initializedPlugins = ppmgr.getWeblogEntryPlugins(this );
1156:                    } catch (Exception e) {
1157:                        this .log.error("ERROR: initializing plugins");
1158:                    }
1159:                }
1160:                return initializedPlugins;
1161:            }
1162:
1163:            /**
1164:             * Returns categories under the default category of the weblog.
1165:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.WeblogCategoryData"
1166:             */
1167:            public List getWeblogCategories() {
1168:                List ret = new ArrayList();
1169:                try {
1170:                    WeblogCategoryData category = this .getDefaultCategory();
1171:                    ret = category.getWeblogCategories();
1172:                } catch (RollerException e) {
1173:                    log.error("ERROR: fetching categories", e);
1174:                }
1175:                return ret;
1176:            }
1177:
1178:            /**
1179:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.WeblogCategoryData"
1180:             */
1181:            public List getWeblogCategories(String categoryPath) {
1182:                List ret = new ArrayList();
1183:                try {
1184:                    Roller roller = RollerFactory.getRoller();
1185:                    WeblogManager wmgr = roller.getWeblogManager();
1186:                    WeblogCategoryData category = null;
1187:                    if (categoryPath != null && !categoryPath.equals("nil")) {
1188:                        category = wmgr.getWeblogCategoryByPath(this , null,
1189:                                categoryPath);
1190:                    } else {
1191:                        category = this .getDefaultCategory();
1192:                    }
1193:                    ret = category.getWeblogCategories();
1194:                } catch (RollerException e) {
1195:                    log.error("ERROR: fetching categories for path: "
1196:                            + categoryPath, e);
1197:                }
1198:                return ret;
1199:            }
1200:
1201:            /**
1202:             * @roller.wrapPojoMethod type="pojo" class="org.apache.roller.pojos.WeblogCategoryData"
1203:             */
1204:            public WeblogCategoryData getWeblogCategory(String categoryPath) {
1205:                WeblogCategoryData category = null;
1206:                try {
1207:                    Roller roller = RollerFactory.getRoller();
1208:                    WeblogManager wmgr = roller.getWeblogManager();
1209:                    if (categoryPath != null && !categoryPath.equals("nil")) {
1210:                        category = wmgr.getWeblogCategoryByPath(this , null,
1211:                                categoryPath);
1212:                    } else {
1213:                        category = this .getDefaultCategory();
1214:                    }
1215:                } catch (RollerException e) {
1216:                    log.error("ERROR: fetching category at path: "
1217:                            + categoryPath, e);
1218:                }
1219:                return category;
1220:            }
1221:
1222:            /**
1223:             * Get up to 100 most recent published entries in weblog.
1224:             * @param cat Category path or null for no category restriction
1225:             * @param length Max entries to return (1-100)
1226:             * @return List of weblog entry objects.
1227:             *
1228:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.WeblogEntryData"
1229:             */
1230:            public List getRecentWeblogEntries(String cat, int length) {
1231:                if (cat != null && "nil".equals(cat))
1232:                    cat = null;
1233:                if (length > 100)
1234:                    length = 100;
1235:                List recentEntries = new ArrayList();
1236:                if (length < 1)
1237:                    return recentEntries;
1238:                try {
1239:                    WeblogManager wmgr = RollerFactory.getRoller()
1240:                            .getWeblogManager();
1241:                    recentEntries = wmgr.getWeblogEntries(this , null, // user
1242:                            null, // startDate
1243:                            new Date(), // endDate
1244:                            cat, // cat or null
1245:                            null, WeblogEntryData.PUBLISHED, "pubTime", // sortby
1246:                            null, 0, length);
1247:                } catch (RollerException e) {
1248:                    log.error("ERROR: getting recent entries", e);
1249:                }
1250:                return recentEntries;
1251:            }
1252:
1253:            /**
1254:             * Get up to 100 most recent approved and non-spam comments in weblog.
1255:             * @param length Max entries to return (1-100)
1256:             * @return List of comment objects.
1257:             *
1258:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.CommentData"
1259:             */
1260:            public List getRecentComments(int length) {
1261:                if (length > 100)
1262:                    length = 100;
1263:                List recentComments = new ArrayList();
1264:                if (length < 1)
1265:                    return recentComments;
1266:                try {
1267:                    WeblogManager wmgr = RollerFactory.getRoller()
1268:                            .getWeblogManager();
1269:                    recentComments = wmgr.getComments(this , null, // weblog entry
1270:                            null, // search String
1271:                            null, // startDate
1272:                            null, // endDate
1273:                            null, // pending
1274:                            Boolean.TRUE, // approved only
1275:                            Boolean.FALSE, // no spam
1276:                            true, // we want reverse chrono order
1277:                            0, // offset
1278:                            length); // length
1279:                } catch (RollerException e) {
1280:                    log.error("ERROR: getting recent comments", e);
1281:                }
1282:                return recentComments;
1283:            }
1284:
1285:            /**
1286:             * Get bookmark folder by name.
1287:             * @param folderName Name or path of bookmark folder to be returned (null for root)
1288:             * @return Folder object requested.
1289:             *
1290:             * @roller.wrapPojoMethod type="pojo" class="org.apache.roller.pojos.FolderData"
1291:             */
1292:            public FolderData getBookmarkFolder(String folderName) {
1293:                FolderData ret = null;
1294:                try {
1295:                    Roller roller = RollerFactory.getRoller();
1296:                    BookmarkManager bmgr = roller.getBookmarkManager();
1297:                    if (folderName == null || folderName.equals("nil")
1298:                            || folderName.trim().equals("/")) {
1299:                        return bmgr.getRootFolder(this );
1300:                    } else {
1301:                        return bmgr.getFolder(this , folderName);
1302:                    }
1303:                } catch (RollerException re) {
1304:                    log.error("ERROR: fetching folder for weblog", re);
1305:                }
1306:                return ret;
1307:            }
1308:
1309:            /** 
1310:             * Return collection of referrers for current day.
1311:             * @roller.wrapPojoMethod type="pojo-collection" class="org.apache.roller.pojos.RefererData"
1312:             */
1313:            public List getTodaysReferrers() {
1314:                List referers = null;
1315:                try {
1316:                    Roller roller = RollerFactory.getRoller();
1317:                    RefererManager rmgr = roller.getRefererManager();
1318:                    return rmgr.getTodaysReferers(this );
1319:
1320:                } catch (RollerException e) {
1321:                    log.error("PageModel getTodaysReferers()", e);
1322:                }
1323:                return (referers == null ? Collections.EMPTY_LIST : referers);
1324:            }
1325:
1326:            /** No-op method to please XDoclet */
1327:            public void setTodaysReferrers(List ignored) {
1328:            }
1329:
1330:            /**
1331:             * Get number of hits counted today.
1332:             * @roller.wrapPojoMethod type="simple"
1333:             */
1334:            public int getTodaysHits() {
1335:                try {
1336:                    Roller roller = RollerFactory.getRoller();
1337:                    WeblogManager mgr = roller.getWeblogManager();
1338:                    HitCountData hitCount = mgr.getHitCountByWeblog(this );
1339:
1340:                    return (hitCount != null) ? hitCount.getDailyHits() : 0;
1341:
1342:                } catch (RollerException e) {
1343:                    log.error("PageModel getTotalHits()", e);
1344:                }
1345:                return 0;
1346:            }
1347:
1348:            /**
1349:             * Get a list of TagStats objects for the most popular tags
1350:             *
1351:             * @param sinceDays Number of days into past (or -1 for all days)
1352:             * @param length    Max number of tags to return.
1353:             * @return          Collection of WeblogEntryTag objects
1354:             *
1355:             * @roller.wrapPojoMethod type="simple"
1356:             */
1357:            public List getPopularTags(int sinceDays, int length) {
1358:                List results = new ArrayList();
1359:                Date startDate = null;
1360:                if (sinceDays > 0) {
1361:                    Calendar cal = Calendar.getInstance();
1362:                    cal.setTime(new Date());
1363:                    cal.add(Calendar.DATE, -1 * sinceDays);
1364:                    startDate = cal.getTime();
1365:                }
1366:                try {
1367:                    Roller roller = RollerFactory.getRoller();
1368:                    WeblogManager wmgr = roller.getWeblogManager();
1369:                    results = wmgr.getPopularTags(this , startDate, length);
1370:                } catch (Exception e) {
1371:                    log.error("ERROR: fetching weblog tags list", e);
1372:                }
1373:                return results;
1374:            }
1375:
1376:            /** No-op method to please XDoclet */
1377:            public void setTodaysHits(int ignored) {
1378:            }
1379:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.