You are viewing a plain text version of this content. The canonical link for it is here.
Posted to site-dev@james.apache.org by rd...@apache.org on 2008/08/23 15:40:31 UTC
svn commit: r688320 [45/47] - in /james/site/trunk/www/mailet/standard: ./
apidocs/ apidocs/org/ apidocs/org/apache/ apidocs/org/apache/james/
apidocs/org/apache/james/transport/
apidocs/org/apache/james/transport/mailets/ apidocs/org/apache/james/tran...
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CommandListservMatcher.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CommandListservMatcher.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CommandListservMatcher.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CommandListservMatcher.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,80 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>CommandListservMatcher xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/CommandListservMatcher.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericRecipientMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.MailAddress;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="28" href="#28">28</a>
+<a name="29" href="#29">29</a> <em class="jxr_javadoccomment">/**</em>
+<a name="30" href="#30">30</a> <em class="jxr_javadoccomment"> * CommandListservMatcher is the matcher that pairs with the {@link org.apache.james.transport.mailets.CommandListservManager}</em>
+<a name="31" href="#31">31</a> <em class="jxr_javadoccomment"> * It checks to see if the request is intended for the ListservManager, but doesn't guarantee that it is a valid command.</em>
+<a name="32" href="#32">32</a> <em class="jxr_javadoccomment"> * <br /></em>
+<a name="33" href="#33">33</a> <em class="jxr_javadoccomment"> * To configure, insert this into the config.xml inside of the root processor block.</em>
+<a name="34" href="#34">34</a> <em class="jxr_javadoccomment"> * <pre></em>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment"> * &lt;mailet match="CommandListservMatcher=announce@localhost" class="CommandListservManager"&gt;</em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * ...</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> * &lt;/mailet&gt;</em>
+<a name="38" href="#38">38</a> <em class="jxr_javadoccomment"> * </pre></em>
+<a name="39" href="#39">39</a> <em class="jxr_javadoccomment"> *</em>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment"> * @version CVS $Revision: 426007 $ $Date: 2006-07-27 09:52:06 +0100 (Thu, 27 Jul 2006) $</em>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment"> * @since 2.2.0</em>
+<a name="42" href="#42">42</a> <em class="jxr_javadoccomment"> * @see org.apache.james.transport.mailets.CommandListservManager</em>
+<a name="43" href="#43">43</a> <em class="jxr_javadoccomment"> */</em>
+<a name="44" href="#44">44</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/CommandListservMatcher.html">CommandListservMatcher</a> <strong class="jxr_keyword">extends</strong> GenericRecipientMatcher {
+<a name="45" href="#45">45</a>
+<a name="46" href="#46">46</a> <strong class="jxr_keyword">private</strong> MailAddress listservAddress;
+<a name="47" href="#47">47</a>
+<a name="48" href="#48">48</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> init() <strong class="jxr_keyword">throws</strong> MessagingException {
+<a name="49" href="#49">49</a> listservAddress = <strong class="jxr_keyword">new</strong> MailAddress(getCondition());
+<a name="50" href="#50">50</a> }
+<a name="51" href="#51">51</a>
+<a name="52" href="#52">52</a> <em class="jxr_javadoccomment">/**</em>
+<a name="53" href="#53">53</a> <em class="jxr_javadoccomment"> * This doesn't perform an exact match, but checks to see if the request is at lesast</em>
+<a name="54" href="#54">54</a> <em class="jxr_javadoccomment"> * intended to go to the list serv manager.</em>
+<a name="55" href="#55">55</a> <em class="jxr_javadoccomment"> * @param recipient</em>
+<a name="56" href="#56">56</a> <em class="jxr_javadoccomment"> * @return true if matches, false otherwise</em>
+<a name="57" href="#57">57</a> <em class="jxr_javadoccomment"> */</em>
+<a name="58" href="#58">58</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> matchRecipient(MailAddress recipient) {
+<a name="59" href="#59">59</a> <strong class="jxr_keyword">if</strong> (recipient.getHost().equals(listservAddress.getHost())) {
+<a name="60" href="#60">60</a> <strong class="jxr_keyword">if</strong> (recipient.getUser().startsWith(listservAddress.getUser() + <span class="jxr_string">"-"</span>)) {
+<a name="61" href="#61">61</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">true</strong>;
+<a name="62" href="#62">62</a> }
+<a name="63" href="#63">63</a> }
+<a name="64" href="#64">64</a> <strong class="jxr_keyword">return</strong> false;
+<a name="65" href="#65">65</a> }
+<a name="66" href="#66">66</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CompareNumericHeaderValue.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CompareNumericHeaderValue.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CompareNumericHeaderValue.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/CompareNumericHeaderValue.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,191 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>CompareNumericHeaderValue xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/CompareNumericHeaderValue.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> javax.mail.internet.MimeMessage;
+<a name="29" href="#29">29</a>
+<a name="30" href="#30">30</a> <strong class="jxr_keyword">import</strong> java.lang.NumberFormatException;
+<a name="31" href="#31">31</a>
+<a name="32" href="#32">32</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="33" href="#33">33</a> <strong class="jxr_keyword">import</strong> java.util.StringTokenizer;
+<a name="34" href="#34">34</a>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment">/**</em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * <P>Matches mails containing a header with a numeric value whose comparison with the specified value is true.</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> * If the header is missing in the message, there will be <I>no match</I></P></em>
+<a name="38" href="#38">38</a> <em class="jxr_javadoccomment"> * <P>Configuration string: The headerName, a comparison operator and the numeric headerValue</em>
+<a name="39" href="#39">39</a> <em class="jxr_javadoccomment"> * to compare with, <I>space or tab delimited</I>.</P></em>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment"> * <P>The comparison operators are: <CODE>&lt, &lt=, ==, &gt=, &gt</CODE>;</em>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment"> * another set of operators is: <CODE>LT, LE, EQ, GE, GT</CODE>.</em>
+<a name="42" href="#42">42</a> <em class="jxr_javadoccomment"> * Also the following operators are accepted: <CODE>=&lt, =, =&gt</CODE>.</P></em>
+<a name="43" href="#43">43</a> <em class="jxr_javadoccomment"> * <P>Example:</P></em>
+<a name="44" href="#44">44</a> <em class="jxr_javadoccomment"> * <PRE><CODE></em>
+<a name="45" href="#45">45</a> <em class="jxr_javadoccomment"> * &lt;mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability > 0.9" class="ToProcessor"&gt;</em>
+<a name="46" href="#46">46</a> <em class="jxr_javadoccomment"> * &lt;processor&gt; spam &lt;/processor&gt;</em>
+<a name="47" href="#47">47</a> <em class="jxr_javadoccomment"> * &lt;/mailet&gt;</em>
+<a name="48" href="#48">48</a> <em class="jxr_javadoccomment"> * </CODE></PRE></em>
+<a name="49" href="#49">49</a> <em class="jxr_javadoccomment"> *</em>
+<a name="50" href="#50">50</a> <em class="jxr_javadoccomment"> * @version CVS $Revision: 426098 $ $Date: 2006-07-27 16:10:07 +0100 (Thu, 27 Jul 2006) $</em>
+<a name="51" href="#51">51</a> <em class="jxr_javadoccomment"> * @since 2.2.0</em>
+<a name="52" href="#52">52</a> <em class="jxr_javadoccomment"> */</em>
+<a name="53" href="#53">53</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/CompareNumericHeaderValue.html">CompareNumericHeaderValue</a> <strong class="jxr_keyword">extends</strong> GenericMatcher {
+<a name="54" href="#54">54</a>
+<a name="55" href="#55">55</a> <strong class="jxr_keyword">private</strong> String headerName = <strong class="jxr_keyword">null</strong>;
+<a name="56" href="#56">56</a>
+<a name="57" href="#57">57</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">int</strong> comparisonOperator;
+<a name="58" href="#58">58</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> LT = -2;
+<a name="59" href="#59">59</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> LE = -1;
+<a name="60" href="#60">60</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> EQ = 0;
+<a name="61" href="#61">61</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> GE = +1;
+<a name="62" href="#62">62</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">int</strong> GT = +2;
+<a name="63" href="#63">63</a>
+<a name="64" href="#64">64</a> <strong class="jxr_keyword">private</strong> Double headerValue;
+<a name="65" href="#65">65</a>
+<a name="66" href="#66">66</a> <em class="jxr_javadoccomment">/**</em>
+<a name="67" href="#67">67</a> <em class="jxr_javadoccomment"> * @see org.apache.mailet.GenericMatcher#init()</em>
+<a name="68" href="#68">68</a> <em class="jxr_javadoccomment"> */</em>
+<a name="69" href="#69">69</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> init() <strong class="jxr_keyword">throws</strong> MessagingException {
+<a name="70" href="#70">70</a> StringTokenizer st = <strong class="jxr_keyword">new</strong> StringTokenizer(getCondition(), <span class="jxr_string">" \t"</span>, false);
+<a name="71" href="#71">71</a> <strong class="jxr_keyword">if</strong> (st.hasMoreTokens()) {
+<a name="72" href="#72">72</a> headerName = st.nextToken().trim();
+<a name="73" href="#73">73</a> }
+<a name="74" href="#74">74</a> <strong class="jxr_keyword">else</strong> {
+<a name="75" href="#75">75</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Missing headerName"</span>);
+<a name="76" href="#76">76</a> }
+<a name="77" href="#77">77</a> <strong class="jxr_keyword">if</strong> (st.hasMoreTokens()) {
+<a name="78" href="#78">78</a> String comparisonOperatorString = st.nextToken().trim();
+<a name="79" href="#79">79</a> <strong class="jxr_keyword">if</strong> (comparisonOperatorString.equals(<span class="jxr_string">"<"</span>)
+<a name="80" href="#80">80</a> || comparisonOperatorString.equals(<span class="jxr_string">"LT"</span>)) {
+<a name="81" href="#81">81</a> comparisonOperator = LT;
+<a name="82" href="#82">82</a> }
+<a name="83" href="#83">83</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (comparisonOperatorString.equals(<span class="jxr_string">"<="</span>)
+<a name="84" href="#84">84</a> || comparisonOperatorString.equals(<span class="jxr_string">"=<"</span>)
+<a name="85" href="#85">85</a> || comparisonOperatorString.equals(<span class="jxr_string">"LE"</span>)) {
+<a name="86" href="#86">86</a> comparisonOperator = LE;
+<a name="87" href="#87">87</a> }
+<a name="88" href="#88">88</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (comparisonOperatorString.equals(<span class="jxr_string">"=="</span>)
+<a name="89" href="#89">89</a> || comparisonOperatorString.equals(<span class="jxr_string">"="</span>)
+<a name="90" href="#90">90</a> || comparisonOperatorString.equals(<span class="jxr_string">"EQ"</span>)) {
+<a name="91" href="#91">91</a> comparisonOperator = EQ;
+<a name="92" href="#92">92</a> }
+<a name="93" href="#93">93</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (comparisonOperatorString.equals(<span class="jxr_string">">="</span>)
+<a name="94" href="#94">94</a> || comparisonOperatorString.equals(<span class="jxr_string">"=>"</span>)
+<a name="95" href="#95">95</a> || comparisonOperatorString.equals(<span class="jxr_string">"GE"</span>)) {
+<a name="96" href="#96">96</a> comparisonOperator = GE;
+<a name="97" href="#97">97</a> }
+<a name="98" href="#98">98</a> <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (comparisonOperatorString.equals(<span class="jxr_string">">"</span>)
+<a name="99" href="#99">99</a> || comparisonOperatorString.equals(<span class="jxr_string">"GT"</span>)) {
+<a name="100" href="#100">100</a> comparisonOperator = GT;
+<a name="101" href="#101">101</a> }
+<a name="102" href="#102">102</a> <strong class="jxr_keyword">else</strong> {
+<a name="103" href="#103">103</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Bad comparisonOperator: \""</span> + comparisonOperatorString + <span class="jxr_string">"\""</span>);
+<a name="104" href="#104">104</a> }
+<a name="105" href="#105">105</a> }
+<a name="106" href="#106">106</a> <strong class="jxr_keyword">else</strong> {
+<a name="107" href="#107">107</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Missing comparisonOperator"</span>);
+<a name="108" href="#108">108</a> }
+<a name="109" href="#109">109</a> <strong class="jxr_keyword">if</strong> (st.hasMoreTokens()) {
+<a name="110" href="#110">110</a> String headerValueString = st.nextToken().trim();
+<a name="111" href="#111">111</a> <strong class="jxr_keyword">try</strong> {
+<a name="112" href="#112">112</a> headerValue = Double.valueOf(headerValueString);
+<a name="113" href="#113">113</a> }
+<a name="114" href="#114">114</a> <strong class="jxr_keyword">catch</strong> (NumberFormatException nfe) {
+<a name="115" href="#115">115</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Bad header comparison value: \""</span>
+<a name="116" href="#116">116</a> + headerValueString + <span class="jxr_string">"\""</span>, nfe);
+<a name="117" href="#117">117</a> }
+<a name="118" href="#118">118</a> }
+<a name="119" href="#119">119</a> <strong class="jxr_keyword">else</strong> {
+<a name="120" href="#120">120</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Missing headerValue threshold"</span>);
+<a name="121" href="#121">121</a> }
+<a name="122" href="#122">122</a> }
+<a name="123" href="#123">123</a>
+<a name="124" href="#124">124</a> <em class="jxr_javadoccomment">/**</em>
+<a name="125" href="#125">125</a> <em class="jxr_javadoccomment"> * @see org.apache.mailet.GenericMatcher#match(Mail)</em>
+<a name="126" href="#126">126</a> <em class="jxr_javadoccomment"> */</em>
+<a name="127" href="#127">127</a> <strong class="jxr_keyword">public</strong> Collection match(Mail mail) <strong class="jxr_keyword">throws</strong> MessagingException {
+<a name="128" href="#128">128</a> <strong class="jxr_keyword">if</strong> (headerName == <strong class="jxr_keyword">null</strong>) {
+<a name="129" href="#129">129</a> <em class="jxr_comment">// should never get here</em>
+<a name="130" href="#130">130</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(<span class="jxr_string">"Null headerName"</span>);
+<a name="131" href="#131">131</a> }
+<a name="132" href="#132">132</a>
+<a name="133" href="#133">133</a> MimeMessage message = (MimeMessage) mail.getMessage();
+<a name="134" href="#134">134</a>
+<a name="135" href="#135">135</a> String [] headerArray = message.getHeader(headerName);
+<a name="136" href="#136">136</a> <strong class="jxr_keyword">if</strong> (headerArray != <strong class="jxr_keyword">null</strong> && headerArray.length > 0) {
+<a name="137" href="#137">137</a> <strong class="jxr_keyword">try</strong> {
+<a name="138" href="#138">138</a> <strong class="jxr_keyword">int</strong> comparison = Double.valueOf(headerArray[0].trim()).compareTo(headerValue);
+<a name="139" href="#139">139</a> <strong class="jxr_keyword">switch</strong> (comparisonOperator) {
+<a name="140" href="#140">140</a> <strong class="jxr_keyword">case</strong> LT:
+<a name="141" href="#141">141</a> <strong class="jxr_keyword">if</strong> (comparison < 0) {
+<a name="142" href="#142">142</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="143" href="#143">143</a> }
+<a name="144" href="#144">144</a> <strong class="jxr_keyword">break</strong>;
+<a name="145" href="#145">145</a> <strong class="jxr_keyword">case</strong> LE:
+<a name="146" href="#146">146</a> <strong class="jxr_keyword">if</strong> (comparison <= 0) {
+<a name="147" href="#147">147</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="148" href="#148">148</a> }
+<a name="149" href="#149">149</a> <strong class="jxr_keyword">break</strong>;
+<a name="150" href="#150">150</a> <strong class="jxr_keyword">case</strong> EQ:
+<a name="151" href="#151">151</a> <strong class="jxr_keyword">if</strong> (comparison == 0) {
+<a name="152" href="#152">152</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="153" href="#153">153</a> }
+<a name="154" href="#154">154</a> <strong class="jxr_keyword">break</strong>;
+<a name="155" href="#155">155</a> <strong class="jxr_keyword">case</strong> GE:
+<a name="156" href="#156">156</a> <strong class="jxr_keyword">if</strong> (comparison >= 0) {
+<a name="157" href="#157">157</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="158" href="#158">158</a> }
+<a name="159" href="#159">159</a> <strong class="jxr_keyword">break</strong>;
+<a name="160" href="#160">160</a> <strong class="jxr_keyword">case</strong> GT:
+<a name="161" href="#161">161</a> <strong class="jxr_keyword">if</strong> (comparison > 0) {
+<a name="162" href="#162">162</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="163" href="#163">163</a> }
+<a name="164" href="#164">164</a> <strong class="jxr_keyword">break</strong>;
+<a name="165" href="#165">165</a> <strong class="jxr_keyword">default</strong>:
+<a name="166" href="#166">166</a> <em class="jxr_comment">// should never get here</em>
+<a name="167" href="#167">167</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> IllegalStateException(<span class="jxr_string">"Unknown comparisonOperator"</span> + comparisonOperator);
+<a name="168" href="#168">168</a> }
+<a name="169" href="#169">169</a> }
+<a name="170" href="#170">170</a> <strong class="jxr_keyword">catch</strong> (NumberFormatException nfe) {
+<a name="171" href="#171">171</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Bad header value found in message: \""</span> + headerArray[0] + <span class="jxr_string">"\""</span>, nfe);
+<a name="172" href="#172">172</a> }
+<a name="173" href="#173">173</a> }
+<a name="174" href="#174">174</a>
+<a name="175" href="#175">175</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="176" href="#176">176</a> }
+<a name="177" href="#177">177</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/FetchedFrom.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/FetchedFrom.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/FetchedFrom.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/FetchedFrom.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>FetchedFrom xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/FetchedFrom.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> javax.mail.internet.MimeMessage;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="29" href="#29">29</a>
+<a name="30" href="#30">30</a> <em class="jxr_javadoccomment">/**</em>
+<a name="31" href="#31">31</a> <em class="jxr_javadoccomment"> * Matches mail with a header set by Fetchpop X-fetched-from <br></em>
+<a name="32" href="#32">32</a> <em class="jxr_javadoccomment"> * fetchpop sets X-fetched-by to the "name" of the fetchpop fetch task.<br></em>
+<a name="33" href="#33">33</a> <em class="jxr_javadoccomment"> * This is used to match all mail fetched from a specific pop account.</em>
+<a name="34" href="#34">34</a> <em class="jxr_javadoccomment"> * Once the condition is met the header is stripped from the message to prevent looping if the mail is re-inserted into the spool.</em>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment"> * </em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * $Id: FetchedFrom.java 426098 2006-07-27 15:10:07Z norman $</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> */</em>
+<a name="38" href="#38">38</a>
+<a name="39" href="#39">39</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/FetchedFrom.html">FetchedFrom</a> <strong class="jxr_keyword">extends</strong> GenericMatcher {
+<a name="40" href="#40">40</a>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment">/**</em>
+<a name="42" href="#42">42</a> <em class="jxr_javadoccomment"> * @see org.apache.mailet.GenericMatcher#match(Mail)</em>
+<a name="43" href="#43">43</a> <em class="jxr_javadoccomment"> */</em>
+<a name="44" href="#44">44</a> <strong class="jxr_keyword">public</strong> Collection match(Mail mail) <strong class="jxr_keyword">throws</strong> javax.mail.MessagingException {
+<a name="45" href="#45">45</a> MimeMessage message = mail.getMessage();
+<a name="46" href="#46">46</a> String fetch = message.getHeader(<span class="jxr_string">"X-fetched-from"</span>, <strong class="jxr_keyword">null</strong>);
+<a name="47" href="#47">47</a> <strong class="jxr_keyword">if</strong> (fetch != <strong class="jxr_keyword">null</strong> && fetch.equals(getCondition())) {
+<a name="48" href="#48">48</a> mail.getMessage().removeHeader(<span class="jxr_string">"X-fetched-from"</span>);
+<a name="49" href="#49">49</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="50" href="#50">50</a> }
+<a name="51" href="#51">51</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="52" href="#52">52</a> }
+<a name="53" href="#53">53</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasAttachment.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasAttachment.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasAttachment.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasAttachment.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,105 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>HasAttachment xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/HasAttachment.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> javax.mail.Multipart;
+<a name="29" href="#29">29</a> <strong class="jxr_keyword">import</strong> javax.mail.Part;
+<a name="30" href="#30">30</a> <strong class="jxr_keyword">import</strong> javax.mail.internet.MimeMessage;
+<a name="31" href="#31">31</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="32" href="#32">32</a>
+<a name="33" href="#33">33</a> <em class="jxr_javadoccomment">/**</em>
+<a name="34" href="#34">34</a> <em class="jxr_javadoccomment"> * Checks whether this message has an attachment</em>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment"> *</em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * @version CVS $Revision: 426007 $ $Date: 2006-07-27 09:52:06 +0100 (Thu, 27 Jul 2006) $</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> */</em>
+<a name="38" href="#38">38</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/HasAttachment.html">HasAttachment</a> <strong class="jxr_keyword">extends</strong> GenericMatcher {
+<a name="39" href="#39">39</a>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment"> </em>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment"> * Either every recipient is matching or neither of them.</em>
+<a name="42" href="#42">42</a> <em class="jxr_javadoccomment"> * @throws MessagingException if no attachment is found and at least one exception was thrown</em>
+<a name="43" href="#43">43</a> <em class="jxr_javadoccomment"> */</em>
+<a name="44" href="#44">44</a> <strong class="jxr_keyword">public</strong> Collection match(Mail mail) <strong class="jxr_keyword">throws</strong> MessagingException {
+<a name="45" href="#45">45</a>
+<a name="46" href="#46">46</a> Exception anException = <strong class="jxr_keyword">null</strong>;
+<a name="47" href="#47">47</a>
+<a name="48" href="#48">48</a> <strong class="jxr_keyword">try</strong> {
+<a name="49" href="#49">49</a> MimeMessage message = mail.getMessage();
+<a name="50" href="#50">50</a> Object content;
+<a name="51" href="#51">51</a>
+<a name="52" href="#52">52</a> <em class="jxr_javadoccomment">/**</em>
+<a name="53" href="#53">53</a> <em class="jxr_javadoccomment"> * if there is an attachment and no inline text,</em>
+<a name="54" href="#54">54</a> <em class="jxr_javadoccomment"> * the content type can be anything</em>
+<a name="55" href="#55">55</a> <em class="jxr_javadoccomment"> */</em>
+<a name="56" href="#56">56</a> <strong class="jxr_keyword">if</strong> (message.getContentType() == <strong class="jxr_keyword">null</strong>) {
+<a name="57" href="#57">57</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="58" href="#58">58</a> }
+<a name="59" href="#59">59</a>
+<a name="60" href="#60">60</a> content = message.getContent();
+<a name="61" href="#61">61</a> <strong class="jxr_keyword">if</strong> (content instanceof Multipart) {
+<a name="62" href="#62">62</a> Multipart multipart = (Multipart) content;
+<a name="63" href="#63">63</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i < multipart.getCount(); i++) {
+<a name="64" href="#64">64</a> <strong class="jxr_keyword">try</strong> {
+<a name="65" href="#65">65</a> Part part = multipart.getBodyPart(i);
+<a name="66" href="#66">66</a> String fileName = part.getFileName();
+<a name="67" href="#67">67</a> <strong class="jxr_keyword">if</strong> (fileName != <strong class="jxr_keyword">null</strong>) {
+<a name="68" href="#68">68</a> <strong class="jxr_keyword">return</strong> mail.getRecipients(); <em class="jxr_comment">// file found</em>
+<a name="69" href="#69">69</a> }
+<a name="70" href="#70">70</a> } <strong class="jxr_keyword">catch</strong> (MessagingException e) {
+<a name="71" href="#71">71</a> anException = e;
+<a name="72" href="#72">72</a> } <em class="jxr_comment">// ignore any messaging exception and process next bodypart</em>
+<a name="73" href="#73">73</a> }
+<a name="74" href="#74">74</a> } <strong class="jxr_keyword">else</strong> {
+<a name="75" href="#75">75</a> String fileName = message.getFileName();
+<a name="76" href="#76">76</a> <strong class="jxr_keyword">if</strong> (fileName != <strong class="jxr_keyword">null</strong>) {
+<a name="77" href="#77">77</a> <strong class="jxr_keyword">return</strong> mail.getRecipients(); <em class="jxr_comment">// file found</em>
+<a name="78" href="#78">78</a> }
+<a name="79" href="#79">79</a> }
+<a name="80" href="#80">80</a> } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a name="81" href="#81">81</a> anException = e;
+<a name="82" href="#82">82</a> }
+<a name="83" href="#83">83</a>
+<a name="84" href="#84">84</a> <em class="jxr_comment">// if no attachment was found and at least one exception was catched rethrow it up</em>
+<a name="85" href="#85">85</a> <strong class="jxr_keyword">if</strong> (anException != <strong class="jxr_keyword">null</strong>) {
+<a name="86" href="#86">86</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Malformed message"</span>, anException);
+<a name="87" href="#87">87</a> }
+<a name="88" href="#88">88</a>
+<a name="89" href="#89">89</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; <em class="jxr_comment">// no attachment found</em>
+<a name="90" href="#90">90</a> }
+<a name="91" href="#91">91</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHabeasWarrantMark.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHabeasWarrantMark.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHabeasWarrantMark.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHabeasWarrantMark.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,141 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>HasHabeasWarrantMark xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/HasHabeasWarrantMark.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> javax.mail.internet.MimeMessage;
+<a name="29" href="#29">29</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="30" href="#30">30</a>
+<a name="31" href="#31">31</a> <em class="jxr_javadoccomment">/**</em>
+<a name="32" href="#32">32</a> <em class="jxr_javadoccomment"> * This matcher tests for the Hebeas Warrant Mark.</em>
+<a name="33" href="#33">33</a> <em class="jxr_javadoccomment"> * For details see: <a href="http://www.hebeas.com" target="alexandria_uri">http://www.hebeas.com</a></em>
+<a name="34" href="#34">34</a> <em class="jxr_javadoccomment"> *</em>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment"> * Usage: Place this matcher</em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> *</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> * <mailet match="HasHabeasWarrantMark" class="ToProcessor"></em>
+<a name="38" href="#38">38</a> <em class="jxr_javadoccomment"> * <processor> transport </processor></em>
+<a name="39" href="#39">39</a> <em class="jxr_javadoccomment"> * </mailet></em>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment"> *</em>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment"> * in the root processs before the DNSRBL block lists (the InSpammerBlacklist matcher).</em>
+<a name="42" href="#42">42</a> <em class="jxr_javadoccomment"> *</em>
+<a name="43" href="#43">43</a> <em class="jxr_javadoccomment"> * Because the Habeas Warrant Mark is copyright material, I have asked for and</em>
+<a name="44" href="#44">44</a> <em class="jxr_javadoccomment"> * received the following explicit statement from Habeas:</em>
+<a name="45" href="#45">45</a> <em class="jxr_javadoccomment"> *</em>
+<a name="46" href="#46">46</a> <em class="jxr_javadoccomment"> * -----------------------------------</em>
+<a name="47" href="#47">47</a> <em class="jxr_javadoccomment"> * From: Lindsey Pettit [<a href="mailto:support@habeas.com" target="alexandria_uri">mailto:support@habeas.com</a>]</em>
+<a name="48" href="#48">48</a> <em class="jxr_javadoccomment"> * Sent: Sunday, September 29, 2002 5:51</em>
+<a name="49" href="#49">49</a> <em class="jxr_javadoccomment"> * To: Noel J. Bergman</em>
+<a name="50" href="#50">50</a> <em class="jxr_javadoccomment"> * Subject: RE: Habeas and Apache James</em>
+<a name="51" href="#51">51</a> <em class="jxr_javadoccomment"> *</em>
+<a name="52" href="#52">52</a> <em class="jxr_javadoccomment"> * Dear Noel,</em>
+<a name="53" href="#53">53</a> <em class="jxr_javadoccomment"> * </em>
+<a name="54" href="#54">54</a> <em class="jxr_javadoccomment"> * > I guess that since your Warrant Mark is copyright, I should ask for</em>
+<a name="55" href="#55">55</a> <em class="jxr_javadoccomment"> * > something from you to explicitly authorize that Hebeas will permit</em>
+<a name="56" href="#56">56</a> <em class="jxr_javadoccomment"> * > this code to be included and distributed as part of Apache James</em>
+<a name="57" href="#57">57</a> <em class="jxr_javadoccomment"> * > under the Apache Software License. As we have established, the use</em>
+<a name="58" href="#58">58</a> <em class="jxr_javadoccomment"> * > of the Habeas Warrant Mark for filtering is not restricted, but I</em>
+<a name="59" href="#59">59</a> <em class="jxr_javadoccomment"> * > would like something to confirm that, so that Apache will be happy.</em>
+<a name="60" href="#60">60</a> <em class="jxr_javadoccomment"> *</em>
+<a name="61" href="#61">61</a> <em class="jxr_javadoccomment"> * I can hereby confirm to you that there is no license necessary in </em>
+<a name="62" href="#62">62</a> <em class="jxr_javadoccomment"> * order to use the Habeas mark for filtering. That said, however, we </em>
+<a name="63" href="#63">63</a> <em class="jxr_javadoccomment"> * do insist that it not ever be used as a basis for rejecting email which </em>
+<a name="64" href="#64">64</a> <em class="jxr_javadoccomment"> * bears the Habeas mark.</em>
+<a name="65" href="#65">65</a> <em class="jxr_javadoccomment"> * -----------------------------------</em>
+<a name="66" href="#66">66</a> <em class="jxr_javadoccomment"> *</em>
+<a name="67" href="#67">67</a> <em class="jxr_javadoccomment"> */</em>
+<a name="68" href="#68">68</a>
+<a name="69" href="#69">69</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/HasHabeasWarrantMark.html">HasHabeasWarrantMark</a> <strong class="jxr_keyword">extends</strong> GenericMatcher
+<a name="70" href="#70">70</a> {
+<a name="71" href="#71">71</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> String[][] warrantMark =
+<a name="72" href="#72">72</a> {
+<a name="73" href="#73">73</a> { <span class="jxr_string">"X-Habeas-SWE-1"</span>, <span class="jxr_string">"winter into spring"</span> },
+<a name="74" href="#74">74</a> { <span class="jxr_string">"X-Habeas-SWE-2"</span>, <span class="jxr_string">"brightly anticipated"</span> },
+<a name="75" href="#75">75</a> { <span class="jxr_string">"X-Habeas-SWE-3"</span>, <span class="jxr_string">"like Habeas SWE (tm)"</span> },
+<a name="76" href="#76">76</a> { <span class="jxr_string">"X-Habeas-SWE-4"</span>, <span class="jxr_string">"Copyright 2002 Habeas (tm)"</span> },
+<a name="77" href="#77">77</a> { <span class="jxr_string">"X-Habeas-SWE-5"</span>, <span class="jxr_string">"Sender Warranted Email (SWE) (tm). The sender of this"</span> },
+<a name="78" href="#78">78</a> { <span class="jxr_string">"X-Habeas-SWE-6"</span>, <span class="jxr_string">"email in exchange for a license for this Habeas"</span> },
+<a name="79" href="#79">79</a> { <span class="jxr_string">"X-Habeas-SWE-7"</span>, <span class="jxr_string">"warrant mark warrants that this is a Habeas Compliant"</span> },
+<a name="80" href="#80">80</a> { <span class="jxr_string">"X-Habeas-SWE-8"</span>, <span class="jxr_string">"Message (HCM) and not spam. Please report use of this"</span> },
+<a name="81" href="#81">81</a> { <span class="jxr_string">"X-Habeas-SWE-9"</span>, <span class="jxr_string">"mark in spam to <http://www.habeas.com/report/>."</span> },
+<a name="82" href="#82">82</a> };
+<a name="83" href="#83">83</a>
+<a name="84" href="#84">84</a> <strong class="jxr_keyword">public</strong> Collection match(Mail mail) <strong class="jxr_keyword">throws</strong> MessagingException
+<a name="85" href="#85">85</a> {
+<a name="86" href="#86">86</a> MimeMessage message = mail.getMessage();
+<a name="87" href="#87">87</a>
+<a name="88" href="#88">88</a> <em class="jxr_comment">//Loop through all the patterns</em>
+<a name="89" href="#89">89</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i < warrantMark.length; i++) <strong class="jxr_keyword">try</strong>
+<a name="90" href="#90">90</a> {
+<a name="91" href="#91">91</a> String headerName = warrantMark[i][0]; <em class="jxr_comment">//Get the header name</em>
+<a name="92" href="#92">92</a> String requiredValue = warrantMark[i][1]; <em class="jxr_comment">//Get the required value</em>
+<a name="93" href="#93">93</a> String headerValue = message.getHeader(headerName, <strong class="jxr_keyword">null</strong>); <em class="jxr_comment">//Get the header value(s)</em>
+<a name="94" href="#94">94</a>
+<a name="95" href="#95">95</a> <em class="jxr_comment">// We want an exact match, so only test the first value.</em>
+<a name="96" href="#96">96</a> <em class="jxr_comment">// If there are multiple values, the header may be</em>
+<a name="97" href="#97">97</a> <em class="jxr_comment">// (illegally) forged. I'll leave it as an exercise to</em>
+<a name="98" href="#98">98</a> <em class="jxr_comment">// others if they want to detect and report potentially</em>
+<a name="99" href="#99">99</a> <em class="jxr_comment">// forged headers.</em>
+<a name="100" href="#100">100</a>
+<a name="101" href="#101">101</a> <strong class="jxr_keyword">if</strong> (!(requiredValue.equals(headerValue))) <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="102" href="#102">102</a> }
+<a name="103" href="#103">103</a> <strong class="jxr_keyword">catch</strong> (Exception e)
+<a name="104" href="#104">104</a> {
+<a name="105" href="#105">105</a> log(e.toString());
+<a name="106" href="#106">106</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; <em class="jxr_comment">//if we get an exception, don't validate the mark</em>
+<a name="107" href="#107">107</a> }
+<a name="108" href="#108">108</a>
+<a name="109" href="#109">109</a> <em class="jxr_comment">// If we get here, all headers are present and match.</em>
+<a name="110" href="#110">110</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="111" href="#111">111</a> }
+<a name="112" href="#112">112</a>
+<a name="113" href="#113">113</a> <em class="jxr_comment">/*</em>
+<a name="114" href="#114">114</a> <em class="jxr_comment"> * Returns information about the matcher, such as author, version, and copyright.</em>
+<a name="115" href="#115">115</a> <em class="jxr_comment"> * <p></em>
+<a name="116" href="#116">116</a> <em class="jxr_comment"> * The string that this method returns should be plain text and not markup</em>
+<a name="117" href="#117">117</a> <em class="jxr_comment"> * of any kind (such as HTML, XML, etc.).</em>
+<a name="118" href="#118">118</a> <em class="jxr_comment"> *</em>
+<a name="119" href="#119">119</a> <em class="jxr_comment"> * @return a String containing matcher information</em>
+<a name="120" href="#120">120</a> <em class="jxr_comment"> */</em>
+<a name="121" href="#121">121</a>
+<a name="122" href="#122">122</a> <strong class="jxr_keyword">public</strong> String getMatcherInfo()
+<a name="123" href="#123">123</a> {
+<a name="124" href="#124">124</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"Habeas Warrant Mark Matcher (see http://www.habeas.com for details)."</span>;
+<a name="125" href="#125">125</a> }
+<a name="126" href="#126">126</a> }
+<a name="127" href="#127">127</a>
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHeader.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHeader.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHeader.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasHeader.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,130 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>HasHeader xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/HasHeader.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="26" href="#26">26</a>
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> java.util.Iterator;
+<a name="29" href="#29">29</a> <strong class="jxr_keyword">import</strong> java.util.LinkedList;
+<a name="30" href="#30">30</a> <strong class="jxr_keyword">import</strong> java.util.StringTokenizer;
+<a name="31" href="#31">31</a>
+<a name="32" href="#32">32</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="33" href="#33">33</a> <strong class="jxr_keyword">import</strong> javax.mail.internet.MimeMessage;
+<a name="34" href="#34">34</a>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment">/**</em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * use: <mailet match="{<header>[=value]}+" class="..." /></em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> * </em>
+<a name="38" href="#38">38</a> <em class="jxr_javadoccomment"> * This matcher checks if the header named is present. If complements the</em>
+<a name="39" href="#39">39</a> <em class="jxr_javadoccomment"> * AddHeader mailet.</em>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment"> */</em>
+<a name="41" href="#41">41</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/HasHeader.html">HasHeader</a> <strong class="jxr_keyword">extends</strong> GenericMatcher {
+<a name="42" href="#42">42</a>
+<a name="43" href="#43">43</a> <strong class="jxr_keyword">private</strong> LinkedList conditionline_ = <strong class="jxr_keyword">new</strong> LinkedList();
+<a name="44" href="#44">44</a>
+<a name="45" href="#45">45</a> <em class="jxr_comment">// set headernames and values</em>
+<a name="46" href="#46">46</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> init() <strong class="jxr_keyword">throws</strong> MessagingException {
+<a name="47" href="#47">47</a> StringTokenizer st = <strong class="jxr_keyword">new</strong> StringTokenizer(getCondition(), <span class="jxr_string">"+"</span>);
+<a name="48" href="#48">48</a> conditionline_ = <strong class="jxr_keyword">new</strong> LinkedList();
+<a name="49" href="#49">49</a>
+<a name="50" href="#50">50</a> <em class="jxr_comment">// separates the headernames from the matchline</em>
+<a name="51" href="#51">51</a> <strong class="jxr_keyword">while</strong> (st.hasMoreTokens()) {
+<a name="52" href="#52">52</a> String condition = st.nextToken().trim();
+<a name="53" href="#53">53</a> conditionline_.add(condition);
+<a name="54" href="#54">54</a> }
+<a name="55" href="#55">55</a> }
+<a name="56" href="#56">56</a>
+<a name="57" href="#57">57</a> <strong class="jxr_keyword">public</strong> Collection match(Mail mail) <strong class="jxr_keyword">throws</strong> javax.mail.MessagingException {
+<a name="58" href="#58">58</a> <strong class="jxr_keyword">boolean</strong> match = false;
+<a name="59" href="#59">59</a> MimeMessage message = (MimeMessage) mail.getMessage();
+<a name="60" href="#60">60</a>
+<a name="61" href="#61">61</a>
+<a name="62" href="#62">62</a> header:
+<a name="63" href="#63">63</a> <em class="jxr_comment">// goes through the headernames one by one</em>
+<a name="64" href="#64">64</a> <strong class="jxr_keyword">for</strong> (Iterator it=conditionline_.iterator(); it.hasNext(); ) {
+<a name="65" href="#65">65</a> String element = (String)it.next();
+<a name="66" href="#66">66</a> StringTokenizer st = <strong class="jxr_keyword">new</strong> StringTokenizer(element, <span class="jxr_string">"="</span>, false);
+<a name="67" href="#67">67</a> String header = <strong class="jxr_keyword">new</strong> String();
+<a name="68" href="#68">68</a>
+<a name="69" href="#69">69</a> <em class="jxr_comment">// read the headername</em>
+<a name="70" href="#70">70</a> <strong class="jxr_keyword">if</strong> (st.hasMoreTokens()) {
+<a name="71" href="#71">71</a> header = st.nextToken().trim();
+<a name="72" href="#72">72</a> } <strong class="jxr_keyword">else</strong> {
+<a name="73" href="#73">73</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MessagingException(<span class="jxr_string">"Missing headerName"</span>);
+<a name="74" href="#74">74</a> }
+<a name="75" href="#75">75</a>
+<a name="76" href="#76">76</a> <em class="jxr_comment">// try to read headervalue</em>
+<a name="77" href="#77">77</a> String headerValue = <strong class="jxr_keyword">new</strong> String();
+<a name="78" href="#78">78</a> <strong class="jxr_keyword">if</strong> (st.hasMoreTokens()) {
+<a name="79" href="#79">79</a> headerValue = st.nextToken().trim();
+<a name="80" href="#80">80</a> } <strong class="jxr_keyword">else</strong> {
+<a name="81" href="#81">81</a> headerValue = <strong class="jxr_keyword">null</strong>;
+<a name="82" href="#82">82</a> }
+<a name="83" href="#83">83</a>
+<a name="84" href="#84">84</a> <em class="jxr_comment">// find headername in Mailheaders</em>
+<a name="85" href="#85">85</a> String [] headerArray = message.getHeader(header);
+<a name="86" href="#86">86</a> <strong class="jxr_keyword">if</strong> (headerArray != <strong class="jxr_keyword">null</strong> && headerArray.length > 0) {
+<a name="87" href="#87">87</a> <em class="jxr_comment">// if there is the headername specified without the headervalue</em>
+<a name="88" href="#88">88</a> <em class="jxr_comment">// only the existence of the headername ist performed</em>
+<a name="89" href="#89">89</a> <strong class="jxr_keyword">if</strong> (headerValue != <strong class="jxr_keyword">null</strong>) {
+<a name="90" href="#90">90</a> <em class="jxr_comment">//</em>
+<a name="91" href="#91">91</a> <strong class="jxr_keyword">if</strong> (headerArray[0].trim().equalsIgnoreCase(headerValue)) {
+<a name="92" href="#92">92</a> <em class="jxr_comment">// headername and value found and match to the condition</em>
+<a name="93" href="#93">93</a> match = <strong class="jxr_keyword">true</strong>;
+<a name="94" href="#94">94</a> } <strong class="jxr_keyword">else</strong> {
+<a name="95" href="#95">95</a> <em class="jxr_comment">// headername and value found but the value does not match the condition</em>
+<a name="96" href="#96">96</a> match = false;
+<a name="97" href="#97">97</a> <em class="jxr_comment">// if one condition fails the matcher returns false</em>
+<a name="98" href="#98">98</a> <strong class="jxr_keyword">break</strong> header;
+<a name="99" href="#99">99</a> };
+<a name="100" href="#100">100</a> } <strong class="jxr_keyword">else</strong> {
+<a name="101" href="#101">101</a> <em class="jxr_comment">// just the headername is specified</em>
+<a name="102" href="#102">102</a> match = <strong class="jxr_keyword">true</strong>;
+<a name="103" href="#103">103</a> }
+<a name="104" href="#104">104</a> } <strong class="jxr_keyword">else</strong> {
+<a name="105" href="#105">105</a> <em class="jxr_comment">// no headername is found</em>
+<a name="106" href="#106">106</a> match = false;
+<a name="107" href="#107">107</a> <em class="jxr_comment">// if one condition fails the matcher returns false</em>
+<a name="108" href="#108">108</a> <strong class="jxr_keyword">break</strong> header;
+<a name="109" href="#109">109</a> }
+<a name="110" href="#110">110</a> }
+<a name="111" href="#111">111</a>
+<a name="112" href="#112">112</a> <strong class="jxr_keyword">return</strong> (match) ? mail.getRecipients() : <strong class="jxr_keyword">null</strong>;
+<a name="113" href="#113">113</a>
+<a name="114" href="#114">114</a> }
+<a name="115" href="#115">115</a> }
+<a name="116" href="#116">116</a>
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+
Added: james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasMailAttribute.html
URL: http://svn.apache.org/viewvc/james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasMailAttribute.html?rev=688320&view=auto
==============================================================================
--- james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasMailAttribute.html (added)
+++ james/site/trunk/www/mailet/standard/xref/org/apache/james/transport/matchers/HasMailAttribute.html Sat Aug 23 06:40:23 2008
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
+<title>HasMailAttribute xref</title>
+<link type="text/css" rel="stylesheet" href="../../../../../stylesheet.css" />
+</head>
+<body>
+<div id="overview"><a href="../../../../../../apidocs/org/apache/james/transport/matchers/HasMailAttribute.html">View Javadoc</a></div><pre>
+
+<a name="1" href="#1">1</a> <em class="jxr_javadoccomment">/**</em><em class="jxr_javadoccomment">**************************************************************</em>
+<a name="2" href="#2">2</a> <em class="jxr_javadoccomment"> * Licensed to the Apache Software Foundation (ASF) under one *</em>
+<a name="3" href="#3">3</a> <em class="jxr_javadoccomment"> * or more contributor license agreements. See the NOTICE file *</em>
+<a name="4" href="#4">4</a> <em class="jxr_javadoccomment"> * distributed with this work for additional information *</em>
+<a name="5" href="#5">5</a> <em class="jxr_javadoccomment"> * regarding copyright ownership. The ASF licenses this file *</em>
+<a name="6" href="#6">6</a> <em class="jxr_javadoccomment"> * to you under the Apache License, Version 2.0 (the *</em>
+<a name="7" href="#7">7</a> <em class="jxr_javadoccomment"> * "License"); you may not use this file except in compliance *</em>
+<a name="8" href="#8">8</a> <em class="jxr_javadoccomment"> * with the License. You may obtain a copy of the License at *</em>
+<a name="9" href="#9">9</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="10" href="#10">10</a> <em class="jxr_javadoccomment"> * <a href="http://www.apache.org/licenses/LICENSE-2.0" target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.0</a> *</em>
+<a name="11" href="#11">11</a> <em class="jxr_javadoccomment"> * *</em>
+<a name="12" href="#12">12</a> <em class="jxr_javadoccomment"> * Unless required by applicable law or agreed to in writing, *</em>
+<a name="13" href="#13">13</a> <em class="jxr_javadoccomment"> * software distributed under the License is distributed on an *</em>
+<a name="14" href="#14">14</a> <em class="jxr_javadoccomment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *</em>
+<a name="15" href="#15">15</a> <em class="jxr_javadoccomment"> * KIND, either express or implied. See the License for the *</em>
+<a name="16" href="#16">16</a> <em class="jxr_javadoccomment"> * specific language governing permissions and limitations *</em>
+<a name="17" href="#17">17</a> <em class="jxr_javadoccomment"> * under the License. *</em>
+<a name="18" href="#18">18</a> <em class="jxr_javadoccomment"> ****************************************************************/</em>
+<a name="19" href="#19">19</a>
+<a name="20" href="#20">20</a>
+<a name="21" href="#21">21</a>
+<a name="22" href="#22">22</a> <strong class="jxr_keyword">package</strong> org.apache.james.transport.matchers;
+<a name="23" href="#23">23</a>
+<a name="24" href="#24">24</a>
+<a name="25" href="#25">25</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.GenericMatcher;
+<a name="26" href="#26">26</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.Mail;
+<a name="27" href="#27">27</a> <strong class="jxr_keyword">import</strong> org.apache.mailet.MatcherConfig;
+<a name="28" href="#28">28</a> <strong class="jxr_keyword">import</strong> java.util.Collection;
+<a name="29" href="#29">29</a> <strong class="jxr_keyword">import</strong> javax.mail.MessagingException;
+<a name="30" href="#30">30</a>
+<a name="31" href="#31">31</a> <em class="jxr_javadoccomment">/**</em>
+<a name="32" href="#32">32</a> <em class="jxr_javadoccomment"> * <P>This Matcher determines if the mail contains the attribute specified in the</em>
+<a name="33" href="#33">33</a> <em class="jxr_javadoccomment"> * condition, and returns all recipients if it is the case.</P></em>
+<a name="34" href="#34">34</a> <em class="jxr_javadoccomment"> * <P>Sample configuration:</P></em>
+<a name="35" href="#35">35</a> <em class="jxr_javadoccomment"> * <PRE><CODE></em>
+<a name="36" href="#36">36</a> <em class="jxr_javadoccomment"> * &lt;mailet match="HasMailAttribute=whatever" class=&quot;&lt;any-class&gt;&quot;&gt;</em>
+<a name="37" href="#37">37</a> <em class="jxr_javadoccomment"> * </CODE></PRE></em>
+<a name="38" href="#38">38</a> <em class="jxr_javadoccomment"> *</em>
+<a name="39" href="#39">39</a> <em class="jxr_javadoccomment"> * @version CVS $Revision: 426007 $ $Date: 2006-07-27 09:52:06 +0100 (Thu, 27 Jul 2006) $</em>
+<a name="40" href="#40">40</a> <em class="jxr_javadoccomment"> * @since 2.2.0</em>
+<a name="41" href="#41">41</a> <em class="jxr_javadoccomment"> **/</em>
+<a name="42" href="#42">42</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/james/transport/matchers/HasMailAttribute.html">HasMailAttribute</a> <strong class="jxr_keyword">extends</strong> GenericMatcher
+<a name="43" href="#43">43</a> {
+<a name="44" href="#44">44</a>
+<a name="45" href="#45">45</a> <strong class="jxr_keyword">private</strong> String attributeName;
+<a name="46" href="#46">46</a>
+<a name="47" href="#47">47</a> <em class="jxr_javadoccomment">/**</em>
+<a name="48" href="#48">48</a> <em class="jxr_javadoccomment"> * Return a string describing this matcher.</em>
+<a name="49" href="#49">49</a> <em class="jxr_javadoccomment"> *</em>
+<a name="50" href="#50">50</a> <em class="jxr_javadoccomment"> * @return a string describing this matcher</em>
+<a name="51" href="#51">51</a> <em class="jxr_javadoccomment"> */</em>
+<a name="52" href="#52">52</a> <strong class="jxr_keyword">public</strong> String getMatcherInfo() {
+<a name="53" href="#53">53</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"Has Mail Attribute Matcher"</span>;
+<a name="54" href="#54">54</a> }
+<a name="55" href="#55">55</a>
+<a name="56" href="#56">56</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> init (MatcherConfig conf) <strong class="jxr_keyword">throws</strong> MessagingException
+<a name="57" href="#57">57</a> {
+<a name="58" href="#58">58</a> attributeName = conf.getCondition();
+<a name="59" href="#59">59</a> }
+<a name="60" href="#60">60</a>
+<a name="61" href="#61">61</a> <em class="jxr_javadoccomment">/**</em>
+<a name="62" href="#62">62</a> <em class="jxr_javadoccomment"> * @param mail the mail to check.</em>
+<a name="63" href="#63">63</a> <em class="jxr_javadoccomment"> * @return all recipients if the condition is the name of an attribute</em>
+<a name="64" href="#64">64</a> <em class="jxr_javadoccomment"> * set on the mail</em>
+<a name="65" href="#65">65</a> <em class="jxr_javadoccomment"> *</em>
+<a name="66" href="#66">66</a> <em class="jxr_javadoccomment"> **/</em>
+<a name="67" href="#67">67</a> <strong class="jxr_keyword">public</strong> Collection match (Mail mail) <strong class="jxr_keyword">throws</strong> MessagingException
+<a name="68" href="#68">68</a> {
+<a name="69" href="#69">69</a> <strong class="jxr_keyword">if</strong> (mail.getAttribute (attributeName) != <strong class="jxr_keyword">null</strong>) {
+<a name="70" href="#70">70</a> <strong class="jxr_keyword">return</strong> mail.getRecipients();
+<a name="71" href="#71">71</a> }
+<a name="72" href="#72">72</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="73" href="#73">73</a> }
+<a name="74" href="#74">74</a>
+<a name="75" href="#75">75</a> }
+</pre>
+<hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
+</html>
+