1   package com.atlassian.maven.plugins.amps.product;
2   
3   import com.atlassian.maven.plugins.amps.Product;
4   import com.atlassian.maven.plugins.amps.ProductArtifact;
5   
6   import java.util.List;
7   import java.util.ArrayList;
8   import java.util.Arrays;
9   import java.util.Collection;
10  import java.util.Collections;
11  
12  public abstract class AbstractPluginProvider implements PluginProvider
13  {
14      public final List<ProductArtifact> provide(Product product)
15      {
16          final List<ProductArtifact> artifacts = new ArrayList<ProductArtifact>();
17          artifacts.addAll(product.getPluginArtifacts());
18  
19          if (product.getSalVersion() != null)
20          {
21              artifacts.addAll(getSalArtifacts(product.getSalVersion()));
22          }
23  
24          if (product.getPdkVersion() != null)
25          {
26              artifacts.addAll(getPdkInstallArtifacts(product.getPdkVersion()));
27          }
28  
29          if (product.getRestVersion() != null)
30          {
31              artifacts.addAll(getRestArtifacts(product.getRestVersion()));
32          }
33  
34          if (product.getWebConsoleVersion() != null)
35          {
36              artifacts.addAll(getWebConsoleArtifacts(product.getWebConsoleVersion()));
37          }
38  
39          return artifacts;
40      }
41  
42      protected abstract Collection<ProductArtifact> getSalArtifacts(String salVersion);
43  
44      protected Collection<ProductArtifact> getPdkInstallArtifacts(String pdkInstallVersion)
45      {
46          return Collections.singletonList(new ProductArtifact("com.atlassian.pdkinstall", "pdkinstall-plugin", pdkInstallVersion));
47      }
48  
49      protected Collection<ProductArtifact> getWebConsoleArtifacts(String webConsoleVersion)
50      {
51          return Arrays.asList(
52                  new ProductArtifact("org.apache.felix", "org.apache.felix.webconsole", webConsoleVersion),
53                  new ProductArtifact("org.apache.felix", "org.osgi.compendium", "1.2.0"),
54                  new ProductArtifact("com.atlassian.labs.httpservice", "httpservice-bridge", "0.6.1")
55                  );
56      }
57  
58      protected Collection<ProductArtifact> getRestArtifacts(String restVersion)
59      {
60          return Collections.singletonList(new ProductArtifact("com.atlassian.plugins.rest", "atlassian-rest-module", restVersion));
61      }
62  }