Verified Owner
Top Fields Constructors Methods
org.jabref.migrations

public Class PreferencesMigrations

extends Object
Class Inheritance
Imports
java.util.ArrayList, .EnumSet, .HashSet, .LinkedHashMap, .List, .Locale, .Optional, .SequencedMap, .Set, java.util.function.UnaryOperator, java.util.prefs.BackingStoreException, .Preferences, java.util.stream.Collectors, javafx.scene.control.TableColumn, org.jabref.gui.keyboard.KeyBinding, org.jabref.gui.maintable.ColumnPreferences, .MainTableColumnModel, org.jabref.gui.preferences.JabRefGuiPreferences, org.jabref.gui.theme.StyleSheet, .ThemeColorScheme, .ThemePreset, org.jabref.logic.citationkeypattern.GlobalCitationKeyPatterns, org.jabref.logic.cleanup.CleanupPreferences, .FieldFormatterCleanupActions, org.jabref.logic.os.OS, org.jabref.logic.preferences.JabRefCliPreferences, org.jabref.logic.preview.TextBasedPreviewLayout, org.jabref.logic.shared.security.Password, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntryTypesManager, org.jabref.model.entry.field.SpecialField, .StandardField, org.jabref.model.entry.types.EntryTypeFactory, com.github.javakeyring.Keyring, org.slf4j.Logger, .LoggerFactory, tools.jackson.databind.ObjectMapper

Field Summary

Modifier and TypeField and Description
private static final Set<String>
private static final Set<String>
private static final Set<String>
LEGACY_GENERAL_TAB_NAMES

The names the default tabs were stored under, in every translation shipped between JabRef 3.8.2 and the 6.0 alphas (harvested from the v3.8.2, v4.3.1, and v5.15 tags plus the current bundles), lower-cased.

private static final Set<String>
private static final Logger
public static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
pack-priv static void
private static void
private static boolean
isLegacyDefaultTab(String name, List<String> fields)

Whether a pre-v6.0-alpha.7 custom tab is one of the former default tabs "General", "Abstract", "Comments" (JabRef 5.x), or "Review" (JabRef ≤ 4.x).

private static Set<Set<String>>
legacyGeneralFieldSets()

The "General" default field set as shipped over time: comment variant (JabRef ≤ 4.0), groups variant (4.x); with special fields: 2019 base set, then doi, eprint, url (v5); citationcount and icore (v6.0-alpha, in either order); eprinttype (v6.0-alpha.5).

pack-priv static void
migrateFileAnnotationsTabVisibility(JabRefGuiPreferences prefs)

The legacy key smartFileAnnotations toggled a "smart visibility" mode.

private static void
migrateFileImportPattern(String oldStylePattern, String newStylePattern, JabRefCliPreferences prefs)

private static void
pack-priv static void
pack-priv static void
restoreVariablesForBackwardCompatibility(JabRefCliPreferences preferences)

In 5.0 the format of column names have changed.

public static void
runMigrations(JabRefGuiPreferences preferences)

Perform checks and changes for users with a preference set from an older JabRef version.

protected static void
upgradeBuiltinPreviewName(JabRefGuiPreferences prefs)

Since v6-alpha6 built in preview style will be stored by internal identifier instead by display name.

pack-priv static void
upgradeCleanups(JabRefCliPreferences prefs)

In version 6.0 the formatting of the CleanUps preferences changed.

pack-priv static void
upgradeColumnPreferences(JabRefCliPreferences preferences)

The former preferences default of columns was a simple list of strings ("author;title;year;...").

pack-priv static void
upgradeEntryEditorCustomTabs(JabRefGuiPreferences prefs)

Up to and including v6.0-alpha.6, custom entry editor tabs were stored in two parallel numbered series (customTabName_0/customTabFields_0, ...).

pack-priv static void
upgradeImportFileAndDirePatterns(JabRefCliPreferences prefs)

Migrate Import File Name and Directory name Patterns from versions <=4.0 to new BracketedPatterns

pack-priv static void
private static void
upgradeLabelPatternToCitationKeyPattern(JabRefCliPreferences prefs, Preferences mainPrefsNode)

Migrate LabelPattern configuration from versions <=3.5 to new CitationKeyPatterns.

pack-priv static void
upgradeMacKeyBindingDefaults(JabRefCliPreferences prefs, boolean isMacOs)

Updates unchanged key bindings in snapshots persisted before macOS-specific defaults were introduced.

private static void
upgradePrefsToOrgJabRef(Preferences mainPrefsNode)

Migrate all preferences from net/sf/jabref to org/jabref

protected static void
upgradePreviewStyle(JabRefGuiPreferences prefs)

Customizable preview style migrations

  • Since v5.0-alpha the custom preview layout shows the 'comment' field instead of the 'review' field (#4100).
  • Since v5.1 a marker enables markdown in comments (#6232).
  • Since v5.2 'bibtexkey' is rebranded as citationkey (#6875).
pack-priv static void
private static void
upgradeSortOrder(JabRefCliPreferences prefs)

Upgrade the sort order preferences for the current version The old preference is kept in case an old version of JabRef is used with these preferences, but it is only used when the new preference does not exist

private static void
upgradeStoredBibEntryTypes(JabRefCliPreferences prefs, Preferences mainPrefsNode, BibEntryTypesManager entryTypesManager)

Migrate all customized entry types from versions <=3.7

pack-priv static void
upgradeTheme(JabRefGuiPreferences preferences)

upgrade the old theme css names of the theme to the new theme properties Theme names were changed in #15573

The old keys are deleted after reading them, so the migration runs at most once -- migrations run on every startup, and re-applying the old value each time would overwrite whatever the user selected in the new UI in the meantime.

private static Set<String>
withFields(Set<String> fields, String... more)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LEGACY_ABSTRACT_TAB_NAMESback to summary
private static final Set<String> LEGACY_ABSTRACT_TAB_NAMES
LEGACY_COMMENTS_TAB_NAMESback to summary
private static final Set<String> LEGACY_COMMENTS_TAB_NAMES
LEGACY_GENERAL_TAB_NAMESback to summary
private static final Set<String> LEGACY_GENERAL_TAB_NAMES

The names the default tabs were stored under, in every translation shipped between JabRef 3.8.2 and the 6.0 alphas (harvested from the v3.8.2, v4.3.1, and v5.15 tags plus the current bundles), lower-cased. Inlined instead of read from the current bundles: translations change and languages get dropped (the "Review" l10n key is already gone), which would silently stop the migration from recognizing names stored by old versions. Untranslated languages fell back to the English name.

LEGACY_REVIEW_TAB_NAMESback to summary
private static final Set<String> LEGACY_REVIEW_TAB_NAMES
LOGGERback to summary
private static final Logger LOGGER
V4_0_IMPORT_FILENAME_PATTERNback to summary
public static final String V4_0_IMPORT_FILENAME_PATTERN

Constructor Detail

PreferencesMigrationsback to summary
private PreferencesMigrations()

Method Detail

addCrossRefRelatedFieldsForAutoCompleteback to summary
private static void addCrossRefRelatedFieldsForAutoComplete(JabRefCliPreferences prefs)
changeColumnVariableNamesFor51back to summary
pack-priv static void changeColumnVariableNamesFor51(JabRefCliPreferences preferences)
copyPrefsRecursivelyback to summary
private static void copyPrefsRecursively(Preferences from, Preferences to) throws BackingStoreException
isLegacyDefaultTabback to summary
private static boolean isLegacyDefaultTab(String name, List<String> fields)

Whether a pre-v6.0-alpha.7 custom tab is one of the former default tabs "General", "Abstract", "Comments" (JabRef 5.x), or "Review" (JabRef ≤ 4.x).

Old versions wrote the default tabs to the store as if the user had defined them (any "Save" in the preferences dialog and the former per-startup General-fields migration did), so the store cannot tell defaults from customizations. Since #12711 the "Main" tab shows all these fields, so such a tab is pure duplication. A tab counts as a default only if its name and its fields match as a shipped pair: a translation of "Abstract"/"Comments"/"Review" (names were stored localized, and not necessarily in the current language) with exactly its shipped single field, or a translation of "General" with exactly one of the shipped default field sets. A cross-match (e.g. an "Abstract" tab holding the General fields) is a customization and is kept.

legacyGeneralFieldSetsback to summary
private static Set<Set<String>> legacyGeneralFieldSets()

The "General" default field set as shipped over time: comment variant (JabRef ≤ 4.0), groups variant (4.x); with special fields: 2019 base set, then doi, eprint, url (v5); citationcount and icore (v6.0-alpha, in either order); eprinttype (v6.0-alpha.5).

migrateFileAnnotationsTabVisibilityback to summary
pack-priv static void migrateFileAnnotationsTabVisibility(JabRefGuiPreferences prefs)

The legacy key smartFileAnnotations toggled a "smart visibility" mode. Mode was adapted for all tabs in EntryEditor as content driven visibility.

migrateFileImportPatternback to summary
private static void migrateFileImportPattern(String oldStylePattern, String newStylePattern, JabRefCliPreferences prefs)
migrateTypedKeyPrefsback to summary
private static void migrateTypedKeyPrefs(JabRefCliPreferences prefs, Preferences oldPatternPrefs) throws BackingStoreException
moveApiKeysToKeyringback to summary
pack-priv static void moveApiKeysToKeyring(JabRefCliPreferences preferences)
restoreVariablesForBackwardCompatibilityback to summary
pack-priv static void restoreVariablesForBackwardCompatibility(JabRefCliPreferences preferences)

In 5.0 the format of column names have changed. That made newer versions of JabRef preferences incompatible with earlier versions of JabRef. As some complains came up, we decided to change the variable names and to clear the variable contents if they are unreadable, so former versions of JabRef would automatically create preferences they can deal with.

runMigrationsback to summary
public static void runMigrations(JabRefGuiPreferences preferences)

Perform checks and changes for users with a preference set from an older JabRef version.

upgradeBuiltinPreviewNameback to summary
protected static void upgradeBuiltinPreviewName(JabRefGuiPreferences prefs)

Since v6-alpha6 built in preview style will be stored by internal identifier instead by display name.

upgradeCleanupsback to summary
pack-priv static void upgradeCleanups(JabRefCliPreferences prefs)

In version 6.0 the formatting of the CleanUps preferences changed. Instead of using several keys that have have a variable name a single preference key is introduced containing just the active cleanup jobs. Also instead of a combined field for the field formatters and the enabled status of all of them, they are split for easier parsing.

Changes
key value
CLEANUP - old format:
CleanUpCLEAN_UP_DOI enabled
CleanUpRENAME_PDF disabled
CleanUpMOVE_PDF enabled
...
CLEANUP_JOBS - new format:
CleanUpJobs CLEAN_UP_DOI;RENAME_PDF;MOVE_PDF
CLEANUP_FORMATTERS - old format:
CleanUpFormatters ENABLED\nfield[formatter,formatter...]\nfield[...]\nfield[...]...
CLEANUP_FORMATTERS - new format:
CleanUpFormattersEnabled TRUE
CleanUpFormatters field[formatter,formatter...]\nfield[...]\nfield[...]...
upgradeColumnPreferencesback to summary
pack-priv static void upgradeColumnPreferences(JabRefCliPreferences preferences)

The former preferences default of columns was a simple list of strings ("author;title;year;..."). Since 5.0 the preferences store the type of the column too, so that the formerly hardwired columns like the graphic groups column or the other icon columns can be reordered in the main table and behave like any other field column ("groups;linked_id;field:author;special:readstatus;extrafile:pdf;...").

Simple strings are by default parsed as a FieldColumn, so there is nothing to do there, but the formerly hard wired columns need to be added.

In 5.1 variable names in JabRefPreferences have changed to offer backward compatibility with pre 5.0 releases Pre 5.1: columnNames, columnWidths, columnSortTypes, columnSortOrder Since 5.1: mainTableColumnNames, mainTableColumnWidths, mainTableColumnSortTypes, mainTableColumnSortOrder

upgradeEntryEditorCustomTabsback to summary
pack-priv static void upgradeEntryEditorCustomTabs(JabRefGuiPreferences prefs)

Up to and including v6.0-alpha.6, custom entry editor tabs were stored in two parallel numbered series (customTabName_0/customTabFields_0, ...). Since #16598 they are stored as one JSON object, {"tab name": ["field pattern",...], ...}. The old keys are kept in case an old version of JabRef is used with these preferences; they are only read when the new key does not exist yet.

upgradeImportFileAndDirePatternsback to summary
pack-priv static void upgradeImportFileAndDirePatterns(JabRefCliPreferences prefs)

Migrate Import File Name and Directory name Patterns from versions <=4.0 to new BracketedPatterns

upgradeKeyBindingsToJavaFXback to summary
pack-priv static void upgradeKeyBindingsToJavaFX(JabRefCliPreferences prefs)
upgradeLabelPatternToCitationKeyPatternback to summary
private static void upgradeLabelPatternToCitationKeyPattern(JabRefCliPreferences prefs, Preferences mainPrefsNode)

Migrate LabelPattern configuration from versions <=3.5 to new CitationKeyPatterns.

Introduced in #1704

upgradeMacKeyBindingDefaultsback to summary
pack-priv static void upgradeMacKeyBindingDefaults(JabRefCliPreferences prefs, boolean isMacOs)

Updates unchanged key bindings in snapshots persisted before macOS-specific defaults were introduced.

upgradePrefsToOrgJabRefback to summary
private static void upgradePrefsToOrgJabRef(Preferences mainPrefsNode)

Migrate all preferences from net/sf/jabref to org/jabref

upgradePreviewStyleback to summary
protected static void upgradePreviewStyle(JabRefGuiPreferences prefs)

Customizable preview style migrations

  • Since v5.0-alpha the custom preview layout shows the 'comment' field instead of the 'review' field (#4100).
  • Since v5.1 a marker enables markdown in comments (#6232).
  • Since v5.2 'bibtexkey' is rebranded as citationkey (#6875).
upgradeResolveBibTeXStringsFieldsback to summary
pack-priv static void upgradeResolveBibTeXStringsFields(JabRefCliPreferences prefs)
upgradeSortOrderback to summary
private static void upgradeSortOrder(JabRefCliPreferences prefs)

Upgrade the sort order preferences for the current version The old preference is kept in case an old version of JabRef is used with these preferences, but it is only used when the new preference does not exist

upgradeStoredBibEntryTypesback to summary
private static void upgradeStoredBibEntryTypes(JabRefCliPreferences prefs, Preferences mainPrefsNode, BibEntryTypesManager entryTypesManager)

Migrate all customized entry types from versions <=3.7

upgradeThemeback to summary
pack-priv static void upgradeTheme(JabRefGuiPreferences preferences)

upgrade the old theme css names of the theme to the new theme properties Theme names were changed in #15573

The old keys are deleted after reading them, so the migration runs at most once -- migrations run on every startup, and re-applying the old value each time would overwrite whatever the user selected in the new UI in the meantime.

withFieldsback to summary
private static Set<String> withFields(Set<String> fields, String... more)