File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
main/java/org/jabref/logic/importer/fetcher
test/java/org/jabref/logic/importer/fetcher Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 33import java .io .IOException ;
44import java .net .URL ;
55import java .util .ArrayList ;
6+ import java .util .Arrays ;
67import java .util .List ;
78import java .util .Locale ;
89import java .util .Objects ;
3132public 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
Original file line number Diff line number Diff 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" );
You can’t perform that action at this time.
0 commit comments