diff options
author | Michael Petretti | 2014-06-03 11:12:54 +0200 |
---|---|---|
committer | Michael Petretti | 2014-06-03 11:12:54 +0200 |
commit | 7a51454a562a5efbb793e26d32bfea66f64ef9ad (patch) | |
tree | 535b9442e6d80cdbed3c6dab00623f803fdb7d86 /src/main/java/org/openslx/satellitedaemon/Globals.java | |
parent | Fixed most ToDo's. (diff) | |
download | satellite-daemon-7a51454a562a5efbb793e26d32bfea66f64ef9ad.tar.gz satellite-daemon-7a51454a562a5efbb793e26d32bfea66f64ef9ad.tar.xz satellite-daemon-7a51454a562a5efbb793e26d32bfea66f64ef9ad.zip |
Moved more things to the Globals.java class.
Diffstat (limited to 'src/main/java/org/openslx/satellitedaemon/Globals.java')
-rw-r--r-- | src/main/java/org/openslx/satellitedaemon/Globals.java | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/src/main/java/org/openslx/satellitedaemon/Globals.java b/src/main/java/org/openslx/satellitedaemon/Globals.java index ae631f1..8fe87c5 100644 --- a/src/main/java/org/openslx/satellitedaemon/Globals.java +++ b/src/main/java/org/openslx/satellitedaemon/Globals.java @@ -13,16 +13,19 @@ public class Globals /** * If there are more ints or Strings which should be added to config/global.properties, * add to suiting enum, add a 'case' to getPropertyInt/String() and add checks to - * propertiesValid() + * propertiesValid(). + * + * As an Example, if you want the value of the FTPSERVERIP you have to call + * Globals.getPropertyString( PropString.FTPSERVERIP ) which returns a string. */ public static enum PropInt { - FTPPORT + FTPPORT // More int's? Add them separated with "," } - + public static enum PropString - { - FTPSERVERIP + { // More strings's? Add them separated with "," + FTPSERVERIP, KEYSTORETYPE, FTPSKEYSTOREPATH, FTPSKEYSTOREPWD } public static boolean loadProperties() throws IOException @@ -30,7 +33,7 @@ public class Globals if ( loadedProperties ) return false; - // Load properties + // Load all entries of the config file into properties BufferedInputStream stream = new BufferedInputStream( new FileInputStream( "config/global.properties" ) ); properties.load( stream ); stream.close(); @@ -38,6 +41,7 @@ public class Globals return true; } + // Calling public static int getPropertyInt( Globals.PropInt props ) { String result = null; @@ -55,7 +59,7 @@ public class Globals return Integer.valueOf( result ); } - + public static String getPropertyString( Globals.PropString props ) { String result = null; @@ -64,6 +68,15 @@ public class Globals case FTPSERVERIP: result = properties.getProperty( "ftp_server_ip" ); break; + case KEYSTORETYPE: + result = properties.getProperty( "keyStore_type" ); + break; + case FTPSKEYSTOREPATH: + result = properties.getProperty( "path_to_ftps_keyStore" ); + break; + case FTPSKEYSTOREPWD: + result = properties.getProperty( "ftps_keyStore_password" ); + break; default: result = ""; break; @@ -73,9 +86,15 @@ public class Globals public static boolean propertiesValid() { - if (Globals.getPropertyInt( PropInt.FTPPORT ) == 0 + if ( Globals.getPropertyInt( PropInt.FTPPORT ) == 0 || Globals.getPropertyString( PropString.FTPSERVERIP ).isEmpty() - || Globals.getPropertyString( PropString.FTPSERVERIP ) == null) { + || Globals.getPropertyString( PropString.FTPSERVERIP ) == null + || Globals.getPropertyString( PropString.KEYSTORETYPE ).isEmpty() + || Globals.getPropertyString( PropString.KEYSTORETYPE ) == null + || Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ).isEmpty() + || Globals.getPropertyString( PropString.FTPSKEYSTOREPATH ) == null + || Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ).isEmpty() + || Globals.getPropertyString( PropString.FTPSKEYSTOREPWD ) == null ) { return false; } else { |