Verified Owner
Top Inners Fields Constructors Methods
org.jabref.gui.linkedfile

public Class DownloadLinkedFileAction

extends SimpleCommand
Class Inheritance
Imports
java.io.IOException, java.net.MalformedURLException, .URL, java.nio.file.Files, .Path, .StandardCopyOption, java.util.ArrayList, .List, .Map, .Optional, javax.net.ssl.SSLHandshakeException, javafx.beans.property.DoubleProperty, .ReadOnlyDoubleProperty, .SimpleDoubleProperty, org.jabref.gui.DialogService, org.jabref.gui.actions.SimpleCommand, org.jabref.gui.externalfiletype.ExternalFileType, .ExternalFileTypes, .StandardExternalFileType, org.jabref.gui.fieldeditors.LinkedFilesEditorViewModel, .URLUtil, org.jabref.gui.frame.ExternalApplicationsPreferences, org.jabref.logic.FilePreferences, org.jabref.logic.bibtex.FileFieldWriter, org.jabref.logic.externalfiles.LinkedFileHandler, org.jabref.logic.importer.FetcherException, org.jabref.logic.l10n.Localization, org.jabref.logic.net.ProgressInputStream, .URLDownload, org.jabref.logic.undo.UndoManager, org.jabref.logic.util.BackgroundTask, .TaskExecutor, org.jabref.logic.util.io.FileNameUniqueness, .FileUtil, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .LinkedFile, org.jabref.model.entry.field.StandardField, org.jabref.model.undo.UndoableFieldChange, com.tobiasdiez.easybind.EasyBind, kong.unirest.core.UnirestException, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final BibDatabaseContext
private final DialogService
private Map<String, String>
private final DoubleProperty
private final String
private final BibEntry
private final ExternalApplicationsPreferences
private final FilePreferences
private final boolean
private final LinkedFile
private final LinkedFileHandler
private static final Logger
private final String
private final TaskExecutor
private final UndoManager
Inherited from org.jabref.gui.actions.SimpleCommand:
statusMessage

Constructor Summary

AccessConstructor and Description
public
DownloadLinkedFileAction(BibDatabaseContext databaseContext, BibEntry entry, LinkedFile linkedFile, String downloadUrl, DialogService dialogService, ExternalApplicationsPreferences externalApplicationsPreferences, FilePreferences filePreferences, TaskExecutor taskExecutor, String suggestedName, boolean keepHtmlLink, UndoManager undoManager)

public
DownloadLinkedFileAction(BibDatabaseContext databaseContext, BibEntry entry, LinkedFile linkedFile, String downloadUrl, DialogService dialogService, ExternalApplicationsPreferences externalApplicationsPreferences, FilePreferences filePreferences, TaskExecutor taskExecutor, UndoManager undoManager)

Downloads the given linked file to the first existing file directory.

Method Summary

Modifier and TypeMethod and Description
private boolean
private void
doDownload(Path targetDirectory, URLDownload urlDownload)

public ReadOnlyDoubleProperty
public void
private Optional<ExternalFileType>
private Optional<ExternalFileType>
private Optional<ExternalFileType>
private void
onFailure(URLDownload urlDownload, Exception ex)

private void
onSuccess(Path
The directory to store the file into. Is an absolute path.
targetDirectory
,
Path downloadedFile)

private org.jabref.logic.util.BackgroundTask<Path>
prepareDownloadTask(Path targetDirectory, URLDownload urlDownload)

public void
Inherited from org.jabref.gui.actions.SimpleCommand:
getProgressprogressPropertysetExecutablestatusMessageProperty

Field Detail

databaseContextback to summary
private final BibDatabaseContext databaseContext
dialogServiceback to summary
private final DialogService dialogService
downloadHeadersback to summary
private Map<String, String> downloadHeaders
downloadProgressback to summary
private final DoubleProperty downloadProgress
downloadUrlback to summary
private final String downloadUrl
entryback to summary
private final BibEntry entry
externalApplicationsPreferencesback to summary
private final ExternalApplicationsPreferences externalApplicationsPreferences
filePreferencesback to summary
private final FilePreferences filePreferences
linkedFileback to summary
private final LinkedFile linkedFile
linkedFileHandlerback to summary
private final LinkedFileHandler linkedFileHandler
LOGGERback to summary
private static final Logger LOGGER
suggestedNameback to summary
private final String suggestedName
taskExecutorback to summary
private final TaskExecutor taskExecutor
undoManagerback to summary
private final UndoManager undoManager

Constructor Detail

DownloadLinkedFileActionback to summary
public DownloadLinkedFileAction(BibDatabaseContext databaseContext, BibEntry entry, LinkedFile linkedFile, String downloadUrl, DialogService dialogService, ExternalApplicationsPreferences externalApplicationsPreferences, FilePreferences filePreferences, TaskExecutor taskExecutor, String suggestedName, boolean keepHtmlLink, UndoManager undoManager)
DownloadLinkedFileActionback to summary
public DownloadLinkedFileAction(BibDatabaseContext databaseContext, BibEntry entry, LinkedFile linkedFile, String downloadUrl, DialogService dialogService, ExternalApplicationsPreferences externalApplicationsPreferences, FilePreferences filePreferences, TaskExecutor taskExecutor, UndoManager undoManager)

Downloads the given linked file to the first existing file directory. It keeps HTML files as URLs.

Method Detail

checkSSLHandshakeback to summary
private boolean checkSSLHandshake(URLDownload urlDownload)
doDownloadback to summary
private void doDownload(Path targetDirectory, URLDownload urlDownload)
downloadProgressback to summary
public ReadOnlyDoubleProperty downloadProgress()
executeback to summary
public void execute()
Annotations
@Override
inferFileTypeback to summary
private Optional<ExternalFileType> inferFileType(URLDownload urlDownload)
inferFileTypeFromMimeTypeback to summary
private Optional<ExternalFileType> inferFileTypeFromMimeType(URLDownload urlDownload)
inferFileTypeFromURLback to summary
private Optional<ExternalFileType> inferFileTypeFromURL(String url)
onFailureback to summary
private void onFailure(URLDownload urlDownload, Exception ex)
onSuccessback to summary
private void onSuccess(Path targetDirectory, Path downloadedFile)
Parameters
targetDirectory:Path

The directory to store the file into. Is an absolute path.

prepareDownloadTaskback to summary
private org.jabref.logic.util.BackgroundTask<Path> prepareDownloadTask(Path targetDirectory, URLDownload urlDownload)
setDownloadHeadersback to summary
public void setDownloadHeaders(Map<String, String> headers)
org.jabref.gui.linkedfile back to summary

private Class DownloadLinkedFileAction.FileDownloadTask

extends BackgroundTask<Path>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Path
private final Map<String, String>
private final URL

Constructor Summary

AccessConstructor and Description
public
FileDownloadTask(URL source, Path destination, Map<String, String> headers)

Method Summary

Modifier and TypeMethod and Description
public Path
call()

Field Detail

destinationback to summary
private final Path destination
headersback to summary
private final Map<String, String> headers
sourceback to summary
private final URL source

Constructor Detail

FileDownloadTaskback to summary
public FileDownloadTask(URL source, Path destination, Map<String, String> headers)

Method Detail

callback to summary
public Path call() throws org.jabref.logic.importer.FetcherException, IOException
Annotations
@Override