blob: 7fe4233f9d8e4f7b9b85a38ecb5101b8c338e5b1 [file] [log] [blame]
hebastaa66693a2020-07-19 16:51:28 +02001/**
2 *
Akron35881012020-11-24 20:05:06 +01003 * @author helge, ndiewald
hebastaa66693a2020-07-19 16:51:28 +02004 *
5 * Class to define the constants of the export web service,
6 * like the maximum hits to be exported
7 *
8 */
9package de.ids_mannheim.korap.plkexport;
10
Akronc931cd02020-09-15 10:54:17 +020011import java.io.*;
12import java.lang.String;
13import java.util.Properties;
Akron143acad2020-11-25 17:48:33 +010014import java.nio.charset.StandardCharsets;
Akronc931cd02020-09-15 10:54:17 +020015
hebastaa66693a2020-07-19 16:51:28 +020016public class ExWSConf {
Akron62d90a32020-11-18 20:45:38 +010017
hebasta2e431202020-11-02 10:00:26 +010018 // Version of Export Plugin
hebasta541e6762020-07-22 20:01:53 +020019 public static final int VERSION_MAJOR = 0;
Akron69cd35d2020-11-20 13:17:31 +010020 public static final int VERSION_MINOR = 2;
Akrona578eb02020-11-26 12:34:17 +010021 public static final int VERSION_PATCHLEVEL = 2;
Akronc931cd02020-09-15 10:54:17 +020022
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 {
Akron143acad2020-11-25 17:48:33 +010036
37 iFile = new FileInputStream(propFile);
Akronc931cd02020-09-15 10:54:17 +020038 prop = new Properties();
Akron143acad2020-11-25 17:48:33 +010039 prop.load(
40 new BufferedReader(
41 new InputStreamReader(iFile, "UTF-8")
42 )
43 );
Akronc931cd02020-09-15 10:54:17 +020044 }
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 };
hebastaa66693a2020-07-19 16:51:28 +020066}