diff --git a/CHANGELOG.md b/CHANGELOG.md index 5246bd3355f..3bdd6c5c3f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,7 +66,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Removed - We removed some obsolete notifications. [#5555](https://github.com/JabRef/jabref/issues/5555) - +- We removed an internal step in the [ISBN-to-BibTeX fetcher](https://docs.jabref.org/import-using-publication-identifiers/isbntobibtex): The [ISBN to BibTeX Converter](https://manas.tungare.name/software/isbn-to-bibtex) by [@manastungare](https://github.com/manastungare) is not used anymore, because it is offline: "people using this tool have not been generating enough sales for Amazon." diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java index df78d4f25d2..eda85988ff6 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IsbnFetcher.java @@ -47,17 +47,10 @@ public Optional performSearchById(String identifier) throws FetcherExc IsbnViaEbookDeFetcher isbnViaEbookDeFetcher = new IsbnViaEbookDeFetcher(importFormatPreferences); Optional bibEntry = isbnViaEbookDeFetcher.performSearchById(identifier); - - // nothing found at ebook.de, try chimbori.com - if (!bibEntry.isPresent()) { - LOGGER.debug("No entry found at ebook.de try chimbori.com"); - IsbnViaChimboriFetcher isbnViaChimboriFetcher = new IsbnViaChimboriFetcher(importFormatPreferences); - bibEntry = isbnViaChimboriFetcher.performSearchById(identifier); - } - //nothing found at ebook.de and chimbori.com, try ottobib + // nothing found at ebook.de: try ottobib if (!bibEntry.isPresent()) { - LOGGER.debug("No entry found at ebook.de and chimbori.com try ottobib"); + LOGGER.debug("No entry found at ebook.de; trying ottobib"); IsbnViaOttoBibFetcher isbnViaOttoBibFetcher = new IsbnViaOttoBibFetcher(importFormatPreferences); bibEntry = isbnViaOttoBibFetcher.performSearchById(identifier); } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java deleted file mode 100644 index 068f039c8b6..00000000000 --- a/src/main/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcher.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.jabref.logic.importer.fetcher; - -import java.net.MalformedURLException; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.List; -import java.util.Optional; - -import org.jabref.logic.importer.FetcherException; -import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.ParseException; -import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.field.StandardField; -import org.jabref.model.strings.StringUtil; - -import kong.unirest.RawResponse; -import kong.unirest.Unirest; -import kong.unirest.UnirestException; - -/** - * Fetcher for ISBN using https://bibtex.chimbori.com/, which in turn uses Amazon's API. - */ -public class IsbnViaChimboriFetcher extends AbstractIsbnFetcher { - private RawResponse postResponse; - - public IsbnViaChimboriFetcher(ImportFormatPreferences importFormatPreferences) { - super(importFormatPreferences); - } - - @Override - public String getName() { - return "ISBN (Chimbori/Amazon)"; - } - - /** - * @return null, because the identifier is passed using form data. This method is not used. - */ - @Override - public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException { - return null; - } - - @Override - public Optional performSearchById(String identifier) throws FetcherException { - if (StringUtil.isBlank(identifier)) { - return Optional.empty(); - } - - this.ensureThatIsbnIsValid(identifier); - - postResponse = null; - try { - Unirest.post("https://bibtex.chimbori.com/isbn-bibtex") - .field("isbn", identifier) - .thenConsume(rawResponse -> postResponse = rawResponse); - } catch (UnirestException e) { - throw new FetcherException("Could not retrieve data from chimbori.com", e); - } - if (postResponse.getStatus() != 200) { - throw new FetcherException("Error while retrieving data from chimbori.com: " + postResponse.getContentAsString()); - } - - List fetchedEntries; - try { - fetchedEntries = getParser().parseEntries(postResponse.getContent()); - } catch (ParseException e) { - throw new FetcherException("An internal parser error occurred", e); - } - if (fetchedEntries.isEmpty()) { - return Optional.empty(); - } else if (fetchedEntries.size() > 1) { - LOGGER.info("Fetcher " + getName() + "found more than one result for identifier " + identifier - + ". We will use the first entry."); - } - - BibEntry entry = fetchedEntries.get(0); - - // chimbori does not return an ISBN. Thus, we add the one searched for - entry.setField(StandardField.ISBN, identifier); - - doPostCleanup(entry); - - return Optional.of(entry); - } - - @Override - public void doPostCleanup(BibEntry entry) { - // We MUST NOT clean the URL. this is the deal with @manastungare - see https://github.com/JabRef/jabref/issues/684#issuecomment-266541507 - // DO NOT add following code: - // new FieldFormatterCleanup(StandardField.URL, new ClearFormatter()).cleanup(entry); - } - -} diff --git a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java index b5d93a2be54..9ce8e083c35 100644 --- a/src/test/java/org/jabref/logic/importer/WebFetchersTest.java +++ b/src/test/java/org/jabref/logic/importer/WebFetchersTest.java @@ -5,7 +5,6 @@ import java.util.stream.Collectors; import org.jabref.logic.importer.fetcher.AbstractIsbnFetcher; -import org.jabref.logic.importer.fetcher.IsbnViaChimboriFetcher; import org.jabref.logic.importer.fetcher.IsbnViaEbookDeFetcher; import org.jabref.logic.importer.fetcher.IsbnViaOttoBibFetcher; import org.jabref.logic.importer.fetcher.MrDLibFetcher; @@ -41,7 +40,6 @@ void getIdBasedFetchersReturnsAllFetcherDerivingFromIdBasedFetcher() throws Exce expected.remove(AbstractIsbnFetcher.class); expected.remove(IdBasedParserFetcher.class); // Remove special ISBN fetcher since we don't want to expose them to the user - expected.remove(IsbnViaChimboriFetcher.class); expected.remove(IsbnViaEbookDeFetcher.class); expected.remove(IsbnViaOttoBibFetcher.class); assertEquals(expected, getClasses(idFetchers)); diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java index b699c6290e7..65bb0fd6dee 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IsbnFetcherTest.java @@ -97,10 +97,10 @@ void searchByEntryWithISBNSuccessful() throws FetcherException { /** * This test searches for a valid ISBN. See https://www.amazon.de/dp/3728128155/?tag=jabref-21 However, this ISBN is - * not available on ebook.de. The fetcher should something as it falls back to Chimbori + * not available on ebook.de. The fetcher should something as it falls back to OttoBib */ @Test - void searchForIsbnAvailableAtChimboriButNonOnEbookDe() throws FetcherException { + void searchForIsbnAvailableAtOttoBibButNonOnEbookDe() throws FetcherException { Optional fetchedEntry = fetcher.performSearchById("3728128155"); assertNotEquals(Optional.empty(), fetchedEntry); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java deleted file mode 100644 index 21fc0268564..00000000000 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaChimboriFetcherTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.jabref.logic.importer.fetcher; - -import java.util.Optional; - -import org.jabref.logic.importer.FetcherException; -import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.field.StandardField; -import org.jabref.model.entry.types.StandardEntryType; -import org.jabref.testutils.category.FetcherTest; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Answers; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.mockito.Mockito.mock; - -@FetcherTest -public class IsbnViaChimboriFetcherTest extends AbstractIsbnFetcherTest { - - @BeforeEach - public void setUp() { - bibEntry = new BibEntry(); - bibEntry.setType(StandardEntryType.Book); - bibEntry.setCiteKey("9780321356680"); - bibEntry.setField(StandardField.TITLE, "Effective Java (2nd Edition)"); - bibEntry.setField(StandardField.PUBLISHER, "Addison-Wesley"); - bibEntry.setField(StandardField.YEAR, "2008"); - bibEntry.setField(StandardField.AUTHOR, "Joshua Bloch"); - bibEntry.setField(StandardField.ISBN, "978-0321356680"); - bibEntry.setField(StandardField.URL, - "https://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683?SubscriptionId=AKIAIOBINVZYXZQZ2U3A&tag=chimbori05-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=0321356683"); - - fetcher = new IsbnViaChimboriFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS)); - } - - @Test - @Override - public void testName() { - assertEquals("ISBN (Chimbori/Amazon)", fetcher.getName()); - } - - @Test - @Override - public void testHelpPage() { - assertEquals("ISBNtoBibTeX", fetcher.getHelpPage().get().getPageName()); - } - - @Test - @Override - public void searchByIdSuccessfulWithShortISBN() throws FetcherException { - Optional fetchedEntry = fetcher.performSearchById("0321356683"); - bibEntry.setCiteKey("0321356683"); - bibEntry.setField(StandardField.ISBN, "0321356683"); - assertEquals(Optional.of(bibEntry), fetchedEntry); - } - - @Test - @Override - public void searchByIdSuccessfulWithLongISBN() throws FetcherException { - Optional fetchedEntry = fetcher.performSearchById("9780321356680"); - bibEntry.setCiteKey("9780321356680"); - bibEntry.setField(StandardField.ISBN, "9780321356680"); - assertEquals(Optional.of(bibEntry), fetchedEntry); - } - - @Test - @Override - public void authorsAreCorrectlyFormatted() throws Exception { - BibEntry bibEntry = new BibEntry(); - bibEntry.setType(StandardEntryType.Book); - bibEntry.setCiteKey("3642434738"); - bibEntry.setField(StandardField.TITLE, "Fundamentals of Business Process Management"); - bibEntry.setField(StandardField.PUBLISHER, "Springer"); - bibEntry.setField(StandardField.YEAR, "2015"); - bibEntry.setField(StandardField.AUTHOR, "Marlon Dumas and Marcello La Rosa and Jan Mendling and Hajo A. Reijers"); - bibEntry.setField(StandardField.ISBN, "3642434738"); - bibEntry.setField(StandardField.URL, - "https://www.amazon.com/Fundamentals-Business-Process-Management-Marlon/dp/3642434738?SubscriptionId=AKIAIOBINVZYXZQZ2U3A&tag=chimbori05-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=3642434738"); - - Optional fetchedEntry = fetcher.performSearchById("3642434738"); - assertEquals(Optional.of(bibEntry), fetchedEntry); - } - - @Test - public void searchForIsbnAvailableAtChimboriButNonOnEbookDe() throws Exception { - Optional fetchedEntry = fetcher.performSearchById("3728128155"); - assertNotEquals(Optional.empty(), fetchedEntry); - } -} diff --git a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaOttoBibFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaOttoBibFetcherTest.java index 526e5c57539..a9598f24a8a 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaOttoBibFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/IsbnViaOttoBibFetcherTest.java @@ -65,7 +65,7 @@ public void searchByIdSuccessfulWithLongISBN() throws FetcherException { @Test @Override public void authorsAreCorrectlyFormatted() throws Exception { - BibEntry bibEntry = new BibEntry(); + bibEntry = new BibEntry(); bibEntry.setType(StandardEntryType.Book); bibEntry.setCiteKey("dumas2018fundamentals"); bibEntry.setField(StandardField.TITLE, "Fundamentals of business process management");