rename eCommerce_config.yml to config.yml
* if no config file is present, create a default config file
This commit is contained in:
parent
8c0652b26b
commit
ea0c8c45d6
|
@ -0,0 +1,21 @@
|
|||
!!org.hso.ecommerce.app.config.YAMLData
|
||||
companyAddress: {cityName: Musterstadt, countryName: Germany, houseNumber: '1', streetName: Musterstraße,
|
||||
zipCode: '12345'}
|
||||
companyName: eCommerce Shop UG
|
||||
installationName: eCommerce
|
||||
numberOfStorageSpaces: 128
|
||||
parcelServiceApiURL: http://[::1]:8082/
|
||||
parcelServiceName: Parcel Service
|
||||
suppliers:
|
||||
- apiURL: http://[::1]:8081/bank/
|
||||
companyAddress: {cityName: Musterstadt, countryName: Germany, houseNumber: '2',
|
||||
streetName: Musterstraße, zipCode: '12345'}
|
||||
deliveryTime: 4
|
||||
id: d41d8cd98f00b204e9800998ecf8427e
|
||||
name: Bank of Chees
|
||||
- apiURL: http://[::1]:8081/mda/
|
||||
companyAddress: {cityName: Musterstadt, countryName: Germany, houseNumber: '3',
|
||||
streetName: Musterstraße, zipCode: '12345'}
|
||||
deliveryTime: 5
|
||||
id: 18a17da5bac1cf00551b08c3e98720f5
|
||||
name: MDA
|
|
@ -1,21 +0,0 @@
|
|||
!!org.hso.ecommerce.app.config.YAMLData
|
||||
companyAddress: {cityName: Berlin, countryName: Germany, houseNumber: '6', streetName: Kupfergraben,
|
||||
zipCode: '10117'}
|
||||
companyName: newCommerce GmbH
|
||||
installationName: Fast-Web-Shop
|
||||
numberOfStorageSpaces: 128
|
||||
parcelServiceApiURL: https://dhl.api.ecommerce.mosad.xyz
|
||||
parcelServiceName: DHL International GmbH
|
||||
suppliers:
|
||||
- apiURL: https://reichelt.api.ecommerce.mosad.xyz
|
||||
companyAddress: {cityName: Sande, countryName: Germany, houseNumber: '1', streetName: Elektronikring,
|
||||
zipCode: '26452'}
|
||||
deliveryTime: 4
|
||||
id: d41d8cd98f00b204e9800998ecf8427e
|
||||
name: Reichelt elektronik GmbH & Co. KG
|
||||
- apiURL: https://conrad.api.ecommerce.mosad.xyz
|
||||
companyAddress: {cityName: Hirschau, countryName: Germany, houseNumber: '1', streetName: Klaus-Conrad-Straße,
|
||||
zipCode: '92240'}
|
||||
deliveryTime: 5
|
||||
id: 18a17da5bac1cf00551b08c3e98720f5
|
||||
name: Conrad Electronic SE
|
|
@ -15,7 +15,7 @@ import javax.annotation.PostConstruct;
|
|||
public class AppSettings {
|
||||
|
||||
private YAMLData data;
|
||||
private final String configFile = "eCommerce_config.yml";
|
||||
private final String configFile = "config.yml";
|
||||
|
||||
private String installationName;
|
||||
private String companyName;
|
||||
|
@ -24,11 +24,11 @@ public class AppSettings {
|
|||
private List<YAMLData.Supplier> suppliers;
|
||||
private String parcelServiceName;
|
||||
private String parcelServiceApiURL;
|
||||
|
||||
@PostConstruct
|
||||
|
||||
/**
|
||||
* on initialization read the config and store the data in static objects
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
data = readConfig();
|
||||
|
||||
|
@ -44,52 +44,52 @@ public class AppSettings {
|
|||
}
|
||||
|
||||
/**
|
||||
* write a demo config file
|
||||
* write the default config file
|
||||
*/
|
||||
public void writeDemoConfig() {
|
||||
public void writeDefaultConfig() {
|
||||
YAMLData data = new YAMLData();
|
||||
data.setInstallationName("Fast-Web-Shop");
|
||||
data.setCompanyName("newCommerce GmbH");
|
||||
data.setInstallationName("eCommerce");
|
||||
data.setCompanyName("eCommerce Shop UG");
|
||||
data.setCompanyAddress(new Address(
|
||||
"Kupfergraben",
|
||||
"6",
|
||||
"10117",
|
||||
"Berlin",
|
||||
"Musterstraße",
|
||||
"1",
|
||||
"12345",
|
||||
"Musterstadt",
|
||||
"Germany"
|
||||
));
|
||||
data.setNumberOfStorageSpaces(128);
|
||||
|
||||
List<YAMLData.Supplier> suppliers = new ArrayList<>();
|
||||
suppliers.add(new YAMLData.Supplier(
|
||||
"Reichelt elektronik GmbH & Co. KG",
|
||||
"Bank of Chees",
|
||||
"d41d8cd98f00b204e9800998ecf8427e",
|
||||
"https://reichelt.api.ecommerce.mosad.xyz",
|
||||
"http://[::1]:8081/bank/",
|
||||
4,
|
||||
new Address(
|
||||
"Elektronikring",
|
||||
"1",
|
||||
"26452",
|
||||
"Sande",
|
||||
"Musterstraße",
|
||||
"2",
|
||||
"12345",
|
||||
"Musterstadt",
|
||||
"Germany"
|
||||
)
|
||||
));
|
||||
suppliers.add(new YAMLData.Supplier(
|
||||
"Conrad Electronic SE",
|
||||
"MDA",
|
||||
"18a17da5bac1cf00551b08c3e98720f5",
|
||||
"https://conrad.api.ecommerce.mosad.xyz",
|
||||
"http://[::1]:8081/mda/",
|
||||
5,
|
||||
new Address(
|
||||
"Klaus-Conrad-Straße",
|
||||
"1",
|
||||
"92240",
|
||||
"Hirschau",
|
||||
"Musterstraße",
|
||||
"3",
|
||||
"12345",
|
||||
"Musterstadt",
|
||||
"Germany"
|
||||
)
|
||||
));
|
||||
data.setSuppliers(suppliers);
|
||||
|
||||
data.setParcelServiceName("DHL International GmbH");
|
||||
data.setParcelServiceApiURL("https://dhl.api.ecommerce.mosad.xyz");
|
||||
data.setParcelServiceName("Parcel Service");
|
||||
data.setParcelServiceApiURL("http://[::1]:8082/");
|
||||
|
||||
try (FileWriter writer = new FileWriter("./" + configFile)) {
|
||||
Yaml yaml = new Yaml();
|
||||
|
@ -107,6 +107,11 @@ public class AppSettings {
|
|||
public YAMLData readConfig() {
|
||||
YAMLData data = new YAMLData();
|
||||
|
||||
File file = new File("./" + configFile);
|
||||
if (!file.exists()) {
|
||||
writeDefaultConfig();
|
||||
}
|
||||
|
||||
try (InputStream inputStream = new FileInputStream("./" + configFile)) {
|
||||
Yaml yaml = new Yaml(new Constructor(YAMLData.class));
|
||||
data = yaml.load(inputStream);
|
||||
|
|
Reference in New Issue