Commit af683de5 authored by j.hoerdt's avatar j.hoerdt
Browse files

ability to configure sensor_type_info

terminate when config not found
parent 1f874955
neo4j_uri=bolt://localhost:7687
neo4j_uri=bolt://sensordata.open-forecast.eu:7687
database_name=neo4j
already_uploaded_days_file = all_days.txt
failed_to_upload_sensors_file = test_sensor.txt
\ No newline at end of file
failed_to_upload_sensors_file = test_sensor.txt
pid_reg_server_cert = /home/neop/Documents/Uni/bachelor/ba/sensordata-ansible/roles/sensor2graph/files/sensor2graph/handle_auth/pid_reg_server_cert.pem
pid_reg_keystore = /home/neop/Documents/Uni/bachelor/ba/sensordata-ansible/roles/sensor2graph/files/sensor2graph/handle_auth/pid_reg_keystore.p12
neo4j_server_certificate_file = /home/neop/Documents/Uni/bachelor/ba/sensordata-ansible/roles/nginx-reverse-proxy/files/nginx-reverse-proxy/sensordata_cert.pem
sensor_type_info = config/sensor_type_info.json
\ No newline at end of file
......@@ -33,6 +33,7 @@ public class Main {
private static String neo4j_uri;
private static File neo4j_server_certificate_file;
private static String archive_uri;
private static String sensor_type_info;
public static String pid_registry_uri;
public static String prefix_for_new_pids;
public static String pid_reg_server_cert;
......@@ -60,7 +61,7 @@ public class Main {
//.withMaxTransactionRetryTime(3, TimeUnit.SECONDS)
//.withLeakedSessionsLogging()
.withMaxConnectionPoolSize(concurrency)
// .withEncryption()
.withEncryption()
// .withTrustStrategy(TrustStrategy.trustCustomCertificateSignedBy(neo4j_server_certificate_file))
.build()
);
......@@ -168,7 +169,7 @@ public class Main {
initialize_driver();
try {
Handle.http_client = Handle.get_client();
test_auth();
......@@ -197,6 +198,7 @@ public class Main {
neo4j_uri = config.getProperty("neo4j_uri" );
neo4j_server_certificate_file = new File(config.getProperty("neo4j_server_certificate_file"));
archive_uri = config.getProperty("archive_uri" );
sensor_type_info = config.getProperty("sensor_type_info" );
pid_registry_uri = config.getProperty("pid_registry_uri" );
prefix_for_new_pids = config.getProperty("prefix_for_new_pids" );
pid_reg_server_cert = config.getProperty("pid_reg_server_cert" );
......@@ -206,12 +208,8 @@ public class Main {
private static Properties load_user_defined_properties_with_defaults(Properties defaults) throws Exception {
Properties config = new Properties(defaults);
try {
config.load(new FileInputStream(config_file));
} catch (FileNotFoundException e) {
Main.logger.warning("configuration file " + config_file + " not found, using defaults!");
}
var config = new Properties(defaults);
config.load(new FileInputStream(config_file));
return config;
}
......@@ -228,6 +226,7 @@ public class Main {
defaults.setProperty("neo4j_uri", "bolt://localhost:7687" );
defaults.setProperty("neo4j_server_certificate_file", "graphdb.gwdg.de.pem" );
defaults.setProperty("archive_uri", "https://archive.sensor.community/" );
defaults.setProperty("sensor_type_info", "sensor_type_info.json" );
defaults.setProperty("pid_registry_uri", "https://vm13.pid.gwdg.de:8000/api/handles/");
defaults.setProperty("prefix_for_new_pids", "21.11138/" );
defaults.setProperty("pid_reg_server_cert", "pid_reg_server_cert.pem" );
......@@ -260,7 +259,7 @@ public class Main {
private static void pre_run_graphdb_actions() throws Exception {
Map<String, Object> parameters = new Gson().fromJson(new FileReader("sensor_type_info.json"), new TypeToken <Map<String, Object>>() {}.getType());
Map<String, Object> parameters = new Gson().fromJson(new FileReader(sensor_type_info), new TypeToken <Map<String, Object>>() {}.getType());
try (var session = Main.driver.session(SessionConfig.forDatabase(Main.database_name))) {
session.writeTransaction(tx -> {
tx.run(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment