Commit 8bc05375 authored by j.hoerdt's avatar j.hoerdt
Browse files

use new httpclient and update uri

parent d37ef9f7
......@@ -64,8 +64,8 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# messages:
# com.xyz.foo.level = SEVERE
sensor2graph.Main.level = INFO
sensor2graph.Main.level = FINE
sensor2graph.Main.handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
global.level = INFO
global.level = FINE
global.handlers = java.util.logging.FileHandler
......@@ -208,18 +208,18 @@ public class Main {
private static Properties get_default_properties() {
Properties defaults = new Properties();
defaults.setProperty("already_uploaded_days_file", "already_uploaded_days.txt" );
defaults.setProperty("failed_to_upload_sensors_file", "failed_to_upload.txt" );
defaults.setProperty("database_name", "sensor" );
defaults.setProperty("csv_directory", "data/csv_files/" );
defaults.setProperty("geocoding_cache", "data/geocoding_cache/" );
defaults.setProperty("concurrency", "50" );
defaults.setProperty("http_agent", "Please/0.5" );
defaults.setProperty("neo4j_uri", "bolt://graphdb.gwdg.de:7687" );
defaults.setProperty("neo4j_server_certificate_file", "graphdb.gwdg.de.pem" );
defaults.setProperty("archive_uri", "https://archive.sensor.community/" );
defaults.setProperty("pid_registry_uri", "http://vm04.pid.gwdg.de:8081/handles/");
defaults.setProperty("prefix_for_new_pids", "21.T11998/" );
defaults.setProperty("already_uploaded_days_file", "already_uploaded_days.txt" );
defaults.setProperty("failed_to_upload_sensors_file", "failed_to_upload.txt" );
defaults.setProperty("database_name", "sensor" );
defaults.setProperty("csv_directory", "data/csv_files/" );
defaults.setProperty("geocoding_cache", "data/geocoding_cache/" );
defaults.setProperty("concurrency", "1" );
defaults.setProperty("http_agent", "Please/0.5" );
defaults.setProperty("neo4j_uri", "bolt://graphdb.gwdg.de:7687" );
defaults.setProperty("neo4j_server_certificate_file", "graphdb.gwdg.de.pem" );
defaults.setProperty("archive_uri", "https://archive.sensor.community/" );
defaults.setProperty("pid_registry_uri", "https://vm13.pid.gwdg.de:8000/api/handles/");
defaults.setProperty("prefix_for_new_pids", "21.11138/" );
return defaults;
}
......
......@@ -73,27 +73,21 @@ class Sensor {
Request request = new Request.Builder()
.url("https://vm13.pid.gwdg.de:8000/api/handles?prefix=21.11138")
.post(RequestBody.create(MediaType.parse("application/json", body.toString())))
.url(Main.pid_registry_uri + target_uri)
.method(RequestBody.create(MediaType.parse("application/json", body.toString())))
.header("Accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", "Handle clientCert=\"true\"")
.build();
try (Response response = http_client.newCall(request).execute()) {
try (Response response = Handle.http_client.newCall(request).execute()) {
System.out.println(response.body().string() + response.code());
Main.glogger.fine("status: " + response.code());
Main.glogger.fine("resp: " + response.body().string());
}
HttpRequest request = HttpRequest.newBuilder(URI.create(Main.pid_registry_uri + target_uri))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.method(method, BodyPublishers.ofString(body.toString())).build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
Main.glogger.fine("status: " + response.statusCode());
Main.glogger.fine("resp: " + response.body());
if (response.statusCode() / 100 != 2) {
if (response.code() / 100 != 2) {
throw new Exception("request to pid registry failed with status code " + response.statusCode() + ", reponse: " + response.body());
}
......
Supports Markdown
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