From b8d8f89b4017b371ee33593a98c12da575fb7260 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sat, 27 Aug 2016 15:52:45 +0200 Subject: [PATCH] Download many files in one go (#1869) * Download many files in one go * Added warnings dialog if 10 or more entries are selected for full text download * Extracted magic number and fixed file name generation fallback * Some code cleanups --- CHANGELOG.md | 2 + .../net/sf/jabref/cli/ArgumentProcessor.java | 2 +- .../jabref/external/DownloadExternalFile.java | 28 ++--- .../jabref/external/DroppedFileHandler.java | 2 +- .../jabref/external/FindFullTextAction.java | 106 +++++++++++------- .../sf/jabref/external/MoveFileAction.java | 2 +- .../gui/fieldeditors/FileListEditor.java | 2 +- .../net/sf/jabref/gui/groups/GroupsTree.java | 2 +- .../gui/importer/ImportInspectionDialog.java | 21 ++-- .../bibtex/comparator/EntryComparator.java | 12 +- .../net/sf/jabref/logic/util/io/FileUtil.java | 7 +- src/main/resources/l10n/JabRef_da.properties | 7 +- src/main/resources/l10n/JabRef_de.properties | 7 +- src/main/resources/l10n/JabRef_en.properties | 5 +- src/main/resources/l10n/JabRef_es.properties | 7 +- src/main/resources/l10n/JabRef_fa.properties | 7 +- src/main/resources/l10n/JabRef_fr.properties | 7 +- src/main/resources/l10n/JabRef_in.properties | 7 +- src/main/resources/l10n/JabRef_it.properties | 7 +- src/main/resources/l10n/JabRef_ja.properties | 7 +- src/main/resources/l10n/JabRef_nl.properties | 7 +- src/main/resources/l10n/JabRef_no.properties | 7 +- .../resources/l10n/JabRef_pt_BR.properties | 7 +- src/main/resources/l10n/JabRef_ru.properties | 7 +- src/main/resources/l10n/JabRef_sv.properties | 7 +- src/main/resources/l10n/JabRef_tr.properties | 7 +- src/main/resources/l10n/JabRef_vi.properties | 7 +- src/main/resources/l10n/JabRef_zh.properties | 7 +- .../sf/jabref/logic/util/io/FileUtilTest.java | 42 +++++++ .../net/sf/jabref/logic/xmp/XMPUtilTest.java | 2 + 30 files changed, 253 insertions(+), 94 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6039538cf2..f1ee8db2acb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Changed - Added integrity check for fields with BibTeX keys, e.g., `crossref` and `related`, to check that the key exists +- [#1496](https://github.com/JabRef/jabref/issues/1496) Keep track of which entry a downloaded file belongs to +- Made it possible to download multiple entries in one action ### Fixed - Fixed NullPointerException when opening search result window for an untitled database diff --git a/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java b/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java index be82b58a8da..7fea35dd088 100644 --- a/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java +++ b/src/main/java/net/sf/jabref/cli/ArgumentProcessor.java @@ -237,7 +237,7 @@ private List importAndOpenFiles() { // BIB files to open. Other files, and files that could not be opened // as bib, we try to import instead. boolean bibExtension = aLeftOver.toLowerCase(Locale.ENGLISH).endsWith("bib"); - ParserResult pr = null; + ParserResult pr = ParserResult.getNullResult(); if (bibExtension) { pr = OpenDatabase.loadDatabaseOrAutoSave(aLeftOver, false, Globals.prefs.getImportFormatPreferences()); diff --git a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java index c64fd598719..871d46609d9 100644 --- a/src/main/java/net/sf/jabref/external/DownloadExternalFile.java +++ b/src/main/java/net/sf/jabref/external/DownloadExternalFile.java @@ -21,6 +21,7 @@ import net.sf.jabref.logic.net.URLDownload; import net.sf.jabref.logic.util.OS; import net.sf.jabref.logic.util.io.FileUtil; +import net.sf.jabref.model.entry.BibEntry; import net.sf.jabref.preferences.JabRefPreferences; import org.apache.commons.logging.Log; @@ -43,15 +44,16 @@ public class DownloadExternalFile { private final JabRefFrame frame; private final BibDatabaseContext databaseContext; - private final String bibtexKey; + private final BibEntry entry; private FileListEntryEditor editor; private boolean downloadFinished; private boolean dontShowDialog; - public DownloadExternalFile(JabRefFrame frame, BibDatabaseContext databaseContext, String bibtexKey) { + + public DownloadExternalFile(JabRefFrame frame, BibDatabaseContext databaseContext, BibEntry entry) { this.frame = frame; this.databaseContext = databaseContext; - this.bibtexKey = bibtexKey; + this.entry = entry; } /** @@ -155,8 +157,8 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio } final String suggestDir = directory == null ? System.getProperty("user.home") : directory; File file = new File(new File(suggestDir), suggestedName); - FileListEntry entry = new FileListEntry("", file.getCanonicalPath(), suggestedType); - editor = new FileListEntryEditor(frame, entry, true, false, databaseContext); + FileListEntry fileListEntry = new FileListEntry("", file.getCanonicalPath(), suggestedType); + editor = new FileListEntryEditor(frame, fileListEntry, true, false, databaseContext); editor.getProgressBar().setIndeterminate(true); editor.setOkEnabled(false); editor.setExternalConfirm(closeEntry -> { @@ -181,7 +183,8 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio } // Editor closed. Go on: if (editor.okPressed()) { - File toFile = directory == null ? new File(entry.link) : expandFilename(directory, entry.link); + File toFile = directory == null ? new File(fileListEntry.link) : expandFilename(directory, + fileListEntry.link); String dirPrefix; if (directory == null) { dirPrefix = null; @@ -202,12 +205,13 @@ public void download(URL url, final DownloadCallback callback) throws IOExceptio // If the local file is in or below the main file directory, change the // path to relative: - if ((directory != null) && entry.link.startsWith(directory) && - (entry.link.length() > dirPrefix.length())) { - entry = new FileListEntry(entry.description, entry.link.substring(dirPrefix.length()), entry.type); + if ((dirPrefix != null) && fileListEntry.link.startsWith(directory) + && (fileListEntry.link.length() > dirPrefix.length())) { + fileListEntry = new FileListEntry(fileListEntry.description, + fileListEntry.link.substring(dirPrefix.length()), fileListEntry.type); } - callback.downloadComplete(entry); + callback.downloadComplete(fileListEntry); } catch (IOException ex) { LOGGER.warn("Problem downloading file", ex); } @@ -253,10 +257,8 @@ private void downloadFinished() { editor.getProgressBar().setValue(editor.getProgressBar().getMaximum()); } - // FIXME: will break download if no bibtexkey is present! private String getSuggestedFileName(String suffix) { - String plannedName = FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), - frame.getCurrentBasePanel().getSelectedEntries().get(0), + String plannedName = FileUtil.createFileNameFromPattern(databaseContext.getDatabase(), entry, Globals.prefs.get(JabRefPreferences.IMPORT_FILENAMEPATTERN), Globals.prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader)); diff --git a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java index ac5799715d0..a3ace55b28a 100644 --- a/src/main/java/net/sf/jabref/external/DroppedFileHandler.java +++ b/src/main/java/net/sf/jabref/external/DroppedFileHandler.java @@ -273,7 +273,7 @@ private boolean tryXmpImport(String fileName, ExternalFileType fileType, NamedCo panel.getBibDatabaseContext().getFileDirectory(Globals.prefs.getFileDirectoryPreferences())) .toString(); } else { - if (renameCheckBox.isSelected()) { + if (renameCheckBox.isSelected() || (single == null)) { destFilename = fileName; } else { destFilename = single.getCiteKey() + "." + fileType.getExtension(); diff --git a/src/main/java/net/sf/jabref/external/FindFullTextAction.java b/src/main/java/net/sf/jabref/external/FindFullTextAction.java index 32321abbd01..62241c72b2e 100644 --- a/src/main/java/net/sf/jabref/external/FindFullTextAction.java +++ b/src/main/java/net/sf/jabref/external/FindFullTextAction.java @@ -2,8 +2,12 @@ import java.io.IOException; import java.net.URL; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; import javax.swing.JOptionPane; @@ -26,9 +30,10 @@ public class FindFullTextAction extends AbstractWorker { private static final Log LOGGER = LogFactory.getLog(FindFullTextAction.class); + private static final int warningLimit = 10; // The minimum number of selected entries to ask the user for confirmation + private final BasePanel basePanel; - private BibEntry entry; - private Optional result; + private final Map, BibEntry> downloads = new ConcurrentHashMap<>(); public FindFullTextAction(BasePanel basePanel) { this.basePanel = basePanel; @@ -41,52 +46,73 @@ public void init() throws Throwable { @Override public void run() { - if (basePanel.getSelectedEntries().size() != 1) { - basePanel.output(Localization.lang("This operation requires exactly one item to be selected.")); - result = Optional.empty(); - } else { - entry = basePanel.getSelectedEntries().get(0); + if (basePanel.getSelectedEntries().size() >= warningLimit) { + String[] options = new String[]{Localization.lang("Look up full text documents"), Localization.lang("Cancel")}; + int answer = JOptionPane.showOptionDialog(basePanel.frame(), + Localization.lang( + "You are about to look up full text documents for %0 entries.", + String.valueOf(basePanel.getSelectedEntries().size())) + "\n" + + Localization.lang("Do you still want to continue?"), + Localization.lang("Look up full text documents"), JOptionPane.OK_CANCEL_OPTION, + JOptionPane.QUESTION_MESSAGE, null, options, options[0]); + if (answer != JOptionPane.OK_OPTION) { + basePanel.output(Localization.lang("Operation canceled.")); + return; + } + } + for (BibEntry entry : basePanel.getSelectedEntries()) { FulltextFetchers fft = new FulltextFetchers(); - result = fft.findFullTextPDF(entry); + downloads.put(fft.findFullTextPDF(entry), entry); } } @Override public void update() { - if (result.isPresent()) { - List dirs = basePanel.getBibDatabaseContext() - .getFileDirectory(Globals.prefs.getFileDirectoryPreferences()); - if (dirs.isEmpty()) { - JOptionPane.showMessageDialog(basePanel.frame(), - Localization.lang("Main file directory not set!") + " " + Localization.lang("Preferences") - + " -> " + Localization.lang("External programs"), - Localization.lang("Directory not found"), JOptionPane.ERROR_MESSAGE); - return; - } - String bibtexKey = entry.getCiteKey(); - // TODO: this needs its own thread as it blocks the UI! - DownloadExternalFile def = new DownloadExternalFile(basePanel.frame(), basePanel.getBibDatabaseContext(), bibtexKey); - try { - def.download(result.get(), file -> { - FileListTableModel tm = new FileListTableModel(); - entry.getField(FieldName.FILE).ifPresent(tm::setContent); - tm.addEntry(tm.getRowCount(), file); - String newValue = tm.getStringRepresentation(); - UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE, - entry.getField(FieldName.FILE).orElse(null), newValue); - entry.setField(FieldName.FILE, newValue); - basePanel.getUndoManager().addEdit(edit); - basePanel.markBaseChanged(); - }); - } catch (IOException e) { - LOGGER.warn("Problem downloading file", e); + List> remove = new ArrayList<>(); + for (Entry, BibEntry> download : downloads.entrySet()) { + BibEntry entry = download.getValue(); + Optional result = download.getKey(); + if (result.isPresent()) { + List dirs = basePanel.getBibDatabaseContext() + .getFileDirectory(Globals.prefs.getFileDirectoryPreferences()); + if (dirs.isEmpty()) { + JOptionPane.showMessageDialog(basePanel.frame(), + Localization.lang("Main file directory not set!") + " " + Localization.lang("Preferences") + + " -> " + Localization.lang("External programs"), + Localization.lang("Directory not found"), JOptionPane.ERROR_MESSAGE); + return; + } + DownloadExternalFile def = new DownloadExternalFile(basePanel.frame(), + basePanel.getBibDatabaseContext(), entry); + try { + def.download(result.get(), file -> { + FileListTableModel tm = new FileListTableModel(); + entry.getField(FieldName.FILE).ifPresent(tm::setContent); + tm.addEntry(tm.getRowCount(), file); + String newValue = tm.getStringRepresentation(); + UndoableFieldChange edit = new UndoableFieldChange(entry, FieldName.FILE, + entry.getField(FieldName.FILE).orElse(null), newValue); + entry.setField(FieldName.FILE, newValue); + basePanel.getUndoManager().addEdit(edit); + basePanel.markBaseChanged(); + }); + } catch (IOException e) { + LOGGER.warn("Problem downloading file", e); + } + basePanel.output(Localization.lang("Finished downloading full text document for entry %0.", + entry.getCiteKeyOptional().orElse(Localization.lang("undefined")))); + } else { + String title = Localization.lang("Full text document download failed"); + String message = Localization.lang("Full text document download failed for entry %0.", + entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))); + + basePanel.output(message); + JOptionPane.showMessageDialog(basePanel.frame(), message, title, JOptionPane.ERROR_MESSAGE); } - basePanel.output(Localization.lang("Finished downloading full text document")); + remove.add(result); } - else { - String message = Localization.lang("Full text document download failed"); - basePanel.output(message); - JOptionPane.showMessageDialog(basePanel.frame(), message, message, JOptionPane.ERROR_MESSAGE); + for (Optional result : remove) { + downloads.remove(result); } } } diff --git a/src/main/java/net/sf/jabref/external/MoveFileAction.java b/src/main/java/net/sf/jabref/external/MoveFileAction.java index 4d2a10dae00..69a0b421aec 100644 --- a/src/main/java/net/sf/jabref/external/MoveFileAction.java +++ b/src/main/java/net/sf/jabref/external/MoveFileAction.java @@ -140,7 +140,7 @@ public void actionPerformed(ActionEvent event) { } - if (!newFile.equals(file)) { + if ((newFile != null) && !newFile.equals(file)) { try { boolean success = file.renameTo(newFile); if (!success) { diff --git a/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java b/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java index 71d8fe3701a..7a079deeb40 100644 --- a/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java +++ b/src/main/java/net/sf/jabref/gui/fieldeditors/FileListEditor.java @@ -460,7 +460,7 @@ private void downloadFile() { } } DownloadExternalFile def = new DownloadExternalFile(frame, - frame.getCurrentBasePanel().getBibDatabaseContext(), bibtexKey.orElse(null)); + frame.getCurrentBasePanel().getBibDatabaseContext(), entryEditor.getEntry()); try { def.download(this); } catch (IOException ex) { diff --git a/src/main/java/net/sf/jabref/gui/groups/GroupsTree.java b/src/main/java/net/sf/jabref/gui/groups/GroupsTree.java index eea297dc766..ef3c792c70a 100644 --- a/src/main/java/net/sf/jabref/gui/groups/GroupsTree.java +++ b/src/main/java/net/sf/jabref/gui/groups/GroupsTree.java @@ -168,7 +168,7 @@ public void dragOver(DropTargetDragEvent dtde) { } else if (dtde .isDataFlavorSupported(TransferableEntrySelection.FLAVOR_INTERNAL)) { // check if node accepts explicit assignment - if (path == null) { + if (target == null) { dtde.rejectDrag(); } else { // this would be the place to check if the dragging entries diff --git a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java index 1f77cd09de5..d8cbd3c907e 100644 --- a/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java +++ b/src/main/java/net/sf/jabref/gui/importer/ImportInspectionDialog.java @@ -438,13 +438,10 @@ public void entryListComplete() { } /** - * Generate key for the selected entry only. + * Generate key for an entry. */ - private void generateKeySelectedEntry() { - if (selectionModel.getSelected().size() != 1) { - return; - } - BibEntry entry = selectionModel.getSelected().get(0); + private void generateKeyForEntry(BibEntry entry) { + entries.getReadWriteLock().writeLock().lock(); try { BibDatabase database; @@ -1166,21 +1163,19 @@ public void actionPerformed(ActionEvent actionEvent) { return; } entry = selectionModel.getSelected().get(0); - Optional bibtexKey = entry.getCiteKeyOptional(); - if (!bibtexKey.isPresent()) { + if (!entry.getCiteKeyOptional().isPresent()) { int answer = JOptionPane.showConfirmDialog(frame, Localization.lang("This entry has no BibTeX key. Generate key now?"), Localization.lang("Download file"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (answer == JOptionPane.OK_OPTION) { - generateKeySelectedEntry(); - bibtexKey = entry.getCiteKeyOptional(); + generateKeyForEntry(entry); } } - DownloadExternalFile def = new DownloadExternalFile(frame, bibDatabaseContext, bibtexKey.get()); + DownloadExternalFile def = new DownloadExternalFile(frame, bibDatabaseContext, entry); try { def.download(this); } catch (IOException ex) { - LOGGER.warn("Could not downlod file", ex); + LOGGER.warn("Could not download file", ex); } } @@ -1218,7 +1213,7 @@ public void actionPerformed(ActionEvent actionEvent) { Localization.lang("This entry has no BibTeX key. Generate key now?"), Localization.lang("Download file"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (answer == JOptionPane.OK_OPTION) { - generateKeySelectedEntry(); + generateKeyForEntry(entry); } else { return; // Can't go on without the bibtex key. } diff --git a/src/main/java/net/sf/jabref/logic/bibtex/comparator/EntryComparator.java b/src/main/java/net/sf/jabref/logic/bibtex/comparator/EntryComparator.java index 65b31ba7d14..eb6d682675a 100644 --- a/src/main/java/net/sf/jabref/logic/bibtex/comparator/EntryComparator.java +++ b/src/main/java/net/sf/jabref/logic/bibtex/comparator/EntryComparator.java @@ -87,12 +87,14 @@ public int compare(BibEntry e1, BibEntry e2) { } } - if ((f1 == null) && (f2 == null)) { - return next == null ? idCompare(e1, e2) : next.compare(e1, e2); - } - if ((f1 != null) && (f2 == null)) { - return -1; + if (f2 == null) { + if (f1 == null) { + return next == null ? idCompare(e1, e2) : next.compare(e1, e2); + } else { + return -1; + } } + if (f1 == null) { // f2 != null here automatically return 1; } diff --git a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java index 397eb07211e..d10bb88ab82 100644 --- a/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java +++ b/src/main/java/net/sf/jabref/logic/util/io/FileUtil.java @@ -379,7 +379,8 @@ public static List getListOfLinkedFiles(List bes, List f */ public static String createFileNameFromPattern(BibDatabase database, BibEntry entry, String fileNamePattern, LayoutFormatterPreferences prefs) { - String targetName = entry.getCiteKeyOptional().orElse("default"); + String targetName = null; + StringReader sr = new StringReader(fileNamePattern); Layout layout = null; try { @@ -390,6 +391,10 @@ public static String createFileNameFromPattern(BibDatabase database, BibEntry en if (layout != null) { targetName = layout.doLayout(entry, database); } + + if ((targetName == null) || targetName.isEmpty()) { + targetName = entry.getCiteKeyOptional().orElse("default"); + } //Removes illegal characters from filename targetName = FileNameCleaner.cleanFileName(targetName); return targetName; diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index c64fa5fb9c0..6799e06bf8c 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -869,7 +869,6 @@ Sort_the_following_fields_as_numeric_fields=Sorter_følgende_felter_som_numerisk Line_%0\:_Found_corrupted_BibTeX_key.=Linje_%0\:_Fandt_ødelagt_BibTeX-nøgle. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Linje_%0\:_Fandt_ødelagt_BibTeX-nøgle_(indeholder_blanktegn). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Linje_%0\:_Fandt_ødelagt_BibTeX-nøgle_(manglende_komma). -Finished_downloading_full_text_document=Download_af_fuldtekst-dokument_afsluttet Full_text_document_download_failed=Download_af_fuldtekst-dokument_mislykkedes Update_to_current_column_order=Brug_nuværende_kolonnerækkefølge @@ -1772,3 +1771,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 23ae5725c90..01cc8cb709c 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -1574,7 +1574,6 @@ Sort_the_following_fields_as_numeric_fields=Sortiere_folgende_Felder_als_numeris Line_%0\:_Found_corrupted_BibTeX_key.=Zeile_%0\:_Beschädigter_BibTeX-Key_gefunden. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Zeile_%0\:_Beschädigter_BibTeX-Key_gefunden_(enthält_Leerzeichen). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Zeile_%0\:_Beschädigter_BibTeX-Key_gefunden_(Komma_fehlt). -Finished_downloading_full_text_document=Herunterladen_des_Volltext-Dokuments_abgeschlossen Full_text_document_download_failed=Herunterladen_des_Volltext-Beitrags_fehlgeschlagen Update_to_current_column_order=Aktuelle_Spaltenanordnung_verwenden @@ -2484,3 +2483,9 @@ Opens_a_link_where_the_current_development_version_can_be_downloaded=Öffnet_ein See_what_has_been_changed_in_the_JabRef_versions=Beschreibt_was_in_den_verschiedenen_JabRef-Versionen_geändert_wurde Referenced_BibTeX_key_does_not_exist=Referenzierter_BibTeX-Key_existiert_nicht + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 5eb11730b5c..aca8fb7d1e2 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1465,7 +1465,6 @@ Sort_the_following_fields_as_numeric_fields=Sort_the_following_fields_as_numeric Line_%0\:_Found_corrupted_BibTeX_key.=Line_%0\:_Found_corrupted_BibTeX_key. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing). -Finished_downloading_full_text_document=Finished_downloading_full_text_document Full_text_document_download_failed=Full_text_document_download_failed Update_to_current_column_order=Update_to_current_column_order Download_from_URL=Download_from_URL @@ -2304,3 +2303,7 @@ Opens_JabRef's_website=Opens_JabRef's_website Opens_a_link_where_the_current_development_version_can_be_downloaded=Opens_a_link_where_the_current_development_version_can_be_downloaded See_what_has_been_changed_in_the_JabRef_versions=See_what_has_been_changed_in_the_JabRef_versions Referenced_BibTeX_key_does_not_exist=Referenced_BibTeX_key_does_not_exist +Finished_downloading_full_text_document_for_entry_%0.=Finished_downloading_full_text_document_for_entry_%0. +Full_text_document_download_failed_for_entry_%0.=Full_text_document_download_failed_for_entry_%0. +Look_up_full_text_documents=Look_up_full_text_documents +You_are_about_to_look_up_full_text_documents_for_%0_entries.=You_are_about_to_look_up_full_text_documents_for_%0_entries. \ No newline at end of file diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index 2565bcb5a81..57a3c9bde1e 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -805,7 +805,6 @@ Sort_the_following_fields_as_numeric_fields=Ordenar_los_siguientes_campos_como_c Line_%0\:_Found_corrupted_BibTeX_key.=Línea_%0\:_Se_ha_encontrado_una_clave_BibTeX_corrupta. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Línea_%0\:_Se_ha_encontrado_una_clave_BibTeX_corrupta_(contiene_espacios_en_blanco) Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Línea_%0\:_Se_ha_encontrado_clave_BibTeX_corrupta_(falta_coma). -Finished_downloading_full_text_document=Se_ha_finalizado_la_descarga_del_texto_completo_del_documento Full_text_document_download_failed=Falló_la_descarga_del_texto_completo_del_artículo Update_to_current_column_order=Actualizar_al_orden_de_columnas_actual Rename_field=Renombrar_campo @@ -1673,3 +1672,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 7844c7db703..15fab27a926 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -1529,7 +1529,6 @@ Back= Sort_the_following_fields_as_numeric_fields= Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).= Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).= -Finished_downloading_full_text_document= Full_text_document_download_failed= Update_to_current_column_order= @@ -2453,3 +2452,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 1a561885708..55db2f96dfc 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -807,7 +807,6 @@ Sort_the_following_fields_as_numeric_fields=Trier_les_champs_suivants_comme_des_ Line_%0\:_Found_corrupted_BibTeX_key.=Ligne_%0_\:_Clef_BibTeX_corrompue_trouvée. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Ligne_%0_\:_Clef_BibTeX_corrompue_trouvée_(contient_des_espaces). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Ligne_%0_\:_Clef_BibTeX_corrompue_trouvée_(virgule_manquante). -Finished_downloading_full_text_document=Téléchargement_du_document_cité_terminé Full_text_document_download_failed=Echec_du_téléchargement_du_document_cité Update_to_current_column_order=Enregistrer_l'ordre_actuel_des_colonnes @@ -1722,3 +1721,9 @@ Opens_a_link_where_the_current_development_version_can_be_downloaded=Ouvre_un_li See_what_has_been_changed_in_the_JabRef_versions=Afficher_les_changements_dans_les_versions_de_JabRef Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 42de880da92..df2188bd6d4 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -804,7 +804,6 @@ Sort_the_following_fields_as_numeric_fields=Urutkan_bidang_berikut_sepeerti_angk Line_%0\:_Found_corrupted_BibTeX_key.=Baris_%0\:_Ditemukan_kunci_BibTeX_ada_kesalahan. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Baris_%0\:_Ditemukan_kunci_BibTeX_ada_kesalahan_(mengandung_spasi_kosong). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Baris_%0\:_Ditemukan_kunci_BibTeX_ada_kesalahan_(tidak_ada_koma). -Finished_downloading_full_text_document=Selesai_muaturun_dokumen_teks_lengkap Full_text_document_download_failed=Gagal_muaturun_artikel_teks_lengkap Update_to_current_column_order=Perbarui_sebuai_urutan_kolom_sekarang Rename_field=Ganti_nama_bidang @@ -1689,3 +1688,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index d0b7179649b..4065b9611a2 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -884,7 +884,6 @@ Sort_the_following_fields_as_numeric_fields=Ordina_i_campi_seguenti_come_campi_n Line_%0\:_Found_corrupted_BibTeX_key.=Riga_%0\:_chiave_BibTeX_corrotta. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Riga_%0\:_chiave_BibTeX_corrotta_(contiene_spazi). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Riga_%0\:_chiave_BibTeX_corrotta_(virgola_mancante). -Finished_downloading_full_text_document=Terminato_il_download_del_documento_citato Full_text_document_download_failed=Fallito_il_download_del_documento_citato Update_to_current_column_order=Salvare_l'ordine_delle_colonne_attuale @@ -1790,3 +1789,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index df80ec240bd..d01a0d642a1 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -1554,7 +1554,6 @@ Sort_the_following_fields_as_numeric_fields=以下のフィールドは数値フ Line_%0\:_Found_corrupted_BibTeX_key.=%0行め\:_破損したBibTeX鍵を検出しました。 Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=%0行め\:_破損したBibTeX鍵を発見しました(空白が入っている)。 Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=%0行め\:_破損したBibTeX鍵を発見しました(コンマが欠落)。 -Finished_downloading_full_text_document=文書本体のダウンロードが終了しました Full_text_document_download_failed=論文本体のダウンロードに失敗しました Update_to_current_column_order=現在の列順に更新 @@ -2430,3 +2429,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index 769d5943e5b..3b5ac6cc930 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -1560,7 +1560,6 @@ Sort_the_following_fields_as_numeric_fields= Line_%0\:_Found_corrupted_BibTeX_key.= Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).= Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).= -Finished_downloading_full_text_document= Full_text_document_download_failed= Update_to_current_column_order= @@ -2462,3 +2461,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index 9916c538a6a..2ab20b12282 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -1763,7 +1763,6 @@ Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Linje_%0\:_Fant_ugy Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Linje_%0\:_Fant_ugyldig_BibTeX-n\u00b8kkel_(manglende_komma). -Finished_downloading_full_text_document=Fullf\u00b8rte_nedlasting_av_fulltekstdokument Full_text_document_download_failed=Kunne_ikke_laste_ned_fulltekstdokument @@ -2854,3 +2853,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index 6705327e152..3cf7b0a8724 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -805,7 +805,6 @@ Sort_the_following_fields_as_numeric_fields=Ordenar_os_seguintes_campos_como_cam Line_%0\:_Found_corrupted_BibTeX_key.=Linha_%0\:_Chave_BibTeX_corrompida_encontrada. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Linha_%0\:_Chave_BibTeX_corrompida_encontrada_(contém_espaços_em_branco). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Linha_%0\:_Chave_BibTeX_corrompida_encontrada_(vírgula_faltando). -Finished_downloading_full_text_document=O_download_do_texto_completo_foi_finalizado Full_text_document_download_failed=O_download_do_artigo_completo_falhou Update_to_current_column_order=Atualizar_para_ordenação_de_coluna_atual Rename_field=Renomear_campo @@ -1686,3 +1685,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 42d70ebee9e..e464cb07b28 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -1527,7 +1527,6 @@ Sort_the_following_fields_as_numeric_fields=Сортировать_следую Line_%0\:_Found_corrupted_BibTeX_key.=Строка_%0\:_Найден_поврежденный_ключ_BibTeX. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Строка_%0\:_Найден_поврежденный_ключ_BibTeX_(содержит_пробелы) Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Строка_%0\:_Найден_поврежденный_ключ_BibTeX_(пропущена_запятая) -Finished_downloading_full_text_document=Загрузка_цитируемого_документа_завершена Full_text_document_download_failed=Ошибка_загрузки_цитируемой_статьи Update_to_current_column_order=Сохранить_текущий_порядок_столбцов @@ -2431,3 +2430,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index a26154da30d..24a2b324fa2 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -465,7 +465,6 @@ Filter=Filtrera Find_and_remove_duplicate_BibTeX_keys=Hitta_och_ta_bort_duplicerade_BibTeX-nycklar Find_unlinked_files=Hitta_olänkade_filer Finished_automatically_setting_external_links.= -Finished_downloading_full_text_document=Nedladdning_av_dokument_avslutad Finished_resolving_duplicate_BibTeX_keys._%0_entries_modified.= Finished_synchronizing_file_links._Entries_changed\:_%0.=Synkronisering_av_fillänkar_avslutad._Ändrade_poster\:_%0. Finished_writing_XMP-metadata._Wrote_to_%0_file(s).=Skrivning_av_XMP-metadata_avslutad._Skrev_till_%0_fil(er). @@ -1634,3 +1633,9 @@ Opens_a_link_where_the_current_development_version_can_be_downloaded=Öpnnar_en_ See_what_has_been_changed_in_the_JabRef_versions=Se_vad_som_har_ändrats_i_de_olika_JabRef-versionerna Referenced_BibTeX_key_does_not_exist=Refererad_BibTeX-nyckel_finns_ej + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index ad89ba392ca..7c0788f43fa 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -809,7 +809,6 @@ Sort_the_following_fields_as_numeric_fields=Aşağıdaki_alanları_sayısal_olar Line_%0\:_Found_corrupted_BibTeX_key.=Satır_%0\:_Bozulmuş_BibTeX-anahtarı_bulundu. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Satır_%0\:_Bozulmuş_BibTeX-anahtarı_bulundu_(beyaz_boşluk_içeriyor). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Satır_%0\:_Bozulmuş_BibTeX-anahtarı_bulundu_(virgül_kayıp). -Finished_downloading_full_text_document=Tam_metin_belge_indirme_tamamlandı Full_text_document_download_failed=Tam_metin_makale_indirme_başarısız Update_to_current_column_order=Varolan_sütun_sırasına_güncelle @@ -1707,3 +1706,9 @@ Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index ef1144fd573..b0c7c917e43 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -1557,7 +1557,6 @@ Sort_the_following_fields_as_numeric_fields=Xếp_thứ_tự_các_trường_sau_ Line_%0\:_Found_corrupted_BibTeX_key.=Dòng_%0\:_Tìm_thấy_khóa-BibTeX_bị_lỗi. Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=Dòng_%0\:_Tìm_thấy_khóa-BibTeX_bị_lỗi_(chứa_khoảng_trắng). Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=Dòng_%0\:_Tìm_thấy_khóa-BibTeX_bị_lỗi_(thiếu_dấu_phẩy). -Finished_downloading_full_text_document=Tải_về_tài_liệu_đầy_đủ_hoàn_tất Full_text_document_download_failed=Việc_tải_về_bài_viết_đầy_đủ_thất_bại Update_to_current_column_order=Cập_nhật_theo_thứ_tự_cột_hiện_tại @@ -2457,3 +2456,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index 0431939a5cd..7b63ade3a8f 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -869,7 +869,6 @@ Sort_the_following_fields_as_numeric_fields=以数值方式排序下列域 Line_%0\:_Found_corrupted_BibTeX_key.=第_%0_行\:_发现错误的_BibTeX_键。 Line_%0\:_Found_corrupted_BibTeX_key_(contains_whitespaces).=第_%0_行\:_发现错误的_BibTeX_键(包含空格)。 Line_%0\:_Found_corrupted_BibTeX_key_(comma_missing).=第_%0_行\:_发现错误的_BibTeX_键(逗号丢失)。 -Finished_downloading_full_text_document=完成全文下载 Full_text_document_download_failed=下载全文失败 Update_to_current_column_order=使用当前视图中的列顺序 @@ -1698,3 +1697,9 @@ Opens_JabRef's_website= Opens_a_link_where_the_current_development_version_can_be_downloaded= See_what_has_been_changed_in_the_JabRef_versions= Referenced_BibTeX_key_does_not_exist= + + +Finished_downloading_full_text_document_for_entry_%0.= +Full_text_document_download_failed_for_entry_%0.= +Look_up_full_text_documents= +You_are_about_to_look_up_full_text_documents_for_%0_entries.= diff --git a/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java b/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java index 6d9bb50f8dc..8b3f5ac9d64 100644 --- a/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/util/io/FileUtilTest.java @@ -44,6 +44,48 @@ public void testGetLinkedFileNameBibTeXKey() { mock(LayoutFormatterPreferences.class))); } + @Test + public void testGetLinkedFileNameNoPattern() { + String fileNamePattern = ""; + BibEntry entry = new BibEntry(); + entry.setCiteKey("1234"); + entry.setField("title", "mytitle"); + + assertEquals("1234", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, + mock(LayoutFormatterPreferences.class))); + } + + @Test + public void testGetDefaultFileNameNoPatternNoBibTeXKey() { + String fileNamePattern = ""; + BibEntry entry = new BibEntry(); + entry.setField("title", "mytitle"); + + assertEquals("default", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, + mock(LayoutFormatterPreferences.class))); + } + + @Test + public void testGetLinkedFileNameGetKeyIfEmptyField() { + // bibkey - title + String fileNamePattern = "\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"; + BibEntry entry = new BibEntry(); + entry.setCiteKey("1234"); + + assertEquals("1234", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, + JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); + } + + @Test + public void testGetLinkedFileNameGetDefaultIfEmptyFieldNoKey() { + // bibkey - title + String fileNamePattern = "\\begin{title} - \\format[RemoveBrackets]{\\title}\\end{title}"; + BibEntry entry = new BibEntry(); + + assertEquals("default", FileUtil.createFileNameFromPattern(null, entry, fileNamePattern, + JabRefPreferences.getInstance().getLayoutFormatterPreferences(mock(JournalAbbreviationLoader.class)))); + } + @Test public void testGetFileExtensionSimpleFile() { assertEquals("pdf", FileUtil.getFileExtension(new File("test.pdf")).get()); diff --git a/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java b/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java index 33c627f8cc6..fb058d0cb4d 100644 --- a/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java +++ b/src/test/java/net/sf/jabref/logic/xmp/XMPUtilTest.java @@ -1015,6 +1015,7 @@ public void testWriteSingleUpdatesDCAndInfo() throws IOException, TransformerExc if (metaRaw == null) { Assert.fail(); + return; } XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw.createInputStream())); @@ -1394,6 +1395,7 @@ public void testResolveStrings2() throws IOException, TransformerException { if (metaRaw == null) { Assert.fail(); + return; // To avoid warnings } XMPMetadata meta = new XMPMetadata(XMLUtil.parse(metaRaw.createInputStream()));