View Javadoc
1   package org.apache.maven.plugin.jira;
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.plugin.MojoExecutionException;
23  import org.apache.maven.plugin.issues.Issue;
24  
25  import java.util.List;
26  
27  /**
28   * Jira downloader that uses REST or RSS, depending. This code is not very attractive. However, JIRA has supported REST
29   * for a very long time, and so the fallback is only relevant for people with very old copies of JIRA.
30   */
31  public class AdaptiveJiraDownloader
32      extends AbstractJiraDownloader
33  {
34      private AbstractJiraDownloader effectiveDownloader;
35  
36      private boolean forceClassic;
37  
38      public void doExecute()
39          throws Exception
40      {
41          effectiveDownloader = new RestJiraDownloader();
42          copySettings( effectiveDownloader );
43          try
44          {
45              effectiveDownloader.doExecute();
46          }
47          catch ( RestJiraDownloader.NoRest nre )
48          {
49              getLog().info( "Falling back to RSS for issue download: " + nre.getMessage() );
50              effectiveDownloader = new ClassicJiraDownloader();
51              copySettings( effectiveDownloader );
52              effectiveDownloader.doExecute();
53          }
54      }
55  
56      private void copySettings( AbstractJiraDownloader target )
57      {
58          target.setLog( getLog() );
59          target.setMavenProject( project );
60          target.setOutput( output );
61          target.setNbEntries( nbEntriesMax );
62          target.setComponent( component );
63          target.setFixVersionIds( fixVersionIds );
64          target.setStatusIds( statusIds );
65          target.setResolutionIds( resolutionIds );
66          target.setPriorityIds( priorityIds );
67          target.setSortColumnNames( sortColumnNames );
68          target.setFilter( filter );
69          target.setJiraDatePattern( jiraDatePattern );
70          target.setJiraUser( jiraUser );
71          target.setJiraPassword( jiraPassword );
72          target.setTypeIds( typeIds );
73          target.setWebUser( webUser );
74          target.setWebPassword( webPassword );
75          target.setSettings( settings );
76          target.setUseJql( useJql );
77          target.setOnlyCurrentVersion( onlyCurrentVersion );
78          target.setVersionPrefix( versionPrefix );
79          target.setConnectionTimeout( connectionTimeout );
80          target.setReceiveTimout( receiveTimout );
81      }
82  
83      public List<Issue> getIssueList()
84          throws MojoExecutionException
85      {
86          return effectiveDownloader.getIssueList();
87      }
88  
89      public boolean isForceClassic()
90      {
91          return forceClassic;
92      }
93  
94      public void setForceClassic( boolean forceClassic )
95      {
96          this.forceClassic = forceClassic;
97      }
98  }