Skip to content

Commit

Permalink
Integrate SpringerLink
Browse files Browse the repository at this point in the history
  • Loading branch information
calixtus committed Oct 14, 2024
1 parent e4fec55 commit d7e1583
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@

import org.jabref.logic.importer.FulltextFetcher;
import org.jabref.logic.importer.ImporterPreferences;
import org.jabref.logic.util.BuildInfo;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.identifier.DOI;

import com.airhacks.afterburner.injection.Injector;
import kong.unirest.core.HttpResponse;
import kong.unirest.core.JsonNode;
import kong.unirest.core.Unirest;
Expand All @@ -36,11 +34,9 @@ public class SpringerLink implements FulltextFetcher, CustomizableKeyFetcher {
private static final String API_URL = "https://api.springer.com/meta/v1/json";
private static final String CONTENT_HOST = "link.springer.com";

private final String apiKey;
private final ImporterPreferences importerPreferences;

public SpringerLink(ImporterPreferences importerPreferences) {
this.apiKey = Injector.instantiateModelOrService(BuildInfo.class).springerNatureAPIKey;
this.importerPreferences = importerPreferences;
}

Expand All @@ -57,7 +53,7 @@ public Optional<URL> findFullText(BibEntry entry) throws IOException {
// Available in catalog?
try {
HttpResponse<JsonNode> jsonResponse = Unirest.get(API_URL)
.queryString("api_key", importerPreferences.getApiKey(getName()).orElse(apiKey))
.queryString("api_key", importerPreferences.getApiKey(getName()).orElse(""))
.queryString("q", "doi:%s".formatted(doi.get().getDOI()))
.asJson();
if (jsonResponse.getBody() != null) {
Expand Down

0 comments on commit d7e1583

Please sign in to comment.