1 package com.atlassian.maven.plugins.amps.product.studio;
2
3 import static com.atlassian.maven.plugins.amps.util.ProjectUtils.firstNotNull;
4
5 import java.io.File;
6 import java.util.Map;
7
8 import com.atlassian.maven.plugins.amps.Product;
9 import com.atlassian.maven.plugins.amps.product.ProductHandlerFactory;
10 import com.google.common.collect.ImmutableMap;
11 import com.google.common.collect.Maps;
12
13
14
15
16 public class StudioProperties
17 {
18
19
20
21
22 protected String version;
23
24
25 private String studioHome;
26
27 private String studioDataLocation;
28 private Product studioProduct;
29 private boolean modeConfluenceStandalone = false;
30
31 private String svnRoot;
32 private String svnPublicUrl;
33 private String svnImportStagingDirectory;
34
35 private String webDavHome;
36
37 private Product jira;
38 private String greenHopperLicense;
39
40 private Product confluence;
41 private String confluenceContext;
42
43 private Product fisheye;
44 private String fisheyeControlPort;
45 private String fisheyeShutdownEnabled;
46
47 private Product bamboo;
48 private Product crowd;
49
50 private boolean gappsEnabled;
51 private String gappsDomain;
52
53 private Map<String, String> systemProperties = Maps.newHashMap();
54
55
56
57
58
59
60
61 public StudioProperties(Product studioContext)
62 {
63 if (!ProductHandlerFactory.STUDIO.equals(studioContext.getId()))
64 {
65 throw new IllegalArgumentException("The Studio Properties should be based on the Studio product");
66 }
67 version = firstNotNull(studioContext.getVersion(), "RELEASE");
68 studioProduct = studioContext;
69
70 gappsEnabled = Boolean.getBoolean(studioContext.getGappsEnabled());
71 gappsDomain = firstNotNull(studioContext.getGappsDomain(), "");
72 }
73
74 public void setVersion(String version)
75 {
76 this.version = version;
77 }
78
79 public void setStudioHome(String studioHome)
80 {
81 this.studioHome = studioHome;
82 }
83
84 public void setStudioDataLocation(String studioDataLocation)
85 {
86 this.studioDataLocation = studioDataLocation;
87 }
88
89 public void setModeConfluenceStandalone(boolean modeConfluenceStandalone)
90 {
91 this.modeConfluenceStandalone = modeConfluenceStandalone;
92 }
93
94 public void setSvnRoot(String svnRoot)
95 {
96 this.svnRoot = svnRoot;
97 }
98
99 public void setSvnPublicUrl(String svnPublicUrl)
100 {
101 this.svnPublicUrl = svnPublicUrl;
102 }
103
104 public void setSvnImportStagingDirectory(String svnImportStagingDirectory)
105 {
106 this.svnImportStagingDirectory = svnImportStagingDirectory;
107 }
108
109 public void setWebDavHome(String webDavHome)
110 {
111 this.webDavHome = webDavHome;
112 }
113
114 public void setJira(Product jira)
115 {
116 this.jira = jira;
117 }
118
119 public void setGreenHopperLicense(String greenHopperLicense)
120 {
121 this.greenHopperLicense = greenHopperLicense;
122 }
123
124 public void setConfluence(Product confluence)
125 {
126 this.confluence = confluence;
127 }
128
129 public void setConfluenceContext(String confluenceContext)
130 {
131 this.confluenceContext = confluenceContext;
132 }
133
134 public void setFisheye(Product fisheye)
135 {
136 this.fisheye = fisheye;
137 }
138
139 public void setFisheyeControlPort(String fisheyeControlPort)
140 {
141 this.fisheyeControlPort = fisheyeControlPort;
142 }
143
144 public void setFisheyeShutdownEnabled(String fisheyeShutdownEnabled)
145 {
146 this.fisheyeShutdownEnabled = fisheyeShutdownEnabled;
147 }
148
149 public void setBamboo(Product bamboo)
150 {
151 this.bamboo = bamboo;
152 }
153
154 public void setCrowd(Product crowd)
155 {
156 this.crowd = crowd;
157 }
158
159 public void setGappsEnabled(boolean gappsEnabled)
160 {
161 this.gappsEnabled = gappsEnabled;
162 }
163
164 public void setGappsDomain(String gappsDomain)
165 {
166 this.gappsDomain = gappsDomain;
167 }
168
169 public String getVersion()
170 {
171 return version;
172 }
173
174 public String getStudioHome()
175 {
176 return studioHome;
177 }
178
179 public String getStudioDataLocation()
180 {
181 return studioDataLocation;
182 }
183
184 public Product getStudioProduct()
185 {
186 return studioProduct;
187 }
188
189 public void setStudioProduct(Product studioProduct)
190 {
191 this.studioProduct = studioProduct;
192 }
193
194 public Map<String, String> getSystemProperties()
195 {
196 return ImmutableMap.copyOf(systemProperties);
197 }
198
199 public void overrideSystemProperty(String key, String value)
200 {
201 this.systemProperties.put(key, value);
202 }
203
204 public boolean isModeConfluenceStandalone()
205 {
206 return modeConfluenceStandalone;
207 }
208
209 public String getSvnRoot()
210 {
211 return svnRoot;
212 }
213
214 public String getSvnPublicUrl()
215 {
216 return svnPublicUrl;
217 }
218
219 public String getSvnHooks()
220 {
221 if (svnRoot != null)
222 {
223 return new File(svnRoot, "hooks").getAbsolutePath();
224 }
225 return null;
226 }
227
228 public String getSvnImportStagingDirectory()
229 {
230 return svnImportStagingDirectory;
231 }
232
233 public String getWebDavHome()
234 {
235 return webDavHome;
236 }
237
238 public String getGreenHopperLicense()
239 {
240 return greenHopperLicense;
241 }
242
243 public Product getConfluence()
244 {
245 return confluence;
246 }
247 public Product getJira()
248 {
249 return jira;
250 }
251
252 public String getConfluenceContext()
253 {
254 return confluenceContext;
255 }
256
257 public Product getFisheye()
258 {
259 return fisheye;
260 }
261
262 public String getFisheyeControlPort()
263 {
264 return fisheyeControlPort;
265 }
266
267 public String getFisheyeShutdownEnabled()
268 {
269 return fisheyeShutdownEnabled;
270 }
271
272 public Product getBamboo()
273 {
274 return bamboo;
275 }
276
277 public Product getCrowd()
278 {
279 return crowd;
280 }
281
282 public boolean isGappsEnabled()
283 {
284 return gappsEnabled;
285 }
286
287 public String getGappsDomain()
288 {
289 return firstNotNull(gappsDomain, "");
290 }
291
292
293
294
295
296
297
298 public int getJiraPort()
299 {
300 return jira != null ? jira.getHttpPort() : 0;
301 }
302
303 public String getJiraContextPath()
304 {
305 return jira != null ? jira.getContextPath() : "";
306 }
307
308 public String getJiraUrl()
309 {
310 if (jira == null)
311 {
312 return "";
313 }
314 return String.format("http://localhost:%d%s", jira.getHttpPort(), jira.getContextPath());
315 }
316
317 public String getJiraHostUrl()
318 {
319 if (jira == null)
320 {
321 return "";
322 }
323 return String.format("http://localhost:%d", jira.getHttpPort());
324 }
325
326 public boolean isJiraEnabled()
327 {
328 return !modeConfluenceStandalone;
329 }
330
331
332 public int getConfluencePort()
333 {
334 return confluence != null ? confluence.getHttpPort() : 0;
335 }
336
337 public String getConfluenceContextPath()
338 {
339 return confluence != null ? confluence.getContextPath() : "";
340 }
341
342 public String getConfluenceUrl()
343 {
344 if (confluence == null)
345 {
346 return "";
347 }
348 return String.format("http://localhost:%d%s", confluence.getHttpPort(), confluence.getContextPath());
349 }
350
351 public String getConfluenceHostUrl()
352 {
353 if (confluence == null)
354 {
355 return "";
356 }
357 return String.format("http://localhost:%d", confluence.getHttpPort());
358 }
359
360 public boolean isConfluenceEnabled()
361 {
362 return confluence != null;
363 }
364
365
366 public int getFisheyePort()
367 {
368 return fisheye != null ? fisheye.getHttpPort() : 0;
369 }
370 public String getFisheyeContextPath()
371 {
372 return fisheye != null && fisheye.getContextPath() != null ? fisheye.getContextPath() : "";
373 }
374
375 public String getFisheyeUrl()
376 {
377 if (fisheye == null)
378 {
379 return "";
380 }
381 if (fisheye.getContextPath() != null)
382 {
383 return String.format("http://localhost:%d%s", fisheye.getHttpPort(), fisheye.getContextPath());
384 }
385 else
386 {
387 return String.format("http://localhost:%d", fisheye.getHttpPort());
388 }
389 }
390
391 public String getFisheyeHostUrl()
392 {
393 return getFisheyeUrl();
394 }
395
396 public boolean isFisheyeEnabled()
397 {
398 return fisheye != null;
399 }
400
401
402 public String getBambooContextPath()
403 {
404 return bamboo != null ? bamboo.getContextPath() : "";
405 }
406
407 public int getBambooPort()
408 {
409 return bamboo != null ? bamboo.getHttpPort() : 0;
410 }
411
412 public String getBambooUrl()
413 {
414 if (bamboo == null)
415 {
416 return "";
417 }
418 return String.format("http://localhost:%d%s", bamboo.getHttpPort(), bamboo.getContextPath());
419 }
420
421 public String getBambooHostUrl()
422 {
423 if (bamboo == null)
424 {
425 return "";
426 }
427 return String.format("http://localhost:%d", bamboo.getHttpPort());
428 }
429
430 public boolean isBambooEnabled()
431 {
432 return bamboo != null;
433 }
434
435
436 public String getCrowdUrl()
437 {
438 if (crowd == null)
439 {
440 return "";
441 }
442 return String.format("http://localhost:%d%s", crowd.getHttpPort(), crowd.getContextPath());
443 }
444
445 public String getCrowdHostUrl()
446 {
447 if (crowd == null)
448 {
449 return "";
450 }
451 return String.format("http://localhost:%d", crowd.getHttpPort());
452 }
453
454 public String getCrowdContextPath()
455 {
456 return crowd != null ? crowd.getContextPath() : "";
457 }
458
459 public int getCrowdPort()
460 {
461 return crowd != null ? crowd.getHttpPort() : 0;
462 }
463
464
465 }