Skip to content

Commit ce9f714

Browse files
committed
Merge commit '8c13808' into master
2 parents d7e39f3 + 8c13808 commit ce9f714

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/org/jabref/logic/importer/fetcher/DoiResolution.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.IOException;
44
import java.net.URL;
55
import java.util.ArrayList;
6+
import java.util.Arrays;
67
import java.util.List;
78
import java.util.Locale;
89
import java.util.Objects;
@@ -31,6 +32,11 @@
3132
public class DoiResolution implements FulltextFetcher {
3233
private static final Logger LOGGER = LoggerFactory.getLogger(DoiResolution.class);
3334

35+
/**
36+
* Hosts for which tailored fetchers exist, so this fetcher is not needed.
37+
*/
38+
private final List<String> excludedHosts = Arrays.asList("link.springer.com", "ieeexplore.ieee.org");
39+
3440
@Override
3541
public Optional<URL> findFullText(BibEntry entry) throws IOException {
3642
Objects.requireNonNull(entry);
@@ -57,7 +63,12 @@ public Optional<URL> findFullText(BibEntry entry) throws IOException {
5763
// some publishers are quite slow (default is 3s)
5864
connection.timeout(10000);
5965

60-
Document html = connection.get();
66+
Connection.Response response = connection.execute();
67+
if (excludedHosts.contains(response.url().getHost())) {
68+
return Optional.empty();
69+
}
70+
71+
Document html = response.parse();
6172
// scan for PDF
6273
Elements hrefElements = html.body().select("a[href]");
6374

src/test/java/org/jabref/logic/importer/fetcher/DoiResolutionTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ void notReturnAnythingWhenMultipleLinksAreFound() throws IOException {
5353
assertEquals(Optional.empty(), finder.findFullText(entry));
5454
}
5555

56+
@Test
57+
void notReturnAnythingWhenDOILeadsToSpringerLink() throws IOException {
58+
entry.setField(StandardField.DOI, "https://doi.org/10.1007/978-3-319-89963-3_28");
59+
assertEquals(Optional.empty(), finder.findFullText(entry));
60+
}
61+
62+
@Test
63+
void notReturnAnythingWhenDOILeadsToIEEE() throws IOException {
64+
entry.setField(StandardField.DOI, "https://doi.org/10.1109/TTS.2020.2992669");
65+
assertEquals(Optional.empty(), finder.findFullText(entry));
66+
}
67+
5668
@Test
5769
void notFoundByDOI() throws IOException {
5870
entry.setField(StandardField.DOI, "10.1186/unknown-doi");

0 commit comments

Comments
 (0)