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