diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e083af19d5..e0c698ec6cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,10 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added - We added a field showing the BibTeX/biblatex source for added and deleted entries in the "External Changes Resolver" dialog. [#9509](https://github.com/JabRef/jabref/issues/9509) -- Add "Attach file from URL" to right-click context menu which downloads file from URL and stores it with reference library. +- We added a full text fetcher for IACR eprints. [#9651](https://github.com/JabRef/jabref/pull/9651) +- We added "Attach file from URL" to right-click context menu to download and store a file with the reference library. [#9646](https://github.com/JabRef/jabref/issues/9646) +- We enabled updating an existing entry with data from InspireHEP. [#9351](https://github.com/JabRef/jabref/issues/9351) + diff --git a/src/main/java/org/jabref/logic/importer/WebFetchers.java b/src/main/java/org/jabref/logic/importer/WebFetchers.java index 7bde63f9678..453ac0c19db 100644 --- a/src/main/java/org/jabref/logic/importer/WebFetchers.java +++ b/src/main/java/org/jabref/logic/importer/WebFetchers.java @@ -196,6 +196,7 @@ public static Set getFullTextFetchers(ImportFormatPreferences i fetchers.add(new ArXivFetcher(importFormatPreferences)); fetchers.add(new IEEE(importFormatPreferences, importerPreferences)); fetchers.add(new ApsFetcher()); + fetchers.add(new IacrEprintFetcher(importFormatPreferences)); // Meta search // fetchers.add(new JstorFetcher(importFormatPreferences)); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java index 42777780515..65419881b46 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java @@ -1,11 +1,14 @@ package org.jabref.logic.importer.fetcher; import java.io.IOException; +import java.net.URL; +import java.util.Objects; import java.util.Optional; import java.util.function.Predicate; import java.util.regex.Pattern; import org.jabref.logic.importer.FetcherException; +import org.jabref.logic.importer.FulltextFetcher; import org.jabref.logic.importer.IdBasedFetcher; import org.jabref.logic.importer.ImportFormatPreferences; import org.jabref.logic.importer.ParseException; @@ -17,7 +20,7 @@ import org.jabref.model.strings.StringUtil; import org.jabref.model.util.DummyFileUpdateMonitor; -public class IacrEprintFetcher implements IdBasedFetcher { +public class IacrEprintFetcher implements FulltextFetcher, IdBasedFetcher { public static final String NAME = "IACR eprints"; @@ -26,6 +29,7 @@ public class IacrEprintFetcher implements IdBasedFetcher { private static final Predicate IDENTIFIER_PREDICATE = Pattern.compile("\\d{4}/\\d{3,5}").asPredicate(); private static final String CITATION_URL_PREFIX = "https://eprint.iacr.org/"; private static final String DESCRIPTION_URL_PREFIX = "https://eprint.iacr.org/"; + private static final String FULLTEXT_URL_PREFIX = "https://eprint.iacr.org/"; private static final String VERSION_URL_PREFIX = "https://eprint.iacr.org/archive/versions/"; private final ImportFormatPreferences prefs; @@ -130,4 +134,27 @@ private boolean isFromOrAfterYear2000(BibEntry entry) throws FetcherException { public String getName() { return NAME; } + + @Override + public Optional findFullText(BibEntry entry) throws IOException, FetcherException { + Objects.requireNonNull(entry); + + Optional urlField = entry.getField(StandardField.URL); + if (urlField.isPresent()) { + String descriptiveHtml = getHtml(urlField.get()); + String startOfFulltextLink = " allNonWithdrawnIdsWithOldHtmlFormat() { ids.removeAll(withdrawnIds); return ids.stream(); } + + @Test + public void getFulltextWithVersion() throws FetcherException, IOException { + Optional pdfUrl = fetcher.findFullText(abram2017); + assertEquals(Optional.of("https://eprint.iacr.org/archive/2017/1118/1511505927.pdf"), pdfUrl.map(URL::toString)); + } + + @Test + public void getFulltextWithoutVersion() throws FetcherException, IOException { + Optional pdfUrl = fetcher.findFullText(abram2017noVersion); + assertEquals(Optional.of("https://eprint.iacr.org/2017/1118.pdf"), pdfUrl.map(URL::toString)); + } + + @Test + public void getFulltextWithoutUrl() throws FetcherException, IOException { + BibEntry abram2017WithoutUrl = abram2017; + abram2017WithoutUrl.clearField(StandardField.URL); + Optional pdfUrl = fetcher.findFullText(abram2017WithoutUrl); + assertEquals(Optional.empty(), pdfUrl); + } + + @Test + public void getFulltextWithNonIACRUrl() throws IOException { + BibEntry abram2017WithNonIACRUrl = abram2017; + abram2017WithNonIACRUrl.setField(StandardField.URL, "https://example.com"); + assertThrows(FetcherException.class, () -> fetcher.findFullText(abram2017WithNonIACRUrl)); + } }