From 49c3e1f719cd5ac963fb0ffff330fc9c03298546 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 3 Jun 2020 09:09:05 +0200 Subject: [PATCH 1/3] Fix XMP Exctrator not returning empty optional Fixes #6577 --- CHANGELOG.md | 1 + .../java/org/jabref/logic/xmp/DublinCoreExtractor.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index deecc643b20..948e77fb49d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -352,6 +352,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the "Attach file" dialog, in the right-click menu for an entry, started on the working directory instead of the user's main directory. [#4995](https://github.com/JabRef/jabref/issues/4995) - We fixed an issue where the JabRef Icon in the macOS launchpad was not displayed correctly [#5003](https://github.com/JabRef/jabref/issues/5003) - We fixed an issue where the "Search for unlinked local files" would throw an exception when parsing the content of a PDF-file with missing "series" information [#5128](https://github.com/JabRef/jabref/issues/5128) +- We fixed an issue where the XMP Importer would incorrectly return an empty default entry when importing pdfs [#6577](https://github.com/JabRef/jabref/issues/6577) ### Removed diff --git a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java index 9c54524bc0a..081c1cb9cdb 100644 --- a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java +++ b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java @@ -61,7 +61,7 @@ private void extractEditor() { private void extractAuthor() { List creators = dcSchema.getCreators(); if ((creators != null) && !creators.isEmpty()) { - bibEntry.setField(StandardField.AUTHOR, String.join(" and ", creators)); + bibEntry.setField(StandardField.AUTHOR, String.join(" and ", creators)); } } @@ -242,10 +242,10 @@ public Optional extractBibtexEntry() { this.extractTitle(); this.extractType(); - if (bibEntry.getType() == null) { - bibEntry.setType(BibEntry.DEFAULT_TYPE); + //we pass a new BibEntry in the constructor which is never empty as it already consists of "@misc" + if (bibEntry.equals(new BibEntry())) { + return Optional.empty(); } - return Optional.of(bibEntry); } From 21ce996cbfffe5b1b29cdd7be3efa76920a5cd2d Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 3 Jun 2020 09:20:09 +0200 Subject: [PATCH 2/3] fix comment checkstyle arght --- src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java index 081c1cb9cdb..06ad8e9d79d 100644 --- a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java +++ b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java @@ -242,7 +242,7 @@ public Optional extractBibtexEntry() { this.extractTitle(); this.extractType(); - //we pass a new BibEntry in the constructor which is never empty as it already consists of "@misc" + // we pass a new BibEntry in the constructor which is never empty as it already consists of "@misc" if (bibEntry.equals(new BibEntry())) { return Optional.empty(); } From db00267716c9eae86c386b7d28b6729eb451c465 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Wed, 3 Jun 2020 18:52:17 +0200 Subject: [PATCH 3/3] check if fields are empty --- src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java index 06ad8e9d79d..fdf91c478e6 100644 --- a/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java +++ b/src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java @@ -243,7 +243,7 @@ public Optional extractBibtexEntry() { this.extractType(); // we pass a new BibEntry in the constructor which is never empty as it already consists of "@misc" - if (bibEntry.equals(new BibEntry())) { + if (bibEntry.getFieldMap().isEmpty()) { return Optional.empty(); } return Optional.of(bibEntry);