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

response body can only be used once and other fixes

parent 39f47f7d
......@@ -22,7 +22,8 @@
!graphdb.gwdg.de.pem
!sensor_type_info.json
!sensor_info/**/*
!develogging.properties
!devel_sensor2graph.properties
......
......@@ -15,6 +15,9 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
}
compileJava {
options.compilerArgs << "-Xlint:deprecation"
}
mainClassName = 'sensor2graph.Main'
......
neo4j_uri=bolt://localhost: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
# custom logging properties file based on default logging config file
############################################################
# Default Logging Configuration File
#
# You can use a different file by specifying a filename
# with the java.util.logging.config.file system property.
# For example java -Djava.util.logging.config.file=myfile
############################################################
############################################################
# Global properties
############################################################
# "handlers" specifies a comma separated list of log Handler
# classes. These handlers will be installed during VM startup.
# Note that these classes must be on the system classpath.
# By default we only configure a ConsoleHandler, which will only
# show messages at the INFO and above levels.
handlers=
# To also add the FileHandler, use the following line instead.
#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level= ALL
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
# default file output is in user's home directory.
java.util.logging.FileHandler.pattern = logs/sensor%g_%u.log
java.util.logging.FileHandler.limit = 0
java.util.logging.FileHandler.count = 10
# Default number of locks FileHandler can obtain synchronously.
# This specifies maximum number of attempts to obtain lock file by FileHandler
# implemented by incrementing the unique field %u as per FileHandler API documentation.
java.util.logging.FileHandler.maxLocks = 100
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Example to customize the SimpleFormatter output format
# to print one-line log message like this:
# <level>: <log message> [<date/time>]
#
# java.util.logging.SimpleFormatter.format=%4$s: %5$s [%1$tc]%n
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
# com.xyz.foo.level = SEVERE
sensor2graph.Main.level = FINE
sensor2graph.Main.handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
global.level = FINE
global.handlers = java.util.logging.FileHandler
......@@ -79,8 +79,8 @@ public class Main {
private static void run() throws Exception {
try_uploading_failed_sensors();
upload_all_days();
try_uploading_failed_sensors();
// upload_all_days();
// try_uploading_failed_sensors();
}
......@@ -170,7 +170,7 @@ public class Main {
Handle.http_client = Handle.get_client();
test_auth();
pre_run_graphdb_actions();
//run();
run();
} catch (org.neo4j.driver.exceptions.AuthenticationException e) {
Main.logger.log(Level.SEVERE, "Authentication failed, are your credentials correct?");
} catch (Exception e) {
......
......@@ -104,22 +104,22 @@ class Sensor {
Request request = new Request.Builder()
.url(Main.pid_registry_uri + target_uri)
.method(method, RequestBody.create(MediaType.parse("application/json"), body.toString()))
.method(method, RequestBody.create(body.toString(), MediaType.parse("application/json")))
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Handle clientCert=\"true\"")
.build();
try (Response response = Handle.http_client.newCall(request).execute()) {
System.out.println(response.body().string() + response.code());
var response_body = response.body().string();
Main.glogger.fine("status: " + response.code());
Main.glogger.fine("resp: " + response.body().string());
Main.glogger.fine("resp: " + response_body);
if (response.code() / 100 != 2) {
throw new Exception("request to pid registry failed with status code " + response.code() + ", reponse: " + response.body().string());
throw new Exception("request to pid registry failed with status code " + response.code() + ", reponse: " + response_body);
}
return response.body().string();
return response_body;
}
}
......@@ -170,7 +170,7 @@ class Sensor {
"with s, type.sensor_type as sensor_type, type.manufacturer as manufacturer, type.description as description\n" +
"match (s)--(all_measurements:MeasurementLocation)" +
"return s.pid, id(s), sensor_type, manufacturer, description min(all_measurements.first_msg), max(all_measurements.last_msg)"
"return s.pid, id(s), sensor_type, manufacturer, description, min(all_measurements.first_msg), max(all_measurements.last_msg)"
).withParameters(properties);
}
......
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