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


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:
019:        package org.apache.roller.ui.rendering.util;
020:
021:        import java.util.ArrayList;
022:        import java.util.Arrays;
023:        import java.util.List;
024:
025:        import javax.servlet.http.HttpServletRequest;
026:
027:        import org.apache.commons.lang.StringUtils;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:        import org.apache.roller.RollerException;
031:        import org.apache.roller.config.RollerConfig;
032:        import org.apache.roller.business.RollerFactory;
033:        import org.apache.roller.business.WeblogManager;
034:        import org.apache.roller.pojos.WeblogCategoryData;
035:        import org.apache.roller.util.URLUtilities;
036:        import org.apache.roller.util.Utilities;
037:
038:        /**
039:         * Represents a request for a Roller weblog feed.
040:         * 
041:         * /roller-ui/rendering/feeds/*
042:         *
043:         * We use this class as a helper to parse an incoming url and sort out the
044:         * information embedded in the url for later use.
045:         */
046:        public class WeblogFeedRequest extends WeblogRequest {
047:
048:            private static Log log = LogFactory.getLog(WeblogFeedRequest.class);
049:
050:            private static final String FEED_SERVLET = "/roller-ui/rendering/feed";
051:
052:            // lightweight attributes
053:            private String type = null;
054:            private String format = null;
055:            private String weblogCategoryName = null;
056:            private List tags = null;
057:            private boolean excerpts = false;
058:
059:            // heavyweight attributes
060:            private WeblogCategoryData weblogCategory = null;
061:
062:            public WeblogFeedRequest() {
063:            }
064:
065:            /**
066:             * Construct the WeblogFeedRequest by parsing the incoming url
067:             */
068:            public WeblogFeedRequest(HttpServletRequest request)
069:                    throws InvalidRequestException {
070:
071:                // let our parent take care of their business first
072:                // parent determines weblog handle and locale if specified
073:                super (request);
074:
075:                String servlet = request.getServletPath();
076:
077:                // we only want the path info left over from after our parents parsing
078:                String pathInfo = this .getPathInfo();
079:
080:                // parse the request object and figure out what we've got
081:                log.debug("parsing path " + pathInfo);
082:
083:                // was this request bound for the feed servlet?
084:                if (servlet == null || !FEED_SERVLET.equals(servlet)) {
085:                    throw new InvalidRequestException(
086:                            "not a weblog feed request, "
087:                                    + request.getRequestURL());
088:                }
089:
090:                /* 
091:                 * parse the path info.
092:                 * 
093:                 * must look like this ...
094:                 *
095:                 * /<type>/<format>
096:                 */
097:                if (pathInfo != null && pathInfo.trim().length() > 1) {
098:
099:                    String[] pathElements = pathInfo.split("/");
100:                    if (pathElements.length == 2) {
101:                        this .type = pathElements[0];
102:                        this .format = pathElements[1];
103:                    } else {
104:                        throw new InvalidRequestException(
105:                                "invalid feed path info, "
106:                                        + request.getRequestURL());
107:                    }
108:
109:                } else {
110:                    throw new InvalidRequestException(
111:                            "invalid feed path info, "
112:                                    + request.getRequestURL());
113:                }
114:
115:                /* 
116:                 * parse request parameters
117:                 *
118:                 * the only params we currently care about are:
119:                 *   cat - specifies a weblog category
120:                 *   excerpts - specifies the feed should only include excerpts
121:                 *
122:                 */
123:                if (request.getParameter("cat") != null) {
124:                    this .weblogCategoryName = URLUtilities.decode(request
125:                            .getParameter("cat"));
126:
127:                    // all categories must start with a /
128:                    if (!this .weblogCategoryName.startsWith("/")) {
129:                        this .weblogCategoryName = "/" + this .weblogCategoryName;
130:                    }
131:                }
132:
133:                if (request.getParameter("tags") != null) {
134:                    this .tags = Utilities.splitStringAsTags(request
135:                            .getParameter("tags"));
136:                    int maxSize = RollerConfig.getIntProperty(
137:                            "tags.queries.maxIntersectionSize", 3);
138:                    if (this .tags.size() > maxSize)
139:                        throw new InvalidRequestException(
140:                                "max number of tags allowed is " + maxSize
141:                                        + ", " + request.getRequestURL());
142:                }
143:
144:                if (request.getParameter("excerpts") != null) {
145:                    this .excerpts = Boolean.valueOf(
146:                            request.getParameter("excerpts")).booleanValue();
147:                }
148:
149:                if ((this .tags != null && this .tags.size() > 0)
150:                        && this .weblogCategoryName != null) {
151:                    throw new InvalidRequestException(
152:                            "please specify either category or tags but not both, "
153:                                    + request.getRequestURL());
154:                }
155:
156:                if (log.isDebugEnabled()) {
157:                    log.debug("type = " + this .type);
158:                    log.debug("format = " + this .format);
159:                    log.debug("weblogCategory = " + this .weblogCategoryName);
160:                    log.debug("tags = " + this .tags);
161:                    log.debug("excerpts = " + this .excerpts);
162:                }
163:            }
164:
165:            public String getType() {
166:                return type;
167:            }
168:
169:            public void setType(String type) {
170:                this .type = type;
171:            }
172:
173:            public String getFormat() {
174:                return format;
175:            }
176:
177:            public void setFormat(String format) {
178:                this .format = format;
179:            }
180:
181:            public String getWeblogCategoryName() {
182:                return weblogCategoryName;
183:            }
184:
185:            public void setWeblogCategoryName(String weblogCategory) {
186:                this .weblogCategoryName = weblogCategory;
187:            }
188:
189:            public List getTags() {
190:                return tags;
191:            }
192:
193:            public void setTags(List tags) {
194:                this .tags = tags;
195:            }
196:
197:            public boolean isExcerpts() {
198:                return excerpts;
199:            }
200:
201:            public void setExcerpts(boolean excerpts) {
202:                this .excerpts = excerpts;
203:            }
204:
205:            public WeblogCategoryData getWeblogCategory() {
206:
207:                if (weblogCategory == null && weblogCategoryName != null) {
208:                    try {
209:                        WeblogManager wmgr = RollerFactory.getRoller()
210:                                .getWeblogManager();
211:                        weblogCategory = wmgr.getWeblogCategoryByPath(
212:                                getWeblog(), weblogCategoryName);
213:                    } catch (RollerException ex) {
214:                        log.error("Error getting weblog category "
215:                                + weblogCategoryName, ex);
216:                    }
217:                }
218:
219:                return weblogCategory;
220:            }
221:
222:            public void setWeblogCategory(WeblogCategoryData weblogCategory) {
223:                this.weblogCategory = weblogCategory;
224:            }
225:
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.