Skip to content

Commit fd9d760

Browse files
committed
fix: Apply Subhramit's suggestions
1 parent 737070c commit fd9d760

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

jabgui/src/main/java/org/jabref/gui/preferences/websearch/ApiKeyDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void initialize() {
5656
okButton.disableProperty().bind(apiKeyValid.not());
5757
}
5858

59-
apiKeyField.textProperty().addListener((obs, oldValue, newValue) -> {
59+
apiKeyField.textProperty().addListener((_, _, newValue) -> {
6060
apiKeyValid.set(newValue.isEmpty());
6161
testButton.setGraphic(null);
6262
testButton.setText(Localization.lang("Test connection"));

jabgui/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,17 +169,17 @@ public void setValues() {
169169
}
170170
boolean isEnabled = enabledCatalogs.contains(fetcher.getName());
171171
boolean isCustomizable = customizableFetcherNames.contains(fetcher.getName());
172-
FetcherViewModel vm = new FetcherViewModel(fetcher, isEnabled, isCustomizable);
172+
FetcherViewModel fetcherViewModel = new FetcherViewModel(fetcher, isEnabled, isCustomizable);
173173
if (isCustomizable) {
174174
savedApiKeys.stream()
175175
.filter(apiKey -> apiKey.getName().equals(fetcher.getName()))
176176
.findFirst()
177177
.ifPresent(apiKey -> {
178-
vm.apiKeyProperty().set(apiKey.getKey());
179-
vm.useCustomApiKeyProperty().set(apiKey.shouldUse());
178+
fetcherViewModel.apiKeyProperty().set(apiKey.getKey());
179+
fetcherViewModel.useCustomApiKeyProperty().set(apiKey.shouldUse());
180180
});
181181
}
182-
fetchers.add(vm);
182+
fetchers.add(fetcherViewModel);
183183
}
184184

185185
apikeyPersistAvailableProperty.setValue(OS.isKeyringAvailable());
@@ -211,11 +211,11 @@ public void storeSettings() {
211211
fetchers.stream()
212212
.filter(FetcherViewModel::isEnabled)
213213
.map(FetcherViewModel::getName)
214-
.collect(Collectors.toList()));
214+
.toList());
215215

216216
List<FetcherApiKey> apiKeysToStore = fetchers.stream()
217217
.filter(FetcherViewModel::isCustomizable)
218-
.map(vm -> new FetcherApiKey(vm.getName(), vm.shouldUseCustomApiKey(), vm.getApiKey()))
218+
.map(fetcherViewModel -> new FetcherApiKey(fetcherViewModel.getName(), fetcherViewModel.shouldUseCustomApiKey(), fetcherViewModel.getApiKey()))
219219
.toList();
220220

221221
importerPreferences.setPersistCustomKeys(apikeyPersistProperty.get());
@@ -308,6 +308,7 @@ public void checkApiKey(FetcherViewModel fetcherViewModel, String apiKey, Consum
308308

309309
try {
310310
URLDownload urlDownload = new URLDownload(testUrlWithoutApiKey + apiKey);
311+
// The HEAD request cannot be used because its response is not 200 (maybe 404 or 596...).
311312
int statusCode = ((HttpURLConnection) urlDownload.getSource().openConnection()).getResponseCode();
312313
return (statusCode >= 200) && (statusCode < 300);
313314
} catch (IOException | UnirestException e) {

0 commit comments

Comments
 (0)