View Javadoc

1   /*
2    * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.maven.bugzilla;
17  
18  import org.apache.commons.lang.StringUtils;
19  import org.apache.maven.plugin.MojoExecutionException;
20  import org.apache.maven.plugin.MojoFailureException;
21  import org.apache.maven.project.MavenProject;
22  
23  import de.smartics.maven.bugzilla.AbstractMojoHelperProduct.ProductInfo;
24  
25  /**
26   * Updates a product on the issue management server with information from this
27   * project.
28   *
29   * @goal updateProduct
30   * @requiresProject
31   * @threadSafe
32   * @since 1.0
33   * @description Updates a product on the issue management server with
34   *              information from this project.
35   */
36  public class UpdateProductMojo extends AbstractProductMojo
37  {
38    // ********************************* Fields *********************************
39  
40    // --- constants ------------------------------------------------------------
41  
42    // --- members --------------------------------------------------------------
43  
44    /**
45     * The old name to select the product on the server. Differs only from
46     * <code>product</code> if the name has changed.
47     *
48     * @parameter expression="${oldProduct}" default-value="${project.artifactId}"
49     * @since 1.0
50     */
51    protected String oldProduct;
52  
53    // ****************************** Initializer *******************************
54  
55    // ****************************** Constructors ******************************
56  
57    // ****************************** Inner Classes *****************************
58  
59    // ********************************* Methods ********************************
60  
61    // --- init -----------------------------------------------------------------
62  
63    // --- get&set --------------------------------------------------------------
64  
65    // --- business -------------------------------------------------------------
66  
67    // CHECKSTYLE:OFF
68    /**
69     * {@inheritDoc}
70     */
71    public void run() throws MojoExecutionException, MojoFailureException
72    {
73      // CHECKSTYLE:ON
74      final ProductInfo productInfo = createProductInfo();
75  
76      final MavenProject project = getProject();
77      final MojoHelperProductUpdate helper =
78          new MojoHelperProductUpdate(project, commandFactory, console,
79              productInfo);
80  
81      final String oldProduct = getOldProduct();
82      helper.execute(oldProduct);
83    }
84  
85    /**
86     * Returns the name of the old product in case the name of the product has
87     * changed. If the product name has not changed, this method returns the same
88     * name as {@link #getProduct()}.
89     *
90     * @return the name of the old product in case the name of the product has
91     *         changed.
92     */
93    protected final String getOldProduct()
94    {
95      if (StringUtils.isNotBlank(oldProduct))
96      {
97        return oldProduct;
98      }
99      return getProduct();
100   }
101 
102   // --- object basics --------------------------------------------------------
103 
104 }