1 package com.atlassian.amps.sdk.util;
2
3 import java.io.IOException;
4 import java.util.Properties;
5
6 import org.apache.commons.lang.StringUtils;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9
10
11
12
13 public class PropertiesReader
14 {
15 private final static String AMPS_LATEST_VERSION = "amps.latest.version";
16 private final static String AMPS_NEW_VERSION = "amps.new.version";
17
18 private final static String BINARY_URI = ".binary.uri";
19
20
21
22 private final static String RELEASE_SUMMARY_DEFAULT = "Atlassian Plugin SDK version {0} with AMPS plugin version {1}";
23 private final static String RELEASE_SUMMARY = "release.summary";
24 private final static String RELEASE_PRODUCTION = "release.production";
25
26 private static final Logger log = LoggerFactory.getLogger(PropertiesReader.class);
27 private static PropertiesReader instance = null;
28
29 private Properties properties;
30
31 private PropertiesReader() throws IOException
32 {
33 properties = new Properties();
34 properties.load(getClass().getResourceAsStream("/release.properties"));
35 }
36
37 public static PropertiesReader getInstance() throws IOException
38 {
39 if (null == instance)
40 {
41 try
42 {
43 instance = new PropertiesReader();
44 }catch (IOException io)
45 {
46 throw new IOException("Could not read release.properties", io);
47 }
48 }
49 return instance;
50 }
51
52 public String getBinaryURI(String prefix)
53 {
54 return properties.getProperty(prefix + BINARY_URI);
55 }
56
57 public String getAMPSLatestVersion()
58 {
59 return properties.getProperty(AMPS_LATEST_VERSION);
60 }
61
62 public String getAMPSCurrentVersion()
63 {
64 return properties.getProperty(AMPS_NEW_VERSION);
65 }
66
67 public String getReleaseSummary()
68 {
69 if (StringUtils.isNotEmpty(properties.getProperty(RELEASE_SUMMARY)))
70 {
71 return properties.getProperty(RELEASE_SUMMARY);
72 }
73 else
74 {
75 return RELEASE_SUMMARY_DEFAULT;
76 }
77 }
78
79 public boolean isReleaseProduction()
80 {
81 return Boolean.getBoolean(properties.getProperty(RELEASE_PRODUCTION));
82 }
83 }