Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Jabref#7660 Unable to download some arXiv links if the "eprint" field is missing #7663

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590)
- We fixed an issue where journal abbreviations in UTF-8 were not recognized [#5850](https://github.com/JabRef/jabref/issues/5850)
- We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633)
- We fixed an issue where the article title with colon fails to download the arXiv link (pdf file). [#7660](https://github.com/JabRef/issues/7660)

### Removed

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.jabref.logic.cleanup.CleanupJob;
import org.jabref.logic.cleanup.EprintCleanup;
import org.jabref.logic.help.HelpFile;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.FulltextFetcher;
Expand Down Expand Up @@ -116,6 +118,9 @@ private Optional<ArXivEntry> searchForEntryById(String id) throws FetcherExcepti
}

private List<ArXivEntry> searchForEntries(BibEntry entry) throws FetcherException {
entry = (BibEntry) entry.clone();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you clone the entry?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do clean up on the original entry, its fields will be changed but I think we needn't change fields here because it is just a search.

CleanupJob cleanupJob = new EprintCleanup();
cleanupJob.cleanup(entry);
// 1. Eprint
Optional<String> identifier = entry.getField(StandardField.EPRINT);
if (StringUtil.isNotBlank(identifier)) {
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ void findFullTextByTitleWithCurlyBracket() throws IOException {
assertEquals(Optional.of(new URL("https://arxiv.org/pdf/2010.15942v2")), fetcher.findFullText(entry));
}

@Test
void findFullTextByTitleWithColonAndJournalWithoutEprint() throws IOException {
entry.setField(StandardField.TITLE, "Bayes-TrEx: a Bayesian Sampling Approach to Model Transparency by Example");
entry.setField(StandardField.JOURNAL, "arXiv:2002.10248v4 [cs]");

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2002.10248v4")), fetcher.findFullText(entry));
}

@Test
void findFullTextByTitleWithColonAndUrlWithoutEprint() throws IOException {
entry.setField(StandardField.TITLE, "Bayes-TrEx: a Bayesian Sampling Approach to Model Transparency by Example");
entry.setField(StandardField.URL, "http://arxiv.org/abs/2002.10248v4");

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/2002.10248v4")), fetcher.findFullText(entry));
}

@Test
void findFullTextByTitleAndPartOfAuthor() throws IOException {
entry.setField(StandardField.TITLE, "Pause Point Spectra in DNA Constant-Force Unzipping");
Expand Down