diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3ace7046089..8da79177b93 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
## [Unreleased]
### Changed
+- Added server timezone parameter when connecting to a shared database.
- We updated the dialog for setting up general fields.
- URL field formatting is updated. All whitespace chars, located at the beginning/ending of the url, are trimmed automatically
- We changed the behavior of the field formatting dialog such that the `bibtexkey` is not changed when formatting all fields or all text fields.
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
index c8c3d49729c..30808026c50 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialog.fxml
@@ -52,6 +52,8 @@
+
+
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
index 4964fd8bb2d..612c2267aea 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogView.java
@@ -43,6 +43,7 @@ public class SharedDatabaseLoginDialogView extends BaseDialog {
@FXML private TextField fileKeystore;
@FXML private PasswordField passwordKeystore;
@FXML private Button browseKeystore;
+ @FXML private TextField serverTimezone;
@Inject private DialogService dialogService;
@@ -83,6 +84,7 @@ private void initialize() {
user.textProperty().bindBidirectional(viewModel.userProperty());
password.textProperty().bindBidirectional(viewModel.passwordProperty());
port.textProperty().bindBidirectional(viewModel.portProperty());
+ serverTimezone.textProperty().bindBidirectional(viewModel.serverTimezoneProperty());
databaseType.valueProperty().bindBidirectional(viewModel.selectedDbmstypeProperty());
folder.textProperty().bindBidirectional(viewModel.folderProperty());
diff --git a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
index 18d0c881baf..dddbce8101a 100644
--- a/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
+++ b/src/main/java/org/jabref/gui/shared/SharedDatabaseLoginDialogViewModel.java
@@ -69,6 +69,7 @@ public class SharedDatabaseLoginDialogViewModel extends AbstractViewModel {
private final StringProperty keystore = new SimpleStringProperty("");
private final BooleanProperty useSSL = new SimpleBooleanProperty();
private final StringProperty keyStorePasswordProperty = new SimpleStringProperty("");
+ private final StringProperty serverTimezone = new SimpleStringProperty("");
private final JabRefFrame frame;
private final DialogService dialogService;
@@ -118,6 +119,7 @@ public void openDatabase() {
connectionProperties.setPassword(password.getValue());
connectionProperties.setUseSSL(useSSL.getValue());
connectionProperties.setKeyStore(keystore.getValue());
+ connectionProperties.setServerTimezone(serverTimezone.getValue());
setupKeyStore();
openSharedDatabase(connectionProperties);
@@ -200,6 +202,7 @@ private void setPreferences() {
prefs.setUser(user.getValue());
prefs.setUseSSL(useSSL.getValue());
prefs.setKeystoreFile(keystore.getValue());
+ prefs.setServerTimezone(serverTimezone.getValue());
if (rememberPassword.get()) {
try {
@@ -364,4 +367,6 @@ public ValidationStatus keystoreValidation() {
public ValidationStatus formValidation() {
return formValidator.getValidationStatus();
}
+
+ public StringProperty serverTimezoneProperty() { return serverTimezone; }
}
diff --git a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
index 6373c1e3035..f39eb8a41a4 100644
--- a/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
+++ b/src/main/java/org/jabref/logic/shared/DBMSConnectionProperties.java
@@ -28,6 +28,7 @@ public class DBMSConnectionProperties implements DatabaseConnectionProperties {
private String user;
private String password;
private boolean useSSL;
+ private String serverTimezone;
//Not needed for connection, but stored for future login
private String keyStore;
@@ -41,7 +42,7 @@ public DBMSConnectionProperties(SharedDatabasePreferences prefs) {
}
public DBMSConnectionProperties(DBMSType type, String host, int port, String database, String user,
- String password, boolean useSSL) {
+ String password, boolean useSSL, String serverTimezone) {
this.type = type;
this.host = host;
this.port = port;
@@ -49,6 +50,7 @@ public DBMSConnectionProperties(DBMSType type, String host, int port, String dat
this.user = user;
this.password = password;
this.useSSL = useSSL;
+ this.serverTimezone = serverTimezone;
}
@Override
@@ -118,6 +120,11 @@ public String getUrl() {
return type.getUrl(host, port, database);
}
+ @Override
+ public String getServerTimezone() { return serverTimezone; }
+
+ public void setServerTimezone(String serverTimezone) { this.serverTimezone = serverTimezone; }
+
/**
* Returns username, password and ssl as Properties Object
* @return Properties with values for user, password and ssl
@@ -126,6 +133,7 @@ public Properties asProperties() {
Properties props = new Properties();
props.setProperty("user", user);
props.setProperty("password", password);
+ props.setProperty("serverTimezone", serverTimezone);
if (useSSL) {
props.setProperty("ssl", Boolean.toString(useSSL));
@@ -161,7 +169,9 @@ public boolean equals(Object obj) {
&& Objects.equals(port, properties.getPort())
&& Objects.equals(database, properties.getDatabase())
&& Objects.equals(user, properties.getUser())
- && Objects.equals(useSSL, properties.isUseSSL());
+ && Objects.equals(useSSL, properties.isUseSSL())
+ && Objects.equals(serverTimezone, properties.getServerTimezone());
+
}
@Override
@@ -184,6 +194,7 @@ private void setFromPreferences(SharedDatabasePreferences prefs) {
prefs.getPort().ifPresent(thePort -> this.port = Integer.parseInt(thePort));
prefs.getName().ifPresent(theDatabase -> this.database = theDatabase);
prefs.getKeyStoreFile().ifPresent(theKeystore -> this.keyStore = theKeystore);
+ prefs.getServerTimezone().ifPresent(theServerTimezone -> this.serverTimezone = theServerTimezone);
this.setUseSSL(prefs.isUseSSL());
if (prefs.getUser().isPresent()) {
diff --git a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
index 14b306a6b94..45346f334a2 100644
--- a/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
+++ b/src/main/java/org/jabref/logic/shared/prefs/SharedDatabasePreferences.java
@@ -32,6 +32,7 @@ public class SharedDatabasePreferences {
private static final String SHARED_DATABASE_REMEMBER_PASSWORD = "sharedDatabaseRememberPassword";
private static final String SHARED_DATABASE_USE_SSL = "sharedDatabaseUseSSL";
private static final String SHARED_DATABASE_KEYSTORE_FILE = "sharedDatabaseKeyStoreFile";
+ private static final String SHARED_DATABASE_SERVER_TIMEZONE = "sharedDatabaseServerTimezone";
// This {@link Preferences} is used only for things which should not appear in real JabRefPreferences due to security reasons.
private final Preferences internalPrefs;
@@ -72,6 +73,10 @@ public Optional getKeyStoreFile() {
return getOptionalValue(SHARED_DATABASE_KEYSTORE_FILE);
}
+ public Optional getServerTimezone() {
+ return getOptionalValue(SHARED_DATABASE_SERVER_TIMEZONE);
+ }
+
public boolean getRememberPassword() {
return internalPrefs.getBoolean(SHARED_DATABASE_REMEMBER_PASSWORD, false);
}
@@ -116,6 +121,10 @@ public void setKeystoreFile(String keystoreFile) {
internalPrefs.put(SHARED_DATABASE_KEYSTORE_FILE, keystoreFile);
}
+ public void setServerTimezone(String serverTimezone) {
+ internalPrefs.put(SHARED_DATABASE_SERVER_TIMEZONE, serverTimezone);
+ }
+
public void clearPassword() {
internalPrefs.remove(SHARED_DATABASE_PASSWORD);
}
@@ -142,6 +151,7 @@ public void putAllDBMSConnectionProperties(DatabaseConnectionProperties properti
setUser(properties.getUser());
setUseSSL(properties.isUseSSL());
setKeystoreFile(properties.getKeyStore());
+ setServerTimezone(properties.getServerTimezone());
try {
setPassword(new Password(properties.getPassword().toCharArray(), properties.getUser()).encrypt());
diff --git a/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java b/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java
index 152078b6af7..d6966994bf0 100644
--- a/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java
+++ b/src/main/java/org/jabref/model/database/shared/DatabaseConnectionProperties.java
@@ -20,4 +20,6 @@ public interface DatabaseConnectionProperties {
boolean isUseSSL();
+ String getServerTimezone();
+
}
diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties
index 46918dfc565..056a1952eb0 100644
--- a/src/main/resources/l10n/JabRef_en.properties
+++ b/src/main/resources/l10n/JabRef_en.properties
@@ -2227,6 +2227,7 @@ User\:=User\:
Keystore\ password\:=Keystore password\:
Keystore\:=Keystore\:
Password\:=Password\:
+Server\ Timezone\:=Server Timezone\:
Remember\ Password=Remember Password
Use\ SSL=Use SSL
Move\ preprint\ information\ from\ 'URL'\ and\ 'journal'\ field\ to\ the\ 'eprint'\ field=Move preprint information from 'URL' and 'journal' field to the 'eprint' field
diff --git a/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java b/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java
index 1594d8a93da..d7fb060f4d0 100644
--- a/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java
+++ b/src/test/java/org/jabref/logic/shared/DBMSConnectionTest.java
@@ -26,6 +26,6 @@ public void testGetConnection(DBMSType dbmsType) throws SQLException, InvalidDBM
@Test
public void testGetConnectionFail(DBMSType dbmsType) throws SQLException, InvalidDBMSConnectionPropertiesException {
assertThrows(SQLException.class,
- () -> new DBMSConnection(new DBMSConnectionProperties(dbmsType, "XXXX", 0, "XXXX", "XXXX", "XXXX", false)).getConnection());
+ () -> new DBMSConnection(new DBMSConnectionProperties(dbmsType, "XXXX", 0, "XXXX", "XXXX", "XXXX", false, "XXXX")).getConnection());
}
}
diff --git a/src/test/java/org/jabref/logic/shared/TestConnector.java b/src/test/java/org/jabref/logic/shared/TestConnector.java
index 2d42b85e410..9949b83e649 100644
--- a/src/test/java/org/jabref/logic/shared/TestConnector.java
+++ b/src/test/java/org/jabref/logic/shared/TestConnector.java
@@ -17,15 +17,15 @@ public static DBMSConnection getTestDBMSConnection(DBMSType dbmsType) throws SQL
public static DBMSConnectionProperties getTestConnectionProperties(DBMSType dbmsType) {
if (dbmsType == DBMSType.MYSQL) {
- return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "jabref", "root", "", false);
+ return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "jabref", "root", "", false, "");
}
if (dbmsType == DBMSType.POSTGRESQL) {
- return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "jabref", "postgres", "", false);
+ return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "jabref", "postgres", "", false, "");
}
if (dbmsType == DBMSType.ORACLE) {
- return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "xe", "travis", "travis", false);
+ return new DBMSConnectionProperties(dbmsType, "localhost", dbmsType.getDefaultPort(), "xe", "travis", "travis", false, "");
}
return new DBMSConnectionProperties();