Source Code Cross Referenced for AvalonListserv.java in  » Web-Mail » james-2.3.1 » org » apache » james » transport » mailets » 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 Mail » james 2.3.1 » org.apache.james.transport.mailets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /****************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one   *
003:         * or more contributor license agreements.  See the NOTICE file *
004:         * distributed with this work for additional information        *
005:         * regarding copyright ownership.  The ASF licenses this file   *
006:         * to you under the Apache License, Version 2.0 (the            *
007:         * "License"); you may not use this file except in compliance   *
008:         * with the License.  You may obtain a copy of the License at   *
009:         *                                                              *
010:         *   http://www.apache.org/licenses/LICENSE-2.0                 *
011:         *                                                              *
012:         * Unless required by applicable law or agreed to in writing,   *
013:         * software distributed under the License is distributed on an  *
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015:         * KIND, either express or implied.  See the License for the    *
016:         * specific language governing permissions and limitations      *
017:         * under the License.                                           *
018:         ****************************************************************/package org.apache.james.transport.mailets;
019:
020:        import org.apache.avalon.framework.service.ServiceException;
021:        import org.apache.avalon.framework.service.ServiceManager;
022:        import org.apache.james.Constants;
023:        import org.apache.james.services.UsersRepository;
024:        import org.apache.james.services.UsersStore;
025:        import org.apache.mailet.MailAddress;
026:
027:        import javax.mail.internet.ParseException;
028:        import java.util.Collection;
029:        import java.util.Iterator;
030:        import java.util.ArrayList;
031:
032:        /**
033:         * MailingListServer capability.
034:         * 
035:         * <p>Requires a configuration element in the config.xml file of the form:
036:         * <br>  &lt;mailet match="RecipientIs=LIST-ADDRESS" class="AvalonListserv"&gt;
037:         * <br>    &lt;repositoryName&gt;LIST-NAME&lt;/repositoryName&gt;
038:         * <br>    &lt;membersonly&gt;[true|false]&lt;/membersonly&gt;
039:         * <br>    &lt;attachmentsallowed&gt;[true|false]&lt;/attachmentsallowed&gt;
040:         * <br>    &lt;replytolist&gt;[true|false]&lt;/replytolist&gt;
041:         * <br>    &lt;autobracket&gt;[true|false]&lt;/autobracket&gt;
042:         * <br>    &lt;subjectprefix [xml:space="preserve"]&gt;SUBJECT-PREFIX&lt;/subjectprefix&gt;
043:         * <br>  &lt;/mailet&gt;
044:         * <p>repositoryName - the name of a user repository configured in the
045:         * UsersStore block, e.g.,
046:         * <br>  &lt;repository name="list-name" class="org.apache.james.userrepository.ListUsersJdbcRepository" destinationURL="db://maildb/lists/list-name"&gt;
047:         * <br>    &lt;sqlFile&gt;file://conf/sqlResources.xml&lt;/sqlFile&gt;
048:         * <br>  &lt;/repository&gt;
049:         * <p>or
050:         * <br>  &lt;repository name="list-name" class="org.apache.james.userrepository.UsersFileRepository"&gt;
051:         * <br>    &lt;destination URL="file://var/lists/list-name/"/&gt;
052:         * <br>  &lt;/repository&gt;
053:         * <p>membersonly - if true only members can post to the list
054:         * <p>attachmentsallowed - if false attachments are not allowed
055:         * <p>replytolist - if true, replies go back to the list address; if
056:         * false they go to the sender.
057:         * <p>subjectprefix - a prefix that will be inserted at the front of
058:         * the subject.  If autobracketing is disabled (see below), the
059:         * xml:space="preserve" attribute can be used to precisely control the
060:         * prefix.
061:         * <p>autobracket - if true the subject prefix will be rendered as
062:         * "[PREFIX] ", if false, the prefix will be used literally.
063:         *
064:         * @version This is $Revision: 494012 $
065:         */
066:        public class AvalonListserv extends GenericListserv {
067:
068:            /**
069:             * Whether only members can post to the list
070:             */
071:            protected boolean membersOnly = false;
072:
073:            /**
074:             * Whether attachments can be sent to the list
075:             */
076:            protected boolean attachmentsAllowed = true;
077:
078:            /**
079:             * Whether the reply-to header should be set to the list address
080:             */
081:            protected boolean replyToList = true;
082:
083:            /**
084:             * A String to prepend to the subject of the message when it
085:             * is sent to the list
086:             */
087:            protected String subjectPrefix = null;
088:
089:            /**
090:             * Whether the subject prefix should be bracketed with '[' and ']'
091:             */
092:            protected boolean autoBracket = true;
093:
094:            /**
095:             * The repository containing the users on this list
096:             */
097:            private UsersRepository members;
098:
099:            /**
100:             * Initialize the mailet
101:             */
102:            public void init() {
103:                try {
104:                    membersOnly = new Boolean(getInitParameter("membersonly"))
105:                            .booleanValue();
106:                } catch (Exception e) {
107:                    // Ignore any exceptions, default to false
108:                }
109:                try {
110:                    attachmentsAllowed = new Boolean(
111:                            getInitParameter("attachmentsallowed"))
112:                            .booleanValue();
113:                } catch (Exception e) {
114:                    // Ignore any exceptions, default to true
115:                }
116:                try {
117:                    replyToList = new Boolean(getInitParameter("replytolist"))
118:                            .booleanValue();
119:                } catch (Exception e) {
120:                    // Ignore any exceptions, default to true
121:                }
122:                subjectPrefix = getInitParameter("subjectprefix");
123:
124:                try {
125:                    autoBracket = new Boolean(getInitParameter("autobracket"))
126:                            .booleanValue();
127:                } catch (Exception e) {
128:                    // Ignore any exceptions, default to true
129:                }
130:
131:                ServiceManager compMgr = (ServiceManager) getMailetContext()
132:                        .getAttribute(Constants.AVALON_COMPONENT_MANAGER);
133:                try {
134:                    UsersStore usersStore = (UsersStore) compMgr
135:                            .lookup(UsersStore.ROLE);
136:                    String repName = getInitParameter("repositoryName");
137:
138:                    members = (UsersRepository) usersStore
139:                            .getRepository(repName);
140:                } catch (ServiceException cnfe) {
141:                    log("Failed to retrieve Store component:"
142:                            + cnfe.getMessage());
143:                } catch (Exception e) {
144:                    log("Failed to retrieve Store component:" + e.getMessage());
145:                }
146:            }
147:
148:            public Collection getMembers() throws ParseException {
149:                Collection reply = new ArrayList();
150:                for (Iterator it = members.list(); it.hasNext();) {
151:                    String member = it.next().toString();
152:                    try {
153:                        reply.add(new MailAddress(member));
154:                    } catch (Exception e) {
155:                        // Handle an invalid subscriber address by logging it and
156:                        // proceeding to the next member.
157:                        StringBuffer logBuffer = new StringBuffer(1024).append(
158:                                "Invalid subscriber address: ").append(member)
159:                                .append(" caused: ").append(e.getMessage());
160:                        log(logBuffer.toString());
161:                    }
162:                }
163:                return reply;
164:            }
165:
166:            /**
167:             * Get whether posting to this list is restricted to list members
168:             *
169:             * @return whether posting to this list is restricted to list members
170:             */
171:            public boolean isMembersOnly() {
172:                return membersOnly;
173:            }
174:
175:            /**
176:             * Get whether attachments can be sent to this list
177:             *
178:             * @return whether attachments can be sent to this list
179:             */
180:            public boolean isAttachmentsAllowed() {
181:                return attachmentsAllowed;
182:            }
183:
184:            /**
185:             * Get whether the reply-to header for messages sent to this list
186:             * will be replaced with the list address
187:             *
188:             * @return whether replies to messages posted to this list will go to the entire list
189:             */
190:            public boolean isReplyToList() {
191:                return replyToList;
192:            }
193:
194:            /**
195:             * Get the prefix prepended to the subject line
196:             *
197:             * @return whether the prefix for subjects on this list will be bracketed.
198:             */
199:            public String getSubjectPrefix() {
200:                return subjectPrefix;
201:            }
202:
203:            /**
204:             * Return whether the prefix for subjects on this list will be bracketed.
205:             *
206:             * @return whether the prefix for subjects on this list will be bracketed.
207:             */
208:            public boolean isPrefixAutoBracketed() {
209:                return autoBracket;
210:            }
211:
212:            /**
213:             * Return a string describing this mailet.
214:             *
215:             * @return a string describing this mailet
216:             */
217:            public String getMailetInfo() {
218:                return "AvalonListserv Mailet";
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.