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


001:        package pygmy.nntp;
002:
003:        import pygmy.core.Handler;
004:        import pygmy.core.Server;
005:        import pygmy.core.Request;
006:        import pygmy.core.Response;
007:
008:        import java.io.IOException;
009:
010:        public abstract class NntpHandler implements  Handler {
011:
012:            private String name;
013:            private Server server;
014:
015:            public boolean initialize(String handlerName, Server aServer) {
016:                name = handlerName;
017:                server = aServer;
018:                return true;
019:            }
020:
021:            public String getName() {
022:                return name;
023:            }
024:
025:            public boolean isPostingAllowed(Request nntpRequest) {
026:                return Boolean.valueOf(
027:                        nntpRequest.getProperty("posting", "true"))
028:                        .booleanValue();
029:            }
030:
031:            public boolean handle(Request request, Response response)
032:                    throws IOException {
033:                if (request instanceof  NntpRequest) {
034:                    return handleNntp((NntpRequest) request,
035:                            (NntpResponse) response);
036:                }
037:                return false;
038:            }
039:
040:            public abstract boolean handleNntp(NntpRequest nntpRequest,
041:                    NntpResponse nntpResponse) throws IOException;
042:
043:            public boolean shutdown(Server server) {
044:                return true;
045:            }
046:
047:            public void respondGroupSelected(NewsGroup group,
048:                    NntpResponse nntpResponse) throws IOException {
049:                StringBuffer buffer = new StringBuffer();
050:                buffer.append(group.size());
051:                buffer.append(" ");
052:                buffer.append(group.getFirstIndex());
053:                buffer.append(" ");
054:                buffer.append(group.getLastIndex());
055:                buffer.append(" ");
056:                buffer.append(group.getName());
057:                buffer.append(" group selected.");
058:                nntpResponse.sendResponse(211, buffer.toString());
059:            }
060:
061:            public void respondNewsgroupList(NntpResponse nntpResponse)
062:                    throws IOException {
063:                nntpResponse.sendResponse(215, "list of newsgroups follows");
064:            }
065:
066:            public void respondArticleRetrieved(Article message,
067:                    NntpResponse nntpResponse) throws IOException {
068:                nntpResponse.sendResponse(220, new String[] {
069:                        Integer.toString(message.getArticleNumber()),
070:                        message.getMessageId(),
071:                        "article retrieved - head and body follow" });
072:            }
073:
074:            public void respondNextArticleFound(Article article,
075:                    NntpResponse nntpResponse) throws IOException {
076:                nntpResponse.sendResponse(223, new String[] {
077:                        String.valueOf(article.getArticleNumber()),
078:                        article.getMessageId(),
079:                        "article retrieved - request text separately" });
080:            }
081:
082:            public void respondListOfNews(NntpResponse response)
083:                    throws IOException {
084:                response.sendResponse(230,
085:                        "list of new articles by message-id follows");
086:            }
087:
088:            public void respondListOfNewsgroups(NntpResponse nntpResponse)
089:                    throws IOException {
090:                nntpResponse
091:                        .sendResponse(231, "list of new newsgroups follows");
092:            }
093:
094:            public void respondArticleTransferedOk(NntpResponse nntpResponse)
095:                    throws IOException {
096:                nntpResponse.sendResponse(235, "article transferred ok");
097:            }
098:
099:            public void respondPostingOk(NntpResponse nntpResponse)
100:                    throws IOException {
101:                nntpResponse.sendResponse(240, "article posted ok");
102:            }
103:
104:            public void respondArticleWanted(NntpResponse nntpResponse)
105:                    throws IOException {
106:                nntpResponse
107:                        .sendResponse(335,
108:                                "send article to be transferred.  End with <CR-LF>.<CR-LF>");
109:            }
110:
111:            public void respondSendArticleToBePosted(NntpResponse nntpResponse)
112:                    throws IOException {
113:                nntpResponse.sendResponse(340,
114:                        "send article to be posted. End with <CR-LF>.<CR-LF>");
115:            }
116:
117:            public void respondNoSuchGroup(NntpResponse nntpResponse)
118:                    throws IOException {
119:                nntpResponse.sendResponse(411, "no such news group");
120:            }
121:
122:            public void respondNoNewsGroup(NntpResponse nntpResponse)
123:                    throws IOException {
124:                nntpResponse
125:                        .sendResponse(412, "no newsgroup has been selected");
126:            }
127:
128:            public void respondNoCurrentArticle(NntpResponse nntpResponse)
129:                    throws IOException {
130:                nntpResponse.sendResponse(420,
131:                        "no current article has been selected");
132:            }
133:
134:            public void respondNoNextArticle(NntpResponse nntpResponse)
135:                    throws IOException {
136:                nntpResponse.sendResponse(421, "no next article in this group");
137:            }
138:
139:            public void respondNoPreviousArticle(NntpResponse nntpResponse)
140:                    throws IOException {
141:                nntpResponse.sendResponse(422,
142:                        "no previous article in this group");
143:            }
144:
145:            public void respondNoSuchArticleIndex(NntpResponse nntpResponse)
146:                    throws IOException {
147:                nntpResponse.sendResponse(423,
148:                        "no such article number in this group");
149:            }
150:
151:            public void respondNoSuchArticle(NntpResponse nntpResponse)
152:                    throws IOException {
153:                nntpResponse.sendResponse(430, "no such article found");
154:            }
155:
156:            public void respondArticleNotWanted(NntpResponse nntpResponse)
157:                    throws IOException {
158:                nntpResponse.sendResponse(435,
159:                        "article not wanted - do not send it");
160:            }
161:
162:            public void respondTryTransferAgain(NntpResponse nntpResponse)
163:                    throws IOException {
164:                nntpResponse.sendResponse(436,
165:                        "transfer failed - try again later");
166:            }
167:
168:            public void respondTransferRejected(NntpResponse nntpResponse)
169:                    throws IOException {
170:                nntpResponse.sendResponse(437,
171:                        "article rejected - do not try again");
172:            }
173:
174:            public void respondPostingNotAllowed(NntpResponse nntpResponse)
175:                    throws IOException {
176:                nntpResponse.sendResponse(440, "posting not allowed");
177:            }
178:
179:            public void respondPostingFailed(NntpResponse nntpResponse)
180:                    throws IOException {
181:                nntpResponse.sendResponse(441, "posting failed");
182:            }
183:
184:            public void respondSyntaxError(NntpResponse nntpResponse)
185:                    throws IOException {
186:                nntpResponse.sendResponse(501, "command syntax error");
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.