Source Code Cross Referenced for ForumHandler.java in  » Web-Server » pygmy-httpd » pygmy » nntp » http » 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 » Web Server » pygmy httpd » pygmy.nntp.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package pygmy.nntp.http;
002:
003:        import pygmy.nntp.Forum;
004:        import pygmy.nntp.NewsGroup;
005:        import pygmy.nntp.http.ForumView;
006:        import pygmy.core.HttpRequest;
007:        import pygmy.core.HttpResponse;
008:        import pygmy.core.UUID;
009:
010:        import java.io.IOException;
011:        import java.net.HttpURLConnection;
012:
013:        public class ForumHandler {//extends AbstractXmlHandler {
014:
015:            public static final String CSS = "css";
016:
017:            private Forum forum;
018:
019:            public ForumHandler() {
020:                //        forum = new Forum();
021:                //
022:                //        NewsGroup t = forum.createNewsgroup( "Foo", "Dude" );
023:                //        System.out.println("t.getGuid() = " + t.getGuid());
024:                //        ForumMessage message = new ForumMessage("This is a subject", "charlie", "Read my contents.");
025:                //        ForumMessage message1 = new ForumMessage( message.getGuid(), "Bring it", "charlie", "Read my contents.");
026:                //        ForumMessage message2 = new ForumMessage("What is this", "charlie", "Read my contents.");
027:                //        ForumMessage message3 = new ForumMessage( message.getGuid(), "DotCrap!", "charlie", "Read my contents.");
028:                //        ForumMessage message4 = new ForumMessage("What is this shit", "charlie", "Read my contents.");
029:                //        ForumMessage message5 = new ForumMessage("Football is cool.", "charlie", "Read my contents.");
030:                //        ForumMessage message6 = new ForumMessage("I have nothing of interest to say", "charlie", "Read my contents.");
031:                //        ForumMessage message7 = new ForumMessage("work sucks.  I know.", "charlie", "Read my contents.");
032:
033:                //        t.addMessage( message );
034:                //        t.addMessage( message1 );
035:                //        t.addMessage( message2 );
036:                //        t.addMessage( message3 );
037:                //        t.addMessage( message4 );
038:                //        t.addMessage( message5 );
039:                //        t.addMessage( message6 );
040:                //        t.addMessage( message7 );
041:            }
042:
043:            protected boolean handleBody(HttpRequest request,
044:                    HttpResponse response) throws IOException {
045:                if (request.getUrl().endsWith("post")
046:                        && request.getMethod().equalsIgnoreCase("GET")) {
047:                    return createPost(request, response);
048:                } else if (request.getUrl().endsWith("post")
049:                        && request.getMethod().equalsIgnoreCase("POST")) {
050:                    return postMessage(request, response);
051:                } else if (request.getUrl().endsWith("read")) {
052:                    return readMessage(request, response);
053:                } else if (request.getUrl().endsWith("topic")) {
054:                    return readTopic(request, response);
055:                } else {
056:                    return readForum(request, response);
057:                }
058:            }
059:
060:            private boolean postMessage(HttpRequest request,
061:                    HttpResponse response) throws IOException {
062:                String subject = request.getParameter("subject");
063:                String author = request.getParameter("author");
064:                String messageUuidStr = request.getParameter("message");
065:                String topicUuidStr = request.getParameter("topic");
066:                String contents = request.getParameter("contents");
067:
068:                //        if( topicUuidStr == null ) return readForum( request, response );
069:
070:                UUID topicUuid = UUID.parse(topicUuidStr);
071:                UUID parentMessage = null;
072:                if (messageUuidStr != null) {
073:                    parentMessage = UUID.parse(messageUuidStr);
074:                }
075:
076:                //        NewsGroup topic = forum.getTopic( topicUuid );
077:                if (request.getParameter("preview") == null) {
078:                    //            showMessage( topicUuid, topic.addMessage( new ForumMessage( parentMessage, subject, author, contents ) ), request, response );
079:                } else {
080:                    //            previewMessage( topic, parentMessage, author, subject, contents, request, response );
081:                }
082:                return true;
083:            }
084:
085:            //    private void previewMessage(NewsGroup topic, UUID parentMessage, String author, String subject, String contents, HttpRequest request, HttpResponse response ) throws IOException {
086:            //        CompositeView composite = new CompositeView( getUrlPrefix(), "<p>" );
087:            //        ForumMessage preview = new ForumMessage( parentMessage, subject, author, contents );
088:            //        composite.addView( createPostView( topic, preview ) );
089:            //        composite.addView( new MessageView( getUrlPrefix(), topic, preview ) );
090:            //        View view = new DocumentView( getUrlPrefix(), getStyleSheet(request), composite );
091:            //        response.sendResponse( HttpURLConnection.HTTP_OK, "text/html", view.render( request ) );
092:            //    }
093:            //
094:            private boolean readForum(HttpRequest request, HttpResponse response)
095:                    throws IOException {
096:                //        ForumView forumView = new ForumView( getUrlPrefix(), forum );
097:                //        NavigationTabsView tabs = new NavigationTabsView( getUrlPrefix(), forumView, "Forums", new String[] { "Forums" }, new String[] { forumView.getForumUrl() } );
098:                //        View view = new DocumentView( getUrlPrefix(), getStyleSheet(request), tabs );
099:                //        response.sendResponse( HttpURLConnection.HTTP_OK, "text/html", view.render( request ) );
100:                return true;
101:            }
102:
103:            private boolean readTopic(HttpRequest request, HttpResponse response)
104:                    throws IOException {
105:                String messageStart = request.getParameter("messageStart");
106:                String numberToDisplay = request.getParameter("display");
107:                UUID topicUuid = UUID.parse(request.getParameter("topic"));
108:
109:                UUID startingMessage = null;
110:                if (messageStart == null) {
111:                    //            startingMessage = forum.getTopic( topicUuid ).first();
112:                } else {
113:                    startingMessage = UUID.parse(messageStart);
114:                }
115:
116:                int displayLength = 20;
117:                if (numberToDisplay != null) {
118:                    displayLength = Integer.parseInt(numberToDisplay);
119:                }
120:
121:                //        NewsGroup topic = forum.getTopic( topicUuid );
122:                //        TopicView topicView = new TopicView( getUrlPrefix(), topic, startingMessage, displayLength );
123:                //        NavigationTabsView tabs = new NavigationTabsView( getUrlPrefix(), topicView, "NewsGroup", new String[] { "Forums", "NewsGroup", "Post" }, new String[] { getUrlPrefix() + "/", null, getUrlPrefix() + "/post?topic=" + topic.getGuid() } );
124:
125:                //        View view = new DocumentView( getUrlPrefix(), getStyleSheet(request), tabs );
126:                //        response.sendResponse( HttpURLConnection.HTTP_OK, "text/html", view.render(request) );
127:                return true;
128:            }
129:
130:            private boolean readMessage(HttpRequest request,
131:                    HttpResponse response) throws IOException {
132:                String messageStr = request.getParameter("message");
133:                String topicStr = request.getParameter("topic");
134:                if (messageStr == null)
135:                    return false;
136:
137:                UUID message = UUID.parse(messageStr);
138:                UUID topicUuid = UUID.parse(topicStr);
139:
140:                showMessage(topicUuid, message, request, response);
141:                return true;
142:            }
143:
144:            private void showMessage(UUID topicUuid, UUID messageGuid,
145:                    HttpRequest request, HttpResponse response)
146:                    throws IOException {
147:                //        NewsGroup topic = forum.getTopic( topicUuid );
148:                //        CompositeView composite = new CompositeView( getUrlPrefix(), "<p>" );
149:                //        ForumMessage message = topic.getMessage( messageGuid );
150:                //        MessageControls controls = new MessageControls( getUrlPrefix(), new MessageView( getUrlPrefix(), topic, message ), message, topic );
151:                //        NavigationTabsView tabs = new NavigationTabsView( getUrlPrefix(), controls, "Message", new String[] { "Forums", "NewsGroup", "Message" }, new String[] { getUrlPrefix() + "/", getUrlPrefix() + topic.getUrl(), null } );
152:                //        composite.addView( tabs );
153:                //        composite.addView( new ThreadMapView( getUrlPrefix(), topic, message ) );
154:                //        View view = new DocumentView( getUrlPrefix(), getStyleSheet(request), composite );
155:                //        response.sendResponse( HttpURLConnection.HTTP_OK, "text/html", view.render( request ) );
156:            }
157:
158:            private boolean createPost(HttpRequest request,
159:                    HttpResponse response) throws IOException {
160:                //        String messageStr = request.getParameter("message");
161:                //        String topicStr = request.getParameter("topic");
162:                //
163:                //        UUID topicUuid = UUID.parse( topicStr );
164:                //        NewsGroup topic = forum.getTopic( topicUuid );
165:                //
166:                //        UUID parentGuid = null;
167:                //        if( messageStr != null ) {
168:                //            parentGuid = UUID.parse( messageStr );
169:                //        }
170:                //
171:                //        ForumMessage message = null;
172:                //        if( parentGuid != null ) {
173:                //            ForumMessage parentMessage = topic.getMessage( parentGuid );
174:                //            message = new ForumMessage( parentMessage.getGuid(), "Re: " + parentMessage.getSubject(), "", parentMessage.getContents() );
175:                //        }
176:                //        View tabs = createPostView(topic, message);
177:                //        View view = new DocumentView( getUrlPrefix(), getStyleSheet(request), tabs );
178:                //        response.sendResponse( HttpURLConnection.HTTP_OK, "text/html", view.render( request ) );
179:                return true;
180:            }
181:
182:            private View createPostView(NewsGroup topic, ForumMessage message) {
183:                //        String[] headings = null;
184:                //        String[] links = null;
185:                //        if( message == null ) {
186:                //            headings = new String[] { "Forums", "NewsGroup", "Post" };
187:                //            links = new String[] { getUrlPrefix() + "/", getUrlPrefix() + topic.getUrl(), null };
188:                //        } else {
189:                //            headings = new String[] { "Forums", "NewsGroup", "Message", "Post" };
190:                //            links = new String[] { getUrlPrefix() + "/", getUrlPrefix() + topic.getUrl(), getUrlPrefix() + topic.getMessage( message.getParentGuid() ).getUrl() , null };
191:                //        }
192:                //        PostView postView = new PostView( getUrlPrefix(), topic, message );
193:                //        NavigationTabsView tabs = new NavigationTabsView( getUrlPrefix(), postView, "Post", headings, links );
194:                //        return tabs;
195:                return null;
196:            }
197:
198:            //    private String getStyleSheet(HttpRequest request) throws IOException {
199:            //        return request.createUrl( server.getHandlerProperty( handlerName, CSS, "/style_ie.css" ) );
200:            //    }
201:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.