From 7a51454a562a5efbb793e26d32bfea66f64ef9ad Mon Sep 17 00:00:00 2001 From: Michael Petretti Date: Tue, 3 Jun 2014 11:12:54 +0200 Subject: Moved more things to the Globals.java class. --- .../java/org/openslx/satellitedaemon/Globals.java | 37 ++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'src/main/java/org/openslx/satellitedaemon/Globals.java') 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 { -- cgit v1.2.3-55-g7522