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

Fix #2417: DOI no longer contains URL #2425

Merged
merged 3 commits into from
Dec 22, 2016
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 @@ -17,6 +17,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- When using "Copy citation (HTML)" and pasting into a text editor, plain text is always pasted.
- When using the "Download from URL" functionality, one is not limited to http(s) URLs, but can, for instance, enter ftp URLs.
- When using the "Look up full text documents" functionality, JabRef warns more explicitly about multiple requests.
- The entry received from DOI does no longer contain the DOI as URL. Implements [#2417](https://github.com/JabRef/jabref/issues/2417).
- We use following parameters for the JVM on Windows and OSX: `-XX:+UseG1GC -XX:+UseStringDeduplication -XX:StringTableSize=1000003`.

### Fixed
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/net/sf/jabref/logic/importer/fetcher/DoiFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.nio.charset.StandardCharsets;
import java.util.Optional;

import net.sf.jabref.logic.formatter.bibtexfields.ClearFormatter;
import net.sf.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.importer.FetcherException;
Expand All @@ -15,7 +16,9 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.net.URLDownload;
import net.sf.jabref.logic.util.DOI;
import net.sf.jabref.model.cleanup.FieldFormatterCleanup;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldName;

public class DoiFetcher implements IdBasedFetcher {

Expand All @@ -25,10 +28,6 @@ public DoiFetcher(ImportFormatPreferences preferences) {
this.preferences = preferences;
}

private String cleanupEncoding(String bibtex) {
return new NormalizePagesFormatter().format(bibtex);
}

@Override
public String getName() {
return "DOI";
Expand All @@ -53,7 +52,9 @@ public Optional<BibEntry> performSearchById(String identifier) throws FetcherExc
String bibtexString = download.downloadToString(StandardCharsets.UTF_8);

// BibTeX entry
return BibtexParser.singleFromString(cleanupEncoding(bibtexString), preferences);
Optional<BibEntry> fetchedEntry = BibtexParser.singleFromString(bibtexString, preferences);
fetchedEntry.ifPresent(this::doPostCleanup);
return fetchedEntry;
} else {
throw new FetcherException(Localization.lang("Invalid_DOI:_'%0'.", identifier));
}
Expand All @@ -63,4 +64,9 @@ public Optional<BibEntry> performSearchById(String identifier) throws FetcherExc
throw new FetcherException("Could not parse BibTeX entry", e);
}
}

private void doPostCleanup(BibEntry entry) {
new FieldFormatterCleanup(FieldName.PAGES, new NormalizePagesFormatter()).cleanup(entry);
new FieldFormatterCleanup(FieldName.URL, new ClearFormatter()).cleanup(entry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void setUp() {
bibEntryBurd2011.setField("author", "Barry Burd");
bibEntryBurd2011.setField("month", "jul");
bibEntryBurd2011.setField("doi", "10.1002/9781118257517");
bibEntryBurd2011.setField("url", "http://dx.doi.org/10.1002/9781118257517");

bibEntryDecker2007 = new BibEntry();
bibEntryDecker2007.setType(BibLatexEntryTypes.INPROCEEDINGS);
Expand All @@ -44,7 +43,6 @@ public void setUp() {
bibEntryDecker2007.setField("month", "jul");
bibEntryDecker2007.setField("publisher", "Institute of Electrical and Electronics Engineers ({IEEE})");
bibEntryDecker2007.setField("title", "{BPEL}4Chor: Extending {BPEL} for Modeling Choreographies");
bibEntryDecker2007.setField("url", "http://dx.doi.org/10.1109/ICWS.2007.59");
bibEntryDecker2007.setField("year", "2007");
bibEntryDecker2007.setField("doi", "10.1109/icws.2007.59");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public void setUp() {
bibEntryBischof2009.setField("booktitle", "2009 35th Euromicro Conference on Software Engineering and Advanced Applications");
bibEntryBischof2009.setField("publisher", "Institute of Electrical and Electronics Engineers ({IEEE})");
bibEntryBischof2009.setField("title", "{BPELscript}: A Simplified Script Syntax for {WS}-{BPEL} 2.0");
bibEntryBischof2009.setField("url", "http://dx.doi.org/10.1109/seaa.2009.21");
bibEntryBischof2009.setField("year", "2009");
bibEntryBischof2009.setField("doi", "10.1109/seaa.2009.21");
}
Expand Down