The attached patch to GenericListserv and AvalonListserv adds a new
configuration option.  GenericListserv now adds:

     /**
      * Should the subject prefix be automatically surrounded by [].
      */
     public boolean getAutoBracketPrefix() throws MessagingException {
         return true; // preserve old behavior unless subclass overrides.
     }

This is true by default to preserve compatibility with any existing
subclasses and configurations.

AvalonListserv.init() adds:

         try {
             autoBracket = new
Boolean(getInitParameter("autobracket")).booleanValue();
         } catch (Exception e) {
         }

and the class gets:

     public boolean getAutoBracketPrefix() {
         return autoBracket;
     }

Existing list classes and configurations work as-is with no changes
required.  If the new functionality is desired, an explicit
<autobracket>false</autobracket> element must be added.

All of this (and more) is in the revised class documentation.

        --- Noel
Index: AvalonListserv.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-james/src/java/org/apache/james/transport/mailets/AvalonListserv.java,v
retrieving revision 1.4
diff -u -r1.4 AvalonListserv.java
--- AvalonListserv.java 19 Aug 2002 18:57:07 -0000      1.4
+++ AvalonListserv.java 19 Aug 2002 21:10:41 -0000
@@ -23,11 +23,33 @@
  * MailingListServer capability.
  * 
  * <p>Requires a configuration element in the .conf.xml file of the form:
- * <br>&lt;repositoryName&gt;name of user repository configured in UsersStore block 
&lt;/repositoryName&gt;
- * <br>&lt;membersonly&gt;
- * <br>&lt;attachmentsallowed&gt;
- * <br>&lt;replytolist&gt;
- * <br>&lt;subjectprefix&gt;
+ * <br>  &lt;mailet match="RecipientIs=LIST-ADDRESS" class="AvalonListserv"&gt;
+ * <br>    &lt;repositoryName&gt;LIST-NAME&lt;/repositoryName&gt;
+ * <br>    &lt;membersonly&gt;[true|false]&lt;/membersonly&gt;
+ * <br>    &lt;attachmentsallowed&gt;[true|false]&lt;/attachmentsallowed&gt;
+ * <br>    &lt;replytolist&gt;[true|false]&lt;/replytolist&gt;
+ * <br>    &lt;autobracket&gt;[true|false]&lt;/autobracket&gt;
+ * <br>    &lt;subjectprefix 
+[xml:space="preserve"]&gt;SUBJECT-PREFIX&lt;/subjectprefix&gt;
+ * <br>  &lt;/mailet&gt;
+ * <p>repositoryName - the name of a user repository configured in the
+ * UsersStore block, e.g.,
+ * <br>  &lt;repository name="list-name" 
+class="org.apache.james.userrepository.ListUsersJdbcRepository" 
+destinationURL="db://maildb/lists/list-name"&gt;
+ * <br>    &lt;sqlFile&gt;file://conf/sqlResources.xml&lt;/sqlFile&gt;
+ * <br>  &lt;/repository&gt;
+ * <p>or
+ * <br>  &lt;repository name="list-name" 
+class="org.apache.james.userrepository.UsersFileRepository"&gt;
+ * <br>    &lt;destination URL="file://var/lists/list-name/"/&gt;
+ * <br>  &lt;/repository&gt;
+ * <p>membersonly - if true only members can post to the list
+ * <p>attachmentsallowed - if false attachments are not allowed
+ * <p>replytolist - if true, replies go back to the list address; if
+ * false they go to the sender.
+ * <p>subjectprefix - a prefix that will be inserted at the front of
+ * the subject.  If autobracketing is disabled (see below), the
+ * xml:space="preserve" attribute can be used to precisely control the
+ * prefix.
+ * <p>autobracket - if true the subject prefix will be rendered as
+ * "[PREFIX] ", if false, the prefix will be used literally.
  *
  * @author  <a href="[EMAIL PROTECTED]">Serge Knystautas </a>
  * @version This is $Revision: 1.4 $
@@ -39,6 +61,7 @@
     protected boolean attachmentsAllowed = true;
     protected boolean replyToList = true;
     protected String subjectPrefix = null;
+    protected boolean autoBracket = true;
     private UsersRepository members;
 
     public void init() {
@@ -55,6 +78,10 @@
         } catch (Exception e) {
         }
         subjectPrefix = getInitParameter("subjectprefix");
+        try {
+            autoBracket = new Boolean(getInitParameter("autobracket")).booleanValue();
+        } catch (Exception e) {
+        }
 
         ComponentManager compMgr = 
(ComponentManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
         try {
@@ -93,11 +120,16 @@
         return subjectPrefix;
     }
 
+    public boolean getAutoBracketPrefix() {
+        return autoBracket;
+    }
+
     /**
      * Return a string describing this mailet.
      *
      * @return a string describing this mailet
      */
+
     public String getMailetInfo() {
         return "AvalonListserv Mailet";
     }
Index: GenericListserv.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-james/src/java/org/apache/james/transport/mailets/GenericListserv.java,v
retrieving revision 1.8
diff -u -r1.8 GenericListserv.java
--- GenericListserv.java        16 Aug 2002 17:05:49 -0000      1.8
+++ GenericListserv.java        19 Aug 2002 21:10:41 -0000
@@ -57,11 +57,18 @@
     }
 
     /**
-     * An optional subject prefix which will be surrounded by [].
+     * An optional subject prefix
      */
     public abstract String getSubjectPrefix() throws MessagingException;
 
     /**
+     * Should the subject prefix be automatically surrounded by [].
+     */
+    public boolean getAutoBracketPrefix() throws MessagingException {
+        return true; // preserve old behavior unless subclass overrides.
+    }
+
+    /**
      * Processes the message.  Assumes it is the only recipient of this forked 
message.
      */
     public final void service(Mail mail) throws MessagingException {
@@ -106,12 +113,15 @@
 
             //Set the subject if set
             if (getSubjectPrefix() != null) {
-                StringBuffer prefixBuffer =
-                    new StringBuffer(64)
-                        .append("[")
-                        .append(getSubjectPrefix())
-                        .append("]");
-                String prefix = prefixBuffer.toString();
+                String prefix = getSubjectPrefix();
+                if (getAutoBracketPrefix()) {
+                    StringBuffer prefixBuffer =
+                        new StringBuffer(64)
+                            .append("[")
+                            .append(prefix)
+                            .append("]");
+                    prefix = prefixBuffer.toString();
+                }
                 String subj = message.getSubject();
                 if (subj == null) {
                     subj = "";

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to