Verified Owner
Top Fields Constructors Methods
org.jabref.logic.externalfiles

public Class LinkedFileTransferHelper

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.io.IOException, .UncheckedIOException, java.nio.file.Files, .Path, .StandardCopyOption, java.util.ArrayList, .List, .Optional, org.jabref.logic.FilePreferences, org.jabref.logic.util.io.FileUtil, org.jabref.model.TransferInformation, .TransferMode, org.jabref.model.database.BibDatabaseContext, org.jabref.model.entry.BibEntry, .LinkedFile, org.jooq.lambda.Unchecked, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
adjustLinkedFilesForTarget(FilePreferences
File preferences for both contexts
filePreferences
,
TransferInformation
The source database context where files are currently located - and the transferMode
transferInformation
,
BibDatabaseContext
The target database context where files should be accessible
targetContext
,
BibEntry
The entry in the targetContext
targetEntry
)

Adjusts linked files when copying entries from source to target context.

private static Optional<Path>
findInSubDirs(Path path, List<Path> directories)

pack-priv static Optional<Path>

Returns:

Optional containing the primary directory path, or empty if none found
getPrimaryPath
(BibDatabaseContext
The database context
context
,
FilePreferences
File preferences for the context
filePreferences
)

Gets the primary directory path for the given context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

LinkedFileTransferHelperback to summary
public LinkedFileTransferHelper()

Method Detail

adjustLinkedFilesForTargetback to summary
public static void adjustLinkedFilesForTarget(FilePreferences filePreferences, TransferInformation transferInformation, BibDatabaseContext targetContext, BibEntry targetEntry)

Adjusts linked files when copying entries from source to target context. Files that are not reachable from the target context will be copied. Files in the target context whose relative paths differ from the source will have their paths adjusted.

There is no need to know the source entry, because we are interested in the file paths only.

Parameters
filePreferences:FilePreferences

File preferences for both contexts

transferInformation:TransferInformation

The source database context where files are currently located - and the transferMode

targetContext:BibDatabaseContext

The target database context where files should be accessible

targetEntry:BibEntry

The entry in the targetContext

findInSubDirsback to summary
private static Optional<Path> findInSubDirs(Path path, List<Path> directories)
getPrimaryPathback to summary
pack-priv static Optional<Path> getPrimaryPath(BibDatabaseContext context, FilePreferences filePreferences)

Gets the primary directory path for the given context. This is a utility method extracted from the original implementation.

Parameters
context:BibDatabaseContext

The database context

filePreferences:FilePreferences

File preferences for the context

Returns:Optional<Path>

Optional containing the primary directory path, or empty if none found