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
35 * configuration for an IMS. Users are expected to add entries to the map via configuration
36 * to reflect their customizations.
37 *
38 * @version $Id: AbstractIssueManagementSystem.java 1379901 2012-09-01 23:44:49Z dennisl $
39 */
40 public abstract class AbstractIssueManagementSystem
41 implements IssueManagementSystem
42 {
43 protected Map<String, IssueType> issueTypeMap;
44
45 protected AbstractIssueManagementSystem()
46 {
47 issueTypeMap = new HashMap<String, IssueType>();
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 /* (non-Javadoc)
59 * @see org.apache.maven.plugin.issues.IssueManagementSystem#getName()
60 */
61 public abstract String getName();
62
63 /* (non-Javadoc)
64 * @see org.apache.maven.plugin.issues.IssueManagementSystem#applyConfiguration(java.util.Map)
65 */
66 public void applyConfiguration( Map<String, String> issueTypes )
67 throws MojoExecutionException
68 {
69 for ( Map.Entry<String, String> me : issueTypes.entrySet() )
70 {
71 IssueType type = IssueType.lookupByKey( me.getKey() );
72 if ( type == null )
73 {
74 throw new MojoExecutionException( "Invalid issue action " + me.getKey() );
75 }
76 String imsTypes = me.getValue();
77 String[] imsTypeArray = imsTypes.split( "," );
78 for ( String imsType : imsTypeArray )
79 {
80 issueTypeMap.put( imsType, type );
81 }
82 }
83 }
84 }