View Javadoc
1   package org.apache.maven.plugin.issues;
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 java.util.HashMap;
23  import java.util.Map;
24  
25  import org.apache.maven.plugin.MojoExecutionException;
26  import org.apache.maven.plugin.changes.IssueType;
27  
28  /**
29   * Historically, this plugin started out working against an IMS-neutral XML file, and then added extensive support for
30   * JIRA with some small snippets of code for other issue management systems. This class is intended to start a cleaner
31   * modularity for support of multiple systems.<br>
32   * Initially, all it provides is a structure for mapping from per-IMS issue types to the three categories defined in
33   * {@link org.apache.maven.plugin.changes.IssueAdapter}. <br/>
34   * Note that the map in here is <strong>not</strong> immutable. It contains the default configuration for an IMS. Users
35   * are expected to add entries to the map via configuration to reflect their customizations.
36   *
37   * @version $Id: AbstractIssueManagementSystem.java 1685894 2015-06-16 19:29:09Z khmarbaise $
38   */
39  public abstract class AbstractIssueManagementSystem
40      implements IssueManagementSystem
41  {
42      protected Map<String, IssueType> issueTypeMap;
43  
44      protected AbstractIssueManagementSystem()
45      {
46          issueTypeMap = new HashMap<String, IssueType>();
47      }
48  
49      /*
50       * (non-Javadoc)
51       * @see org.apache.maven.plugin.issues.IssueManagementSystem#getIssueTypeMap()
52       */
53      public Map<String, IssueType> getIssueTypeMap()
54      {
55          return issueTypeMap;
56      }
57  
58      /*
59       * (non-Javadoc)
60       * @see org.apache.maven.plugin.issues.IssueManagementSystem#getName()
61       */
62      public abstract String getName();
63  
64      /*
65       * (non-Javadoc)
66       * @see org.apache.maven.plugin.issues.IssueManagementSystem#applyConfiguration(java.util.Map)
67       */
68      public void applyConfiguration( Map<String, String> issueTypes )
69          throws MojoExecutionException
70      {
71          for ( Map.Entry<String, String> me : issueTypes.entrySet() )
72          {
73              IssueType type = IssueType.lookupByKey( me.getKey() );
74              if ( type == null )
75              {
76                  throw new MojoExecutionException( "Invalid issue action " + me.getKey() );
77              }
78              String imsTypes = me.getValue();
79              String[] imsTypeArray = imsTypes.split( "," );
80              for ( String imsType : imsTypeArray )
81              {
82                  issueTypeMap.put( imsType, type );
83              }
84          }
85      }
86  }