View Javadoc

1   package org.apache.maven.continuum.web.action.notifier;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.continuum.model.project.ProjectGroup;
23  import org.apache.maven.continuum.model.project.ProjectNotifier;
24  import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
25  import org.codehaus.plexus.util.StringUtils;
26  
27  import java.util.HashMap;
28  import java.util.Map;
29  
30  /**
31   * Action that edits a {@link ProjectNotifier} of type 'Mail' from the
32   * specified {@link ProjectGroup}.
33   *
34   * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
35   * @version $Id: MailGroupNotifierEditAction.java 1372260 2012-08-13 04:29:09Z brett $
36   * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="mailGroupNotifierEdit"
37   * @since 1.1
38   */
39  public class MailGroupNotifierEditAction
40      extends AbstractGroupNotifierEditAction
41  {
42      private String address;
43  
44      private boolean committers;
45  
46      private boolean developers;
47  
48      protected void initConfiguration( Map<String, String> configuration )
49      {
50          if ( StringUtils.isNotEmpty( configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD ) ) )
51          {
52              address = configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD );
53          }
54  
55          if ( StringUtils.isNotEmpty( configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) ) )
56          {
57              committers = Boolean.parseBoolean( configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) );
58          }
59  
60          if ( StringUtils.isNotEmpty( configuration.get( AbstractContinuumNotifier.DEVELOPER_FIELD ) ) )
61          {
62              developers = Boolean.parseBoolean( configuration.get( AbstractContinuumNotifier.DEVELOPER_FIELD ) );
63          }
64      }
65  
66      protected void setNotifierConfiguration( ProjectNotifier notifier )
67      {
68          HashMap<String, Object> configuration = new HashMap<String, Object>();
69  
70          if ( StringUtils.isNotEmpty( address ) )
71          {
72              configuration.put( AbstractContinuumNotifier.ADDRESS_FIELD, address );
73          }
74  
75          configuration.put( AbstractContinuumNotifier.COMMITTER_FIELD, String.valueOf( committers ) );
76  
77          configuration.put( AbstractContinuumNotifier.DEVELOPER_FIELD, String.valueOf( developers ) );
78  
79          notifier.setConfiguration( configuration );
80      }
81  
82      public String getAddress()
83      {
84          return address;
85      }
86  
87      public void setAddress( String address )
88      {
89          this.address = address;
90      }
91  
92      public boolean isCommitters()
93      {
94          return committers;
95      }
96  
97      public void setCommitters( boolean committers )
98      {
99          this.committers = committers;
100     }
101 
102     public boolean isDevelopers()
103     {
104         return developers;
105     }
106 
107     public void setDevelopers( boolean developers )
108     {
109         this.developers = developers;
110     }
111 }