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