diff --git a/app/logbook/olog/client-es/pom.xml b/app/logbook/olog/client-es/pom.xml
index 2296caace4..6276c06ffe 100644
--- a/app/logbook/olog/client-es/pom.xml
+++ b/app/logbook/olog/client-es/pom.xml
@@ -10,7 +10,6 @@
app-logbook-olog-client-es
-
com.sun.jersey
jersey-core
@@ -21,7 +20,6 @@
jersey-client
1.19
-
com.sun.jersey.contribs
jersey-multipart
diff --git a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogClient.java b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogClient.java
index a127982ca6..52a2ed6657 100644
--- a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogClient.java
+++ b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogClient.java
@@ -44,7 +44,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
-import java.net.http.HttpHeaders;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -89,13 +88,9 @@ public static class OlogClientBuilder {
private final String protocol;
private String username = null;
private String password = null;
- private String connectTimeoutAsString = null;
- private Boolean permissiveHostnameVerifier;
-
- private final OlogProperties properties = new OlogProperties();
private OlogClientBuilder() {
- this.ologURI = URI.create(this.properties.getPreferenceValue("olog_url"));
+ this.ologURI = URI.create(Preferences.olog_url);
this.protocol = this.ologURI.getScheme();
}
@@ -157,29 +152,21 @@ public OlogClient create() {
this.clientConfig = new DefaultClientConfig();
}
}
- if(this.username == null || this.password == null){
+ if (this.username == null || this.password == null) {
ScopedAuthenticationToken scopedAuthenticationToken = getCredentialsFromSecureStore();
- if(scopedAuthenticationToken != null){
+ if (scopedAuthenticationToken != null) {
this.username = scopedAuthenticationToken.getUsername();
this.password = scopedAuthenticationToken.getPassword();
+ } else {
+ this.username = Preferences.username != null ? Preferences.username : this.username;
+ this.password = Preferences.password != null ? Preferences.password : this.password;
}
- else{
- this.username = ifNullReturnPreferenceValue(this.username, "username");
- this.password = ifNullReturnPreferenceValue(this.password, "password");
- }
- }
- this.connectTimeoutAsString = ifNullReturnPreferenceValue(this.connectTimeoutAsString, "connectTimeout");
- int connectTimeout = 0;
- try {
- connectTimeout = Integer.parseInt(connectTimeoutAsString);
- } catch (NumberFormatException e) {
- Logger.getLogger(OlogClientBuilder.class.getPackageName())
- .warning("connectTimeout preference not set or invalid, using 0 (=infinite)");
}
+
+ int connectTimeout = Preferences.connectTimeout;
this.clientConfig.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectTimeout);
- this.permissiveHostnameVerifier = Boolean.parseBoolean(this.properties.getPreferenceValue("permissive_hostname_verifier"));
- if (this.permissiveHostnameVerifier) {
+ if (Preferences.permissive_hostname_verifier) {
HostnameVerifier allHostsValid = (hostname, session) -> true;
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
}
@@ -187,15 +174,7 @@ public OlogClient create() {
return new OlogClient(this.ologURI, this.clientConfig, this.withHTTPAuthentication, this.username, this.password);
}
- private String ifNullReturnPreferenceValue(String value, String key) {
- if (value == null) {
- return this.properties.getPreferenceValue(key);
- } else {
- return value;
- }
- }
-
- private ScopedAuthenticationToken getCredentialsFromSecureStore(){
+ private ScopedAuthenticationToken getCredentialsFromSecureStore() {
try {
SecureStore secureStore = new SecureStore();
return secureStore.getScopedAuthenticationToken(AuthenticationScope.LOGBOOK);
@@ -405,24 +384,9 @@ public List listLogs() {
return new ArrayList<>();
}
- /**
- * List of level values as defined in the properties file.
- */
- private List levels;
-
- /**
- * Service URL as configured by properties.
- */
- private String serviceUrl;
-
@Override
public Collection listLevels() {
- if (levels == null) {
- OlogProperties ologProperties = new OlogProperties();
- String[] levelList = ologProperties.getPreferenceValue("levels").split(",");
- levels = Arrays.asList(levelList);
- }
- return levels;
+ return Arrays.stream(Preferences.levels).toList();
}
@Override
@@ -466,11 +430,7 @@ public Collection listTags() {
@Override
public String getServiceUrl() {
- if (serviceUrl == null) {
- OlogProperties ologProperties = new OlogProperties();
- serviceUrl = ologProperties.getPreferenceValue("olog_url");
- }
- return serviceUrl;
+ return Preferences.olog_url;
}
@Override
@@ -549,7 +509,7 @@ public String serviceInfo() {
}
@Override
- public SearchResult getArchivedEntries(long id){
+ public SearchResult getArchivedEntries(long id) {
try {
final OlogSearchResult ologSearchResult = OlogObjectMappers.logEntryDeserializer.readValue(
service.path("logs/archived/" + id)
@@ -566,7 +526,7 @@ public SearchResult getArchivedEntries(long id){
}
@Override
- public Collection getTemplates(){
+ public Collection getTemplates() {
try {
return OlogObjectMappers.logEntryDeserializer.readValue(
service.path("templates").accept(MediaType.APPLICATION_JSON).get(String.class),
@@ -579,7 +539,7 @@ public Collection getTemplates(){
}
@Override
- public LogTemplate saveTemplate(LogTemplate template) throws LogbookException{
+ public LogTemplate saveTemplate(LogTemplate template) throws LogbookException {
ClientResponse clientResponse = service.path("templates").accept(MediaType.APPLICATION_JSON_TYPE)
.header("Content-Type", MediaType.APPLICATION_JSON_TYPE)
.put(ClientResponse.class, template);
diff --git a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogProperties.java b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogProperties.java
deleted file mode 100644
index 5a8b29647e..0000000000
--- a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/OlogProperties.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.phoebus.olog.es.api;
-
-import org.phoebus.framework.preferences.PreferencesReader;
-
-/**
- * The OlogProperties objects holds the properties associated with the
- * olog client library initialized using the olog_es_preferences.properties
- * or default values.
- *
- * @author shroffk
- *
- */
-public class OlogProperties {
-
- final PreferencesReader prefs;
-
- public OlogProperties() {
- prefs = new PreferencesReader(OlogProperties.class, "/olog_es_preferences.properties");
- }
-
- /**
- * check java preferences for the requested key
- * @param key
- * @return
- */
- public String getPreferenceValue(String key) {
- return prefs.get(key);
- }
-
-
-}
diff --git a/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/Preferences.java b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/Preferences.java
new file mode 100644
index 0000000000..761e59c199
--- /dev/null
+++ b/app/logbook/olog/client-es/src/main/java/org/phoebus/olog/es/api/Preferences.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2024 European Spallation Source ERIC.
+ */
+
+package org.phoebus.olog.es.api;
+
+import org.phoebus.framework.preferences.AnnotatedPreferences;
+import org.phoebus.framework.preferences.Preference;
+
+public class Preferences {
+
+ @Preference
+ public static String olog_url;
+
+ @Preference
+ public static int connectTimeout;
+
+ @Preference
+ public static boolean permissive_hostname_verifier;
+
+ @Preference
+ public static String username;
+
+ @Preference
+ public static String password;
+
+ @Preference
+ public static boolean debug;
+
+ @Preference public static String[] levels;
+
+ static
+ {
+ AnnotatedPreferences.initialize(Preferences.class, "/olog_es_preferences.properties");
+ }
+}
diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AdvancedSearchViewController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AdvancedSearchViewController.java
index 19c23d32e2..3a7e06bb95 100644
--- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AdvancedSearchViewController.java
+++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/AdvancedSearchViewController.java
@@ -24,7 +24,6 @@
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.geometry.Pos;
-import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
@@ -39,6 +38,7 @@
import org.phoebus.logbook.LogClient;
import org.phoebus.logbook.Logbook;
import org.phoebus.logbook.Tag;
+import org.phoebus.olog.es.api.Preferences;
import org.phoebus.ui.dialog.ListSelectionPopOver;
import org.phoebus.ui.dialog.PopOver;
import org.phoebus.ui.time.TimeRelativeIntervalPane;
@@ -51,7 +51,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.logging.Logger;
import java.util.stream.Collectors;
import static org.phoebus.logbook.olog.ui.LogbookQueryUtil.Keys;
@@ -62,8 +61,6 @@
*/
public class AdvancedSearchViewController {
- static final Logger logger = Logger.getLogger(AdvancedSearchViewController.class.getName());
-
@FXML
Label levelLabel;
@@ -108,7 +105,7 @@ public class AdvancedSearchViewController {
@FXML
private TextField attachmentTypes;
- private SearchParameters searchParameters;
+ private final SearchParameters searchParameters;
private final SimpleBooleanProperty sortAscending = new SimpleBooleanProperty(false);
private final SimpleBooleanProperty requireAttachments = new SimpleBooleanProperty(false);
@@ -254,7 +251,7 @@ public void initialize() {
if (tagSearchPopover.isShowing()) {
tagSearchPopover.hide();
} else {
- List selectedTags = Arrays.stream( searchParameters.tagsProperty().getValueSafe().split(","))
+ List selectedTags = Arrays.stream(searchParameters.tagsProperty().getValueSafe().split(","))
.map(String::trim)
.filter(it -> !it.isEmpty())
.collect(Collectors.toList());
@@ -272,7 +269,7 @@ public void initialize() {
if (logbookSearchPopover.isShowing()) {
logbookSearchPopover.hide();
} else {
- List selectedLogbooks = Arrays.stream( searchParameters.logbooksProperty().getValueSafe().split(","))
+ List selectedLogbooks = Arrays.stream(searchParameters.logbooksProperty().getValueSafe().split(","))
.map(String::trim)
.filter(it -> !it.isEmpty())
.collect(Collectors.toList());
@@ -286,7 +283,7 @@ public void initialize() {
}
});
- List levelList = logClient.listLevels().stream().collect(Collectors.toList());
+ List levelList = Arrays.stream(Preferences.levels).toList();
levelSelector.getItems().add("");
levelSelector.getItems().addAll(levelList);
@@ -307,7 +304,7 @@ public AnchorPane getPane() {
/**
* Updates non-text field controls so that search parameter values are correctly rendered.
*
- * @param queryString
+ * @param queryString Query string containing search terms and values
*/
private void updateControls(String queryString) {
Map queryStringParameters = LogbookQueryUtil.parseHumanReadableQueryString(queryString);
@@ -315,7 +312,7 @@ private void updateControls(String queryString) {
Keys keys = Keys.findKey(entry.getKey());
if (keys != null) {
if (keys.equals(Keys.LEVEL)) {
- List levels = logClient.listLevels().stream().collect(Collectors.toList());
+ List levels = Arrays.stream(Preferences.levels).toList();
if (levels.contains(entry.getValue())) {
searchParameters.levelProperty().setValue(entry.getValue());
} else {
@@ -371,7 +368,7 @@ protected List getValidatedTagsSelection(String tags) {
return validatedLogbookNames;
}
- public SimpleBooleanProperty getSortAscending(){
+ public SimpleBooleanProperty getSortAscending() {
return sortAscending;
}
diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookUIPreferences.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookUIPreferences.java
index 9b2cc23d7f..eec1525442 100644
--- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookUIPreferences.java
+++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/LogbookUIPreferences.java
@@ -9,37 +9,47 @@
import org.phoebus.framework.preferences.AnnotatedPreferences;
import org.phoebus.framework.preferences.Preference;
-import org.phoebus.framework.preferences.PreferencesReader;
-import org.phoebus.logbook.LogService;
-import java.util.logging.Level;
-
-import static org.phoebus.ui.application.PhoebusApplication.logger;
-
-/** Preference settings for logbook.ui
- * @author Evan Smith
+/**
+ * Preference settings for logbook.ui
+ *
+ * @author Evan Smith
*/
@SuppressWarnings("nls")
-public class LogbookUIPreferences
-{
- @Preference public static String[] default_logbooks;
- @Preference public static String default_logbook_query;
- @Preference public static String calendar_view_item_stylesheet;
- @Preference public static String level_field_name;
- @Preference public static String markup_help;
- @Preference public static String web_client_root_URL;
- @Preference public static boolean log_entry_groups_support;
- @Preference public static boolean log_entry_update_support;
- @Preference public static String[] hidden_properties;
- @Preference public static String log_entry_table_display_name;
- @Preference public static String log_entry_calendar_display_name;
- @Preference public static String log_attribute_desc;
- @Preference public static int search_result_page_size;
- @Preference public static int query_list_size;
- @Preference public static String search_help;
+public class LogbookUIPreferences {
+ @Preference
+ public static String[] default_logbooks;
+ @Preference
+ public static String default_logbook_query;
+ @Preference
+ public static String calendar_view_item_stylesheet;
+ @Preference
+ public static String level_field_name;
+ @Preference
+ public static String markup_help;
+ @Preference
+ public static String web_client_root_URL;
+ @Preference
+ public static boolean log_entry_groups_support;
+ @Preference
+ public static boolean log_entry_update_support;
+ @Preference
+ public static String[] hidden_properties;
+ @Preference
+ public static String log_entry_table_display_name;
+ @Preference
+ public static String log_entry_calendar_display_name;
+ @Preference
+ public static String log_attribute_desc;
+ @Preference
+ public static int search_result_page_size;
+ @Preference
+ public static int query_list_size;
+ @Preference
+ public static String search_help;
+
- static
- {
- final PreferencesReader prefs = AnnotatedPreferences.initialize(LogbookUIPreferences.class, "/log_olog_ui_preferences.properties");
+ static {
+ AnnotatedPreferences.initialize(LogbookUIPreferences.class, "/log_olog_ui_preferences.properties");
}
}
diff --git a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java
index 5950e3321a..dc68d0f5e3 100644
--- a/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java
+++ b/app/logbook/olog/ui/src/main/java/org/phoebus/logbook/olog/ui/write/LogEntryEditorController.java
@@ -72,7 +72,6 @@
import org.phoebus.logbook.olog.ui.LogbookUIPreferences;
import org.phoebus.logbook.olog.ui.Messages;
import org.phoebus.logbook.olog.ui.PreviewViewer;
-import org.phoebus.olog.es.api.OlogProperties;
import org.phoebus.olog.es.api.model.OlogLog;
import org.phoebus.security.store.SecureStore;
import org.phoebus.security.tokens.AuthenticationScope;
@@ -343,8 +342,7 @@ public void initialize() {
levelLabel.setText(LogbookUIPreferences.level_field_name);
// Sites may wish to define a different meaning and name for the "level" field.
- OlogProperties ologProperties = new OlogProperties();
- String[] levelList = ologProperties.getPreferenceValue("levels").split(",");
+ String[] levelList = org.phoebus.olog.es.api.Preferences.levels;
availableLevels.addAll(Arrays.asList(levelList));
levelSelector.setItems(availableLevels);
selectedLevelProperty.set(logEntry.getLevel() != null ? logEntry.getLevel() : availableLevels.get(0));