1   package com.atlassian.maven.plugins.amps;
2   
3   import com.atlassian.maven.plugins.amps.util.ArtifactRetriever;
4   
5   import java.io.File;
6   import java.util.HashMap;
7   import java.util.List;
8   import java.util.ArrayList;
9   import java.util.Map;
10  import java.util.Properties;
11  
12  public class Product
13  {
14      /**
15       * Container to run in
16       */
17      protected String containerId;
18  
19      /**
20       * HTTP port for the servlet containers
21       */
22      private int httpPort = 0;
23  
24      /**
25       * Application context path
26       */
27      protected String contextPath;
28  
29      /**
30       * Application server
31       */
32      protected String server;
33  
34      /**
35       * Webapp version
36       */
37      protected String version;
38  
39      /**
40       * JVM arguments to pass to cargo
41       */
42      protected String jvmArgs = null;
43  
44      /**
45       * A log4j properties file
46       */
47      protected File log4jProperties;
48  
49      /**
50       * The test resources version
51       */
52      protected String productDataVersion;
53  
54      /**
55       * The path to a custom test resources zip
56       */
57      protected String productDataPath = "";
58  
59      /**
60       */
61      private List<ProductArtifact> pluginArtifacts = new ArrayList<ProductArtifact>();
62  
63      /**
64       */
65      private List<ProductArtifact> libArtifacts = new ArrayList<ProductArtifact>();
66  
67      /**
68       */
69      private List<ProductArtifact> bundledArtifacts = new ArrayList<ProductArtifact>();
70  
71      /**
72       * SAL version
73       */
74      private String salVersion;
75  
76      /**
77       * Atlassian Plugin Development Kit (PDK) version
78       */
79      private String pdkVersion;
80  
81      /**
82       * Atlassian REST module version
83       */
84      private String restVersion;
85  
86      /**
87       * Version of the Felix OSGi web console
88       */
89      private String webConsoleVersion;
90  
91      /**
92       * Product id
93       */
94      private String id;
95  
96      /**
97       * The name of the instance of the product
98       */
99      private String instanceId;
100 
101     private ArtifactRetriever artifactRetriever;
102 
103     /**
104      * Flag to indicate whether or not to install the plugin
105      */
106     private Boolean installPlugin;
107 
108     /**
109      * The system properties to set for the product
110      */
111     private Map<String,Object> systemProperties = new HashMap<String,Object>();
112 
113     /**
114      * File the container should log to.
115      */
116     private String output;
117 
118     /**
119      * Creates a new product that is merged with this one, where the properties in this one override the passed
120      * in product.
121      * @param product The product to merge with
122      * @return A new product
123      */
124     public Product merge(Product product)
125     {
126         Product prod = new Product();
127         prod.setOutput(output == null ? product.getOutput() : output);
128         prod.setSystemPropertyVariables(systemProperties.isEmpty() ? product.getSystemPropertyVariables() : systemProperties);
129         prod.setInstallPlugin(installPlugin == null ? product.isInstallPlugin() : installPlugin);
130         prod.setArtifactRetriever(artifactRetriever == null ? product.getArtifactRetriever() : artifactRetriever);
131         prod.setId(id == null ? product.getId() : id);
132         prod.setInstanceId(instanceId == null ? product.getInstanceId() : instanceId);
133         prod.setWebConsoleVersion(webConsoleVersion == null ? product.getWebConsoleVersion() : webConsoleVersion);
134         prod.setRestVersion(restVersion == null ? product.getRestVersion() : restVersion);
135         prod.setPdkVersion(pdkVersion == null ? product.getPdkVersion() : pdkVersion);
136         prod.setSalVersion(salVersion == null ? product.getSalVersion() : salVersion);
137         
138         prod.setBundledArtifacts(bundledArtifacts.isEmpty() ? product.getBundledArtifacts() : bundledArtifacts);
139         prod.setPluginArtifacts(pluginArtifacts.isEmpty() ? product.getPluginArtifacts() : pluginArtifacts);
140         prod.setLibArtifacts(libArtifacts.isEmpty() ? product.getLibArtifacts() : libArtifacts);
141 
142         prod.setDataPath(productDataPath.length() == 0 ? product.getDataPath() : productDataPath);
143         prod.setDataVersion(productDataVersion == null ? product.getDataVersion() : productDataVersion);
144         prod.setLog4jProperties(log4jProperties == null ? product.getLog4jProperties() : log4jProperties);
145         prod.setJvmArgs(jvmArgs == null ? product.getJvmArgs() : jvmArgs);
146         prod.setVersion(version == null ? product.getVersion() : version);
147 
148         prod.setServer(server == null ? product.getServer() : server);
149         prod.setContextPath(contextPath == null ? product.getContextPath() : contextPath);
150         prod.setContainerId(containerId == null ? product.getContainerId() : containerId);
151         prod.setHttpPort(httpPort == 0 ? product.getHttpPort() : httpPort);
152 
153         return prod;
154     }
155 
156     public String getContainerId()
157     {
158         return containerId;
159     }
160 
161     public void setContainerId(String containerId)
162     {
163         this.containerId = containerId;
164     }
165 
166     public String getServer()
167     {
168         return server;
169     }
170 
171     public void setServer(String server)
172     {
173         this.server = server;
174     }
175 
176     public int getHttpPort()
177     {
178         return httpPort;
179     }
180 
181     public void setHttpPort(int httpPort)
182     {
183         this.httpPort = httpPort;
184     }
185 
186     public String getContextPath()
187     {
188         return contextPath;
189     }
190 
191     public void setContextPath(String contextPath)
192     {
193         this.contextPath = contextPath;
194     }
195 
196     public String getJvmArgs()
197     {
198         return jvmArgs;
199     }
200 
201     public void setJvmArgs(String jvmArgs)
202     {
203         this.jvmArgs = jvmArgs;
204     }
205 
206     public ArtifactRetriever getArtifactRetriever()
207     {
208         return artifactRetriever;
209     }
210 
211     public void setArtifactRetriever(ArtifactRetriever artifactRetriever)
212     {
213         this.artifactRetriever = artifactRetriever;
214     }
215 
216     public String getVersion()
217     {
218         return version;
219     }
220 
221     public void setVersion(String version)
222     {
223         this.version = version;
224     }
225 
226     public String getDataVersion()
227     {
228         return productDataVersion;
229     }
230 
231     public void setDataVersion(String productDataVersion)
232     {
233         this.productDataVersion = productDataVersion;
234     }
235 
236     /**
237      * @deprecated since 3.2
238      */
239     public String getProductDataVersion()
240     {
241         return productDataVersion;
242     }
243 
244     /**
245      * @deprecated since 3.2
246      */
247     public void setProductDataVersion(String productDataVersion)
248     {
249         this.productDataVersion = productDataVersion;
250     }
251 
252     public String getDataPath()
253     {
254         return productDataPath;
255     }
256 
257     public void setDataPath(String productDataPath)
258     {
259         this.productDataPath = productDataPath;
260     }
261 
262     /**
263      * @deprecated since 3.2
264      */
265     public String getProductDataPath()
266     {
267         return productDataPath;
268     }
269 
270     /**
271      * @deprecated since 3.2
272      */
273     public void setProductDataPath(String productDataPath)
274     {
275         this.productDataPath = productDataPath;
276     }
277 
278     public List<ProductArtifact> getPluginArtifacts()
279     {
280         return pluginArtifacts;
281     }
282 
283     public void setPluginArtifacts(List<ProductArtifact> pluginArtifacts)
284     {
285         this.pluginArtifacts = pluginArtifacts;
286     }
287 
288     public List<ProductArtifact> getLibArtifacts()
289     {
290         return libArtifacts;
291     }
292 
293     public void setLibArtifacts(List<ProductArtifact> libArtifacts)
294     {
295         this.libArtifacts = libArtifacts;
296     }
297 
298     public List<ProductArtifact> getBundledArtifacts()
299     {
300         return bundledArtifacts;
301     }
302 
303     public void setBundledArtifacts(List<ProductArtifact> bundledArtifacts)
304     {
305         this.bundledArtifacts = bundledArtifacts;
306     }
307 
308     public File getLog4jProperties()
309     {
310         return log4jProperties;
311     }
312 
313     public void setLog4jProperties(File log4jProperties)
314     {
315         this.log4jProperties = log4jProperties;
316     }
317 
318     public String getRestVersion()
319     {
320         return restVersion;
321     }
322 
323     public void setRestVersion(String restVersion)
324     {
325         this.restVersion = restVersion;
326     }
327 
328     public String getSalVersion()
329     {
330         return salVersion;
331     }
332 
333     public void setSalVersion(String salVersion)
334     {
335         this.salVersion = salVersion;
336     }
337 
338     public String getPdkVersion()
339     {
340         return pdkVersion;
341     }
342 
343     public void setPdkVersion(String pdkVersion)
344     {
345         this.pdkVersion = pdkVersion;
346     }
347 
348     public String getId()
349     {
350         return id;
351     }
352 
353     public void setId(String id)
354     {
355         this.id = id;
356     }
357 
358     public String getInstanceId()
359     {
360         return instanceId;
361     }
362 
363     public void setInstanceId(String instanceId)
364     {
365         this.instanceId = instanceId;
366     }
367 
368     public Boolean isInstallPlugin()
369     {
370         return installPlugin;
371     }
372 
373     public void setInstallPlugin(final Boolean installPlugin)
374     {
375         this.installPlugin = installPlugin;
376     }
377 
378     public String getWebConsoleVersion()
379     {
380         return webConsoleVersion;
381     }
382 
383     public void setWebConsoleVersion(String webConsoleVersion)
384     {
385         this.webConsoleVersion = webConsoleVersion;
386     }
387 
388     /**
389      * @deprecated Since 3.2, use systemPropertyVariables
390      */
391     public void setSystemProperties(Properties systemProperties)
392     {
393         this.systemProperties.putAll((Map) systemProperties);
394     }
395 
396     /**
397      * @deprecated Since 3.2, use systemPropertyVariables
398      */
399     public Properties getSystemProperties()
400     {
401         Properties props = new Properties();
402         props.putAll(systemProperties);
403         return props;
404     }
405 
406     public void setSystemPropertyVariables(Map<String,Object> systemProperties)
407     {
408         this.systemProperties = systemProperties;
409     }
410 
411     public Map<String,Object> getSystemPropertyVariables()
412     {
413         return systemProperties;
414     }
415 
416 	public String getOutput()
417 	{
418 		return output;
419 	}
420 	
421 	public void setOutput(String output)
422 	{
423 		this.output = output;
424 	}
425 
426 }