Skip to content

Commit

Permalink
Throw BibEntryNotFound exception in case entry is no longer present (#…
Browse files Browse the repository at this point in the history
…4935)

* improve oo Logging

* fix typos

* Throw BibEntryNotFound exception in case entry is no longer present

Fixes  #4932

* add changelog

* fix wording and move nonNullRequire to the top
  • Loading branch information
Siedlerchr committed May 1, 2019
1 parent e73dd2e commit f1b4b5b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where ranking an entry would generate an IllegalArgumentException. [#4754](https://github.com/JabRef/jabref/issues/4754)
- We fixed an issue where special characters where removed from non label key generation pattern parts [#4767](https://github.com/JabRef/jabref/issues/4767)
- We fixed an issue where the RIS import would overwite the article date with the value of the acessed date [#4816](https://github.com/JabRef/jabref/issues/4816)
- We fixed an issue where an NullPointer exception was thrown when a referenced entry in an Open/Libre Office document was no longer present in the library. Now an error message with the reference marker of the missing entry is shown. [#4932](https://github.com/JabRef/jabref/issues/4932)



Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/openoffice/OOBibBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ private List<String> refreshCiteMarkersInternal(List<BibDatabase> databases, OOB
} else {
LOGGER.info("BibTeX key not found: '" + keys[j] + '\'');
LOGGER.info("Problem with reference mark: '" + names.get(i) + '\'');
cEntries[j] = new UndefinedBibtexEntry(keys[j]);
throw new BibEntryNotFoundException(names.get(i), Localization
.lang("Could not resolve BibTeX entry for citation marker '%0'.", names.get(i)));
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/logic/openoffice/OOBibStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,13 @@ private String getAuthorYearInTextMarker(List<BibEntry> entries, Map<BibEntry, B
* @return The resolved field content, or an empty string if the field(s) were empty.
*/
private String getCitationMarkerField(BibEntry entry, BibDatabase database, String field) {
Objects.requireNonNull(entry, "Entry cannot be null");
Objects.requireNonNull(database, "database cannot be null");

String authorField = getStringCitProperty(AUTHOR_FIELD);
String[] fields = field.split(FieldName.FIELD_SEPARATOR);
for (String s : fields) {

Optional<String> content = entry.getResolvedFieldOrAlias(s, database);

if ((content.isPresent()) && !content.get().trim().isEmpty()) {
Expand Down

0 comments on commit f1b4b5b

Please sign in to comment.