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 public abstract class AbstractIssueManagementSystem 39 implements IssueManagementSystem 40 { 41 protected Map<String, IssueType> issueTypeMap; 42 43 protected AbstractIssueManagementSystem() 44 { 45 issueTypeMap = new HashMap<String, IssueType>(); 46 } 47 48 /* (non-Javadoc) 49 * @see org.apache.maven.plugin.issues.IssueManagementSystem#getIssueTypeMap() 50 */ 51 public Map<String, IssueType> getIssueTypeMap() 52 { 53 return issueTypeMap; 54 } 55 56 /* (non-Javadoc) 57 * @see org.apache.maven.plugin.issues.IssueManagementSystem#getName() 58 */ 59 public abstract String getName(); 60 61 /* (non-Javadoc) 62 * @see org.apache.maven.plugin.issues.IssueManagementSystem#applyConfiguration(java.util.Map) 63 */ 64 public void applyConfiguration( Map<String, String> issueTypes ) 65 throws MojoExecutionException 66 { 67 for ( Map.Entry<String, String> me : issueTypes.entrySet() ) 68 { 69 IssueType type = IssueType.lookupByKey( me.getValue() ); 70 if ( type == null ) 71 { 72 throw new MojoExecutionException( "Invalid issue action " + me.getValue() ); 73 } 74 String imsTypes = me.getKey(); 75 String[] imsTypeArray = imsTypes.split( "," ); 76 for ( String imsType : imsTypeArray ) 77 { 78 issueTypeMap.put( imsType, type ); 79 } 80 } 81 } 82 }