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          if (product.isEnableFastdev() && product.getFastdevVersion() != null)
40          {
41              artifacts.addAll(getFastdevArtifacts(product.getFastdevVersion()));
42          }
43  
44          if (product.isEnableDevToolbox() && product.getDevToolboxVersion() != null)
45          {
46              artifacts.addAll(getDevToolboxArtifacts(product.getDevToolboxVersion()));
47          }
48  
49          if (product.isEnablePde() && product.getPdeVersion() != null) 
50          {
51              artifacts.addAll(getPdeArtifacts(product.getPdeVersion()));
52          }
53          
54          return artifacts;
55      }
56  
57      protected abstract Collection<ProductArtifact> getSalArtifacts(String salVersion);
58  
59      protected Collection<ProductArtifact> getPdkInstallArtifacts(String pdkInstallVersion)
60      {
61          return Collections.singletonList(new ProductArtifact("com.atlassian.pdkinstall", "pdkinstall-plugin", pdkInstallVersion));
62      }
63  
64      protected Collection<ProductArtifact> getWebConsoleArtifacts(String webConsoleVersion)
65      {
66          return Arrays.asList(
67                  new ProductArtifact("org.apache.felix", "org.apache.felix.webconsole", webConsoleVersion),
68                  new ProductArtifact("org.apache.felix", "org.osgi.compendium", "1.2.0"),
69                  new ProductArtifact("com.atlassian.labs.httpservice", "httpservice-bridge", "0.6.1")
70                  );
71      }
72  
73      protected Collection<ProductArtifact> getFastdevArtifacts(String fastdevVersion)
74      {
75          return Collections.singletonList(new ProductArtifact("com.atlassian.labs", "fastdev-plugin", fastdevVersion));
76      }
77  
78      protected Collection<ProductArtifact> getDevToolboxArtifacts(String devToolboxVersion)
79      {
80          return Collections.singletonList(new ProductArtifact("com.atlassian.devrel", "developer-toolbox-plugin", devToolboxVersion));
81      }
82  
83      protected Collection<ProductArtifact> getPdeArtifacts(String pdeVersion)
84      {
85          return Collections.singletonList(new ProductArtifact("com.atlassian.plugins", "plugin-data-editor", pdeVersion));
86      }
87      
88      protected Collection<ProductArtifact> getRestArtifacts(String restVersion)
89      {
90          return Collections.singletonList(new ProductArtifact("com.atlassian.plugins.rest", "atlassian-rest-module", restVersion));
91      }
92  }