1   package com.atlassian.maven.plugins.amps;
2   
3   import com.atlassian.maven.plugins.amps.product.ProductHandlerFactory;
4   import org.apache.maven.plugin.MojoExecutionException;
5   import org.jfrog.maven.annomojo.annotations.MojoParameter;
6   
7   public abstract class AbstractProductAwareMojo extends AbstractAmpsMojo
8   {
9       /**
10       * Product id
11       */
12      @MojoParameter(expression = "${product}")
13      private String product;
14  
15      /**
16       * Instance to run. If provided, used to determine the product to use, instead of
17       * using the product ID.
18       */
19      @MojoParameter(expression = "${instanceId}")
20      protected String instanceId;
21  
22  
23      protected String getDefaultProductId() throws MojoExecutionException
24      {
25          return null;
26      }
27  
28      protected final String getProductId() throws MojoExecutionException
29      {
30          if (product == null)
31          {
32              product = getDefaultProductId();
33              if (product == null && ProductHandlerFactory.getIds().contains(getPluginInformation().getId()))
34              {
35                  product = getPluginInformation().getId();
36              }
37              else if (product == null)
38              {
39                  product = ProductHandlerFactory.REFAPP;
40              }
41          }
42          return product;
43      }
44  }