View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.jsieve.commands;
21  
22  import org.apache.jsieve.Arguments;
23  import org.apache.jsieve.Block;
24  import org.apache.jsieve.SieveContext;
25  import org.apache.jsieve.StringListArgument;
26  import org.apache.jsieve.exception.SieveException;
27  import org.apache.jsieve.mail.ActionRedirect;
28  import org.apache.jsieve.mail.MailAdapter;
29  
30  /**
31   * Class Redirect implements the Redirect Command as defined in RFC 3028,
32   * section 4.3.
33   */
34  public class Redirect extends AbstractActionCommand {
35  
36      /**
37       * Constructor for Redirect.
38       */
39      public Redirect() {
40          super();
41      }
42  
43      /**
44       * <p>
45       * Add an ActionRedirect to the List of Actions to be performed passing the
46       * sole StringList argument as the recipient.
47       * </p>
48       * <p>
49       * Also,
50       * 
51       * @see org.apache.jsieve.commands.AbstractCommand#executeBasic(MailAdapter,
52       *      Arguments, Block, SieveContext)
53       *      </p>
54       */
55      protected Object executeBasic(MailAdapter mail, Arguments arguments,
56              Block block, SieveContext context) throws SieveException {
57          String recipient = ((StringListArgument) arguments
58                  .getArgumentList().get(0)).getList().get(0);
59  
60          mail.addAction(new ActionRedirect(recipient));
61  
62          return null;
63      }
64  
65      /**
66       * @see org.apache.jsieve.commands.AbstractCommand#validateArguments(Arguments,
67       *      SieveContext)
68       */
69      protected void validateArguments(Arguments arguments, SieveContext context)
70              throws SieveException {
71          validateSingleStringArguments(arguments, context);
72      }
73  
74  }