44
44
import org .jabref .logic .util .BackgroundTask ;
45
45
import org .jabref .logic .util .StandardFileType ;
46
46
import org .jabref .logic .util .TaskExecutor ;
47
+ import org .jabref .logic .util .URLUtil ;
47
48
import org .jabref .logic .util .UpdateField ;
48
49
import org .jabref .logic .util .io .FileUtil ;
49
50
import org .jabref .model .FieldChange ;
@@ -374,7 +375,7 @@ public List<BibEntry> handleBibTeXData(String entries) {
374
375
return result ;
375
376
} catch (ParseException ex ) {
376
377
LOGGER .error ("Could not paste" , ex );
377
- return Collections . emptyList ();
378
+ return List . of ();
378
379
}
379
380
}
380
381
@@ -400,16 +401,16 @@ public void importStringConstantsWithDuplicateCheck(Collection<BibtexString> str
400
401
401
402
public List <BibEntry > handleStringData (String data ) throws FetcherException {
402
403
if ((data == null ) || data .isEmpty ()) {
403
- return Collections . emptyList ();
404
+ return List . of ();
404
405
}
405
406
LOGGER .debug ("Checking if URL is a PDF: {}" , data );
406
407
407
- if (org . jabref . logic . util . URLUtil .isURL (data ) && data .toLowerCase ().endsWith (".pdf" )) {
408
+ if (URLUtil .isURL (data ) && data .toLowerCase ().endsWith (".pdf" )) {
408
409
try {
409
410
return handlePdfUrl (data );
410
411
} catch (IOException ex ) {
411
412
LOGGER .error ("Could not handle PDF URL" , ex );
412
- return Collections . emptyList ();
413
+ return List . of ();
413
414
}
414
415
}
415
416
@@ -434,7 +435,7 @@ private List<BibEntry> tryImportFormats(String data) {
434
435
return unknownFormatImport .parserResult ().getDatabase ().getEntries ();
435
436
} catch (ImportException ex ) { // ex is already localized
436
437
dialogService .showErrorDialogAndWait (Localization .lang ("Import error" ), ex );
437
- return Collections . emptyList ();
438
+ return List . of ();
438
439
}
439
440
}
440
441
@@ -462,7 +463,7 @@ private List<BibEntry> handlePdfUrl(String pdfUrl) throws IOException {
462
463
Optional <Path > targetDirectory = bibDatabaseContext .getFirstExistingFileDir (preferences .getFilePreferences ());
463
464
if (targetDirectory .isEmpty ()) {
464
465
LOGGER .warn ("File directory not available while downloading {}." , pdfUrl );
465
- return Collections . emptyList ();
466
+ return List . of ();
466
467
}
467
468
URLDownload urlDownload = new URLDownload (pdfUrl );
468
469
String filename = deriveFileNameFromUrl (pdfUrl );
@@ -471,7 +472,7 @@ private List<BibEntry> handlePdfUrl(String pdfUrl) throws IOException {
471
472
urlDownload .toFile (targetFile );
472
473
} catch (FetcherException fe ) {
473
474
LOGGER .error ("Error downloading PDF from URL" , fe );
474
- throw new IOException ( "Error downloading PDF" , fe );
475
+ return List . of ( );
475
476
}
476
477
try {
477
478
PdfMergeMetadataImporter importer = new PdfMergeMetadataImporter (preferences .getImportFormatPreferences ());
@@ -492,9 +493,9 @@ private List<BibEntry> handlePdfUrl(String pdfUrl) throws IOException {
492
493
entries .add (emptyEntry );
493
494
}
494
495
return entries ;
495
- } catch (Exception ex ) {
496
- LOGGER .error ("Error importing PDF from URL" , ex );
497
- return Collections . emptyList ();
496
+ } catch (IOException ex ) {
497
+ LOGGER .error ("Error importing PDF from URL - IO issue " , ex );
498
+ return List . of ();
498
499
}
499
500
}
500
501
0 commit comments