Skip to content

Commit

Permalink
Fix QA issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
obraliar committed Sep 20, 2016
1 parent d8257e7 commit 5d30b42
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions src/main/java/net/sf/jabref/shared/DBMSConnectionProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,18 @@ private void setFromPreferences(SharedDatabasePreferences prefs) {
}
}

if (prefs.getHost().isPresent()) {
this.host = prefs.getHost().get();
}

if (prefs.getPort().isPresent()) {
this.port = Integer.parseInt(prefs.getPort().get());
}

if (prefs.getName().isPresent()) {
this.database = prefs.getName().get();
}
prefs.getHost().ifPresent(theHost -> this.host = theHost);
prefs.getPort().ifPresent(thePort -> this.port = Integer.parseInt(thePort));
prefs.getName().ifPresent(theDatabase -> this.database = theDatabase);

if (prefs.getUser().isPresent()) {
this.user = prefs.getUser().get();
}

if (prefs.getPassword().isPresent() && prefs.getUser().isPresent()) {
try {
this.password = new Password(prefs.getPassword().get().toCharArray(), prefs.getUser().get()).decrypt();
} catch (UnsupportedEncodingException | GeneralSecurityException e) {
LOGGER.error("Could not decrypt pasword" + e);
if (prefs.getPassword().isPresent()) {
try {
this.password = new Password(prefs.getPassword().get().toCharArray(), prefs.getUser().get()).decrypt();
} catch (UnsupportedEncodingException | GeneralSecurityException e) {
LOGGER.error("Could not decrypt password", e);
}
}
}

Expand All @@ -131,5 +122,4 @@ private void setFromPreferences(SharedDatabasePreferences prefs) {
this.password = "";
}
}

}

0 comments on commit 5d30b42

Please # to comment.