feature/config #78
@ -15,6 +15,7 @@ import javax.annotation.PostConstruct;
|
|||||||
public class AppSettings {
|
public class AppSettings {
|
||||||
|
|
||||||
private YAMLData data;
|
private YAMLData data;
|
||||||
|
private final String configFile = "eCommerce_config.yml";
|
||||||
|
|
||||||
private String installationName;
|
private String installationName;
|
||||||
private String companyName;
|
private String companyName;
|
||||||
@ -90,7 +91,7 @@ public class AppSettings {
|
|||||||
data.setParcelServiceName("DHL International GmbH");
|
data.setParcelServiceName("DHL International GmbH");
|
||||||
data.setParcelServiceApiURL("https://dhl.api.ecommerce.mosad.xyz");
|
data.setParcelServiceApiURL("https://dhl.api.ecommerce.mosad.xyz");
|
||||||
|
|
||||||
try (FileWriter writer = new FileWriter("./eCommerce_config.yml")) {
|
try (FileWriter writer = new FileWriter("./" + configFile)) {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
yaml.dump(data, writer);
|
yaml.dump(data, writer);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -106,14 +107,16 @@ public class AppSettings {
|
|||||||
public YAMLData readConfig() {
|
public YAMLData readConfig() {
|
||||||
YAMLData data = new YAMLData();
|
YAMLData data = new YAMLData();
|
||||||
|
|
||||||
|
|||||||
try (InputStream inputStream = new FileInputStream("./eCommerce_config.yml")) {
|
try (InputStream inputStream = new FileInputStream("./" + configFile)) {
|
||||||
Yaml yaml = new Yaml(new Constructor(YAMLData.class));
|
Yaml yaml = new Yaml(new Constructor(YAMLData.class));
|
||||||
data = yaml.load(inputStream);
|
data = yaml.load(inputStream);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.err.println("The file \"eCommerce_config.yml\" has not been found, please create a valid Configuration file.");
|
System.err.println("The file \"" + configFile + "\" has not been found, please create a valid Configuration file.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
CodeSteak
commented
Führt nach im catch(...) Fall evtl zu null pointer deref. Vlcht im catch leere werte setzen oder app beenden. Führt nach im catch(...) Fall evtl zu null pointer deref. Vlcht im catch leere werte setzen oder app beenden.
Seil0
commented
Wollen wir mit leeren Werten starten oder beenden? Ich hab jetzt mal ein Wollen wir mit leeren Werten starten oder beenden? Ich hab jetzt mal ein `System.exit()` eingebaut.
|
|||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Reference in New Issue
Block a user
Vlcht besser als private/public static final String in der Klasse.
wollen wir wirklich "./eCommerce_config.yml" als Dateinamen? Hat merkwürdiges Caseing (underscore und Groß/klein-schreibung.).