| hebasta | a66693a | 2020-07-19 16:51:28 +0200 | [diff] [blame] | 1 | /** |
| 2 | * |
| Akron | 3588101 | 2020-11-24 20:05:06 +0100 | [diff] [blame] | 3 | * @author helge, ndiewald |
| hebasta | a66693a | 2020-07-19 16:51:28 +0200 | [diff] [blame] | 4 | * |
| 5 | * Class to define the constants of the export web service, |
| 6 | * like the maximum hits to be exported |
| 7 | * |
| 8 | */ |
| 9 | package de.ids_mannheim.korap.plkexport; |
| 10 | |
| Akron | c931cd0 | 2020-09-15 10:54:17 +0200 | [diff] [blame] | 11 | import java.io.*; |
| 12 | import java.lang.String; |
| 13 | import java.util.Properties; |
| Akron | 143acad | 2020-11-25 17:48:33 +0100 | [diff] [blame] | 14 | import java.nio.charset.StandardCharsets; |
| Akron | c931cd0 | 2020-09-15 10:54:17 +0200 | [diff] [blame] | 15 | |
| hebasta | a66693a | 2020-07-19 16:51:28 +0200 | [diff] [blame] | 16 | public class ExWSConf { |
| Akron | 62d90a3 | 2020-11-18 20:45:38 +0100 | [diff] [blame] | 17 | |
| hebasta | 2e43120 | 2020-11-02 10:00:26 +0100 | [diff] [blame] | 18 | // Version of Export Plugin |
| hebasta | 541e676 | 2020-07-22 20:01:53 +0200 | [diff] [blame] | 19 | public static final int VERSION_MAJOR = 0; |
| Akron | 69cd35d | 2020-11-20 13:17:31 +0100 | [diff] [blame] | 20 | public static final int VERSION_MINOR = 2; |
| Akron | a578eb0 | 2020-11-26 12:34:17 +0100 | [diff] [blame^] | 21 | public static final int VERSION_PATCHLEVEL = 2; |
| Akron | c931cd0 | 2020-09-15 10:54:17 +0200 | [diff] [blame] | 22 | |
| 23 | private static Properties prop; |
| 24 | |
| 25 | // Load properties from file |
| 26 | public static Properties properties (String propFile) { |
| 27 | |
| 28 | if (prop != null) |
| 29 | return prop; |
| 30 | |
| 31 | if (propFile == null) |
| 32 | propFile = "exportPlugin.conf"; |
| 33 | |
| 34 | InputStream iFile; |
| 35 | try { |
| Akron | 143acad | 2020-11-25 17:48:33 +0100 | [diff] [blame] | 36 | |
| 37 | iFile = new FileInputStream(propFile); |
| Akron | c931cd0 | 2020-09-15 10:54:17 +0200 | [diff] [blame] | 38 | prop = new Properties(); |
| Akron | 143acad | 2020-11-25 17:48:33 +0100 | [diff] [blame] | 39 | prop.load( |
| 40 | new BufferedReader( |
| 41 | new InputStreamReader(iFile, "UTF-8") |
| 42 | ) |
| 43 | ); |
| Akron | c931cd0 | 2020-09-15 10:54:17 +0200 | [diff] [blame] | 44 | } |
| 45 | catch (IOException t) { |
| 46 | try { |
| 47 | iFile = ExWSConf.class.getClassLoader() |
| 48 | .getResourceAsStream(propFile); |
| 49 | |
| 50 | if (iFile == null) { |
| 51 | System.err.println("Unable to load properties."); |
| 52 | return null; |
| 53 | }; |
| 54 | |
| 55 | prop = new Properties(); |
| 56 | prop.load(iFile); |
| 57 | iFile.close(); |
| 58 | } |
| 59 | catch (IOException e) { |
| 60 | System.err.println(e.getLocalizedMessage()); |
| 61 | return null; |
| 62 | }; |
| 63 | }; |
| 64 | return prop; |
| 65 | }; |
| hebasta | a66693a | 2020-07-19 16:51:28 +0200 | [diff] [blame] | 66 | } |