Source Code Cross Referenced for WeblogCommentRequest.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.io.UnsupportedEncodingException;
022:        import java.net.URLDecoder;
023:        import javax.servlet.http.HttpServletRequest;
024:        import org.apache.commons.logging.Log;
025:        import org.apache.commons.logging.LogFactory;
026:        import org.apache.roller.RollerException;
027:        import org.apache.roller.business.RollerFactory;
028:        import org.apache.roller.business.WeblogManager;
029:        import org.apache.roller.pojos.WeblogEntryData;
030:        import org.apache.roller.util.Utilities;
031:
032:        /**
033:         * Represents a request to post a weblog entry comment.
034:         */
035:        public class WeblogCommentRequest extends WeblogRequest {
036:
037:            private static Log log = LogFactory
038:                    .getLog(WeblogCommentRequest.class);
039:
040:            private static final String COMMENT_SERVLET = "/roller-ui/rendering/comment";
041:
042:            // lightweight attributes
043:            private String name = null;
044:            private String email = null;
045:            private String url = null;
046:            private String content = null;
047:            private boolean notify = false;
048:            private String weblogAnchor = null;
049:
050:            // heavyweight attributes
051:            private WeblogEntryData weblogEntry = null;
052:
053:            public WeblogCommentRequest() {
054:            }
055:
056:            public WeblogCommentRequest(HttpServletRequest request)
057:                    throws InvalidRequestException {
058:
059:                // let our parent take care of their business first
060:                // parent determines weblog handle and locale if specified
061:                super (request);
062:
063:                String servlet = request.getServletPath();
064:
065:                // we only want the path info left over from after our parents parsing
066:                String pathInfo = this .getPathInfo();
067:
068:                // was this request bound for the comment servlet?
069:                if (servlet == null || !COMMENT_SERVLET.equals(servlet)) {
070:                    throw new InvalidRequestException(
071:                            "not a weblog comment request, "
072:                                    + request.getRequestURL());
073:                }
074:
075:                /*
076:                 * parse path info.  we expect ...
077:                 *
078:                 * /entry/<anchor> - permalink
079:                 */
080:                if (pathInfo != null && pathInfo.trim().length() > 0) {
081:
082:                    // we should only ever get 2 path elements
083:                    String[] pathElements = pathInfo.split("/");
084:                    if (pathElements.length == 2) {
085:
086:                        String context = pathElements[0];
087:                        if ("entry".equals(context)) {
088:                            try {
089:                                this .weblogAnchor = URLDecoder.decode(
090:                                        pathElements[1], "UTF-8");
091:                            } catch (UnsupportedEncodingException ex) {
092:                                // should never happen
093:                                log.error(ex);
094:                            }
095:
096:                        } else {
097:                            throw new InvalidRequestException("bad path info, "
098:                                    + request.getRequestURL());
099:                        }
100:
101:                    } else {
102:                        throw new InvalidRequestException("bad path info, "
103:                                + request.getRequestURL());
104:                    }
105:
106:                } else {
107:                    // bad request
108:                    throw new InvalidRequestException("bad path info, "
109:                            + request.getRequestURL());
110:                }
111:
112:                /*
113:                 * parse request parameters
114:                 *
115:                 * the only params we currently care about are:
116:                 *   name - comment author
117:                 *   email - comment email
118:                 *   url - comment referring url
119:                 *   content - comment contents
120:                 *   notify - if commenter wants to receive notifications
121:                 */
122:                if (request.getParameter("name") != null) {
123:                    this .name = Utilities.removeHTML(request
124:                            .getParameter("name"));
125:                }
126:
127:                if (request.getParameter("email") != null) {
128:                    this .email = Utilities.removeHTML(request
129:                            .getParameter("email"));
130:                }
131:
132:                if (request.getParameter("url") != null) {
133:                    this .url = Utilities
134:                            .removeHTML(request.getParameter("url"));
135:                }
136:
137:                if (request.getParameter("content") != null) {
138:                    this .content = request.getParameter("content");
139:                }
140:
141:                if (request.getParameter("notify") != null) {
142:                    this .notify = Boolean.valueOf(
143:                            request.getParameter("notify")).booleanValue();
144:                }
145:
146:                if (log.isDebugEnabled()) {
147:                    log.debug("name = " + this .name);
148:                    log.debug("email = " + this .email);
149:                    log.debug("url = " + this .url);
150:                    log.debug("content = " + this .content);
151:                    log.debug("notify = " + this .notify);
152:                    log.debug("weblogAnchor = " + this .weblogAnchor);
153:                }
154:            }
155:
156:            public String getName() {
157:                return name;
158:            }
159:
160:            public void setName(String name) {
161:                this .name = name;
162:            }
163:
164:            public String getEmail() {
165:                return email;
166:            }
167:
168:            public void setEmail(String email) {
169:                this .email = email;
170:            }
171:
172:            public String getUrl() {
173:                return url;
174:            }
175:
176:            public void setUrl(String url) {
177:                this .url = url;
178:            }
179:
180:            public String getContent() {
181:                return content;
182:            }
183:
184:            public void setContent(String content) {
185:                this .content = content;
186:            }
187:
188:            public boolean isNotify() {
189:                return notify;
190:            }
191:
192:            public void setNotify(boolean notify) {
193:                this .notify = notify;
194:            }
195:
196:            public String getWeblogAnchor() {
197:                return weblogAnchor;
198:            }
199:
200:            public void setWeblogAnchor(String weblogAnchor) {
201:                this .weblogAnchor = weblogAnchor;
202:            }
203:
204:            public WeblogEntryData getWeblogEntry() {
205:
206:                if (weblogEntry == null && weblogAnchor != null) {
207:                    try {
208:                        WeblogManager wmgr = RollerFactory.getRoller()
209:                                .getWeblogManager();
210:                        weblogEntry = wmgr.getWeblogEntryByAnchor(getWeblog(),
211:                                weblogAnchor);
212:                    } catch (RollerException ex) {
213:                        log.error("Error getting weblog entry " + weblogAnchor,
214:                                ex);
215:                    }
216:                }
217:
218:                return weblogEntry;
219:            }
220:
221:            public void setWeblogEntry(WeblogEntryData weblogEntry) {
222:                this.weblogEntry = weblogEntry;
223:            }
224:
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.