From a1d2bf6936dbb1d6e89fcca6412b4d3095677812 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 2 May 2021 17:55:29 +0200 Subject: [PATCH] Make key for ScienceDirect configurable --- build.gradle | 3 ++- docs/advanced-reading/fetchers.md | 1 + .../java/org/jabref/logic/importer/fetcher/ScienceDirect.java | 3 ++- src/main/java/org/jabref/logic/util/BuildInfo.java | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index f7796aad992..24da247ae4f 100644 --- a/build.gradle +++ b/build.gradle @@ -278,7 +278,8 @@ processResources { "azureInstrumentationKey": System.getenv('AzureInstrumentationKey') ? System.getenv('AzureInstrumentationKey') : '', "springerNatureAPIKey": System.getenv('SpringerNatureAPIKey') ? System.getenv('SpringerNatureAPIKey') : '', "astrophysicsDataSystemAPIKey": System.getenv('AstrophysicsDataSystemAPIKey') ? System.getenv('AstrophysicsDataSystemAPIKey') : '', - "ieeeAPIKey": System.getenv('IEEEAPIKey') ? System.getenv('IEEEAPIKey') : '' + "ieeeAPIKey": System.getenv('IEEEAPIKey') ? System.getenv('IEEEAPIKey') : '', + "scienceDirectApiKey": System.getenv('SCIENCEDIRECTAPIKEY') ? System.getenv('SCIENCEDIRECTAPIKEY') : '' ) filteringCharset = 'UTF-8' } diff --git a/docs/advanced-reading/fetchers.md b/docs/advanced-reading/fetchers.md index 3903cb2d4e7..46d75c46b65 100644 --- a/docs/advanced-reading/fetchers.md +++ b/docs/advanced-reading/fetchers.md @@ -7,6 +7,7 @@ Fetchers are the implementation of the [search using online services](https://do | [IEEEXplore](https://docs.jabref.org/collect/import-using-online-bibliographic-database/ieeexplore) | [IEEE Xplore API portal](https://developer.ieee.org/) | `IEEEAPIKey` | 200 calls/day | | [MathSciNet](http://www.ams.org/mathscinet) | \(none\) | \(none\) | Depending on the current network | | [SAO/NASA Astrophysics Data System](https://docs.jabref.org/collect/import-using-online-bibliographic-database/ads) | [ADS UI](https://ui.adsabs.harvard.edu/user/settings/token) | `AstrophysicsDataSystemAPIKey` | 5000 calls/day | +| [ScienceDirect](https://www.sciencedirect.com/) | | `ScienceDirectApiKey` | | | [Springer Nature](https://docs.jabref.org/collect/import-using-online-bibliographic-database/springer) | [Springer Nature API Portal](https://dev.springernature.com/) | `SpringerNatureAPIKey` | 5000 calls/day | | [Zentralblatt Math](https://www.zbmath.org/) | \(none\) | \(none\) | Depending on the current network | diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java b/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java index 9db80d2b600..dd8868c3082 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ScienceDirect.java @@ -7,6 +7,7 @@ import org.jabref.logic.importer.FulltextFetcher; import org.jabref.logic.net.URLDownload; +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; @@ -31,7 +32,7 @@ public class ScienceDirect implements FulltextFetcher { private static final Logger LOGGER = LoggerFactory.getLogger(ScienceDirect.class); private static final String API_URL = "http://api.elsevier.com/content/article/doi/"; - private static final String API_KEY = "fb82f2e692b3c72dafe5f4f1fa0ac00b"; + private static final String API_KEY = new BuildInfo().scienceDirectApiKey; @Override public Optional findFullText(BibEntry entry) throws IOException { diff --git a/src/main/java/org/jabref/logic/util/BuildInfo.java b/src/main/java/org/jabref/logic/util/BuildInfo.java index 529772854b5..47ef962f21a 100644 --- a/src/main/java/org/jabref/logic/util/BuildInfo.java +++ b/src/main/java/org/jabref/logic/util/BuildInfo.java @@ -26,6 +26,7 @@ public final class BuildInfo { public final String springerNatureAPIKey; public final String astrophysicsDataSystemAPIKey; public final String ieeeAPIKey; + public final String scienceDirectApiKey; public final String minRequiredJavaVersion; public final boolean allowJava9; @@ -53,6 +54,7 @@ public BuildInfo(String path) { springerNatureAPIKey = BuildInfo.getValue(properties, "springerNatureAPIKey", "118d90a519d0fc2a01ee9715400054d4"); astrophysicsDataSystemAPIKey = BuildInfo.getValue(properties, "astrophysicsDataSystemAPIKey", "tAhPRKADc6cC26mZUnAoBt3MAjCvKbuCZsB4lI3c"); ieeeAPIKey = BuildInfo.getValue(properties, "ieeeAPIKey", "5jv3wyt4tt2bwcwv7jjk7pc3"); + scienceDirectApiKey = BuildInfo.getValue(properties, "scienceDirectApiKey", "fb82f2e692b3c72dafe5f4f1fa0ac00b"); minRequiredJavaVersion = properties.getProperty("minRequiredJavaVersion", "1.8"); allowJava9 = "true".equals(properties.getProperty("allowJava9", "true")); }