diff --git a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java index b3e0d15e05..93c3ac1d8f 100644 --- a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java +++ b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogHttpClient.java @@ -126,13 +126,19 @@ public static Builder builder() { * Disallow instantiation. */ private OlogHttpClient(String userName, String password) { - httpClient = HttpClient.newBuilder() - .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)) - .followRedirects(HttpClient.Redirect.ALWAYS) - // HttpClient rejects Duration.ZERO for the connect timeout value. - // To support infinite timeout (preference value == 0), use Long.MAX_VALUE - .connectTimeout(Duration.ofMillis(Preferences.connectTimeout <= 0 ? Long.MAX_VALUE : Preferences.connectTimeout)) - .build(); + if(Preferences.connectTimeout > 0){ + httpClient = HttpClient.newBuilder() + .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)) + .followRedirects(HttpClient.Redirect.ALWAYS) + .connectTimeout(Duration.ofMillis(Preferences.connectTimeout)) + .build(); + } + else{ + httpClient = HttpClient.newBuilder() + .cookieHandler(new CookieManager(null, CookiePolicy.ACCEPT_ALL)) + .followRedirects(HttpClient.Redirect.ALWAYS) + .build(); + } if (userName != null && password != null) { this.basicAuthenticationHeader = "Basic " + Base64.getEncoder().encodeToString((userName + ":" + password).getBytes()); @@ -456,7 +462,8 @@ public Collection listProperties() { public InputStream getAttachment(Long logId, String attachmentName) { try { HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(Preferences.olog_url + "/logs/attachments/" + logId + "/" + URLEncoder.encode(attachmentName, StandardCharsets.UTF_8))) + .uri(URI.create(Preferences.olog_url + "/logs/attachments/" + logId + "/" + + URLEncoder.encode(attachmentName, StandardCharsets.UTF_8).replace("+", "%20"))) // + char does not work in path element! .GET() .build(); HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream()); diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTable.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTable.java index 3835fa1882..892f223d7c 100644 --- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTable.java +++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogEntryTable.java @@ -57,18 +57,21 @@ public LogEntryTable(final LogEntryTableApp app) { loader.setResources(resourceBundle); loader.setLocation(this.getClass().getResource("LogEntryTableView.fxml")); + LogClient logClient = app.getClient(); + loader.setControllerFactory(clazz -> { try { - if (app.getClient() != null) { + if (logClient != null) { if (clazz.isAssignableFrom(LogEntryTableViewController.class)) { - LogEntryTableViewController logEntryTableViewController = (LogEntryTableViewController) clazz.getConstructor(LogClient.class, OlogQueryManager.class, SearchParameters.class).newInstance(app.getClient(), ologQueryManager, searchParameters); + LogEntryTableViewController logEntryTableViewController = (LogEntryTableViewController) clazz.getConstructor(LogClient.class, OlogQueryManager.class, SearchParameters.class) + .newInstance(logClient, ologQueryManager, searchParameters); logEntryTableViewController.setGoBackAndGoForwardActions(goBackAndGoForwardActions); logEntryTableViewController.setDecorations(decorations); return logEntryTableViewController; } else if (clazz.isAssignableFrom(AdvancedSearchViewController.class)) { - return clazz.getConstructor(LogClient.class, SearchParameters.class).newInstance(app.getClient(), searchParameters); + return clazz.getConstructor(LogClient.class, SearchParameters.class).newInstance(logClient, searchParameters); } else if (clazz.isAssignableFrom(SingleLogEntryDisplayController.class)) { - SingleLogEntryDisplayController singleLogEntryDisplayController = (SingleLogEntryDisplayController) clazz.getConstructor(LogClient.class).newInstance(app.getClient()); + SingleLogEntryDisplayController singleLogEntryDisplayController = (SingleLogEntryDisplayController) clazz.getConstructor(LogClient.class).newInstance(logClient); singleLogEntryDisplayController.setSelectLogEntryInUI(id -> goBackAndGoForwardActions.loadLogEntryWithID(id)); return singleLogEntryDisplayController; } else if (clazz.isAssignableFrom(LogEntryDisplayController.class)) { @@ -80,7 +83,7 @@ public LogEntryTable(final LogEntryTableApp app) { } else if (clazz.isAssignableFrom(AttachmentsEditorController.class)) { return clazz.getConstructor().newInstance(); } else if (clazz.isAssignableFrom(MergedLogEntryDisplayController.class)) { - return clazz.getConstructor(LogClient.class).newInstance(app.getClient()); + return clazz.getConstructor(LogClient.class).newInstance(logClient); } } else { // no logbook client available