Package com.google.gerrit.server.account
Class StoredPreferences
- java.lang.Object
-
- com.google.gerrit.server.account.StoredPreferences
-
public class StoredPreferences extends Object
Parses/writes preferences from/to aConfig
file.This is a low-level API. Read/write of preferences in a user branch should be done through
AccountsUpdate
orAccountConfig
.The config file has separate sections for general, diff and edit preferences:
[diff] hideTopMenu = true [edit] lineLength = 80
The parameter names match the names that are used in the preferences REST API.
If the preference is omitted in the config file, then the default value for the preference is used.
Defaults for preferences that apply for all accounts can be configured in the
refs/users/default
branch in theAll-Users
repository. The config for the default preferences must be provided to this class so that it can read default values from it.The preferences are lazily parsed.
-
-
Field Summary
Fields Modifier and Type Field Description static String
PREFERENCES_CONFIG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DiffPreferencesInfo
getDiffPreferences()
EditPreferencesInfo
getEditPreferences()
GeneralPreferencesInfo
getGeneralPreferences()
void
parse()
static DiffPreferencesInfo
parseDiffPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, DiffPreferencesInfo input)
Returns aDiffPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config.static EditPreferencesInfo
parseEditPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, EditPreferencesInfo input)
Returns aEditPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config.static GeneralPreferencesInfo
parseGeneralPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, GeneralPreferencesInfo input)
Returns aGeneralPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config.static DiffPreferencesInfo
readDefaultDiffPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo)
static EditPreferencesInfo
readDefaultEditPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo)
static GeneralPreferencesInfo
readDefaultGeneralPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo)
org.eclipse.jgit.lib.Config
saveGeneralPreferences(Optional<GeneralPreferencesInfo> generalPreferencesInput, Optional<DiffPreferencesInfo> diffPreferencesInput, Optional<EditPreferencesInfo> editPreferencesInput)
static DiffPreferencesInfo
updateDefaultDiffPreferences(MetaDataUpdate md, DiffPreferencesInfo input)
static EditPreferencesInfo
updateDefaultEditPreferences(MetaDataUpdate md, EditPreferencesInfo input)
static GeneralPreferencesInfo
updateDefaultGeneralPreferences(MetaDataUpdate md, GeneralPreferencesInfo input)
static void
validateMy(List<MenuItem> my)
-
-
-
Field Detail
-
PREFERENCES_CONFIG
public static final String PREFERENCES_CONFIG
- See Also:
- Constant Field Values
-
-
Method Detail
-
getGeneralPreferences
public GeneralPreferencesInfo getGeneralPreferences()
-
getDiffPreferences
public DiffPreferencesInfo getDiffPreferences()
-
getEditPreferences
public EditPreferencesInfo getEditPreferences()
-
parse
public void parse()
-
saveGeneralPreferences
public org.eclipse.jgit.lib.Config saveGeneralPreferences(Optional<GeneralPreferencesInfo> generalPreferencesInput, Optional<DiffPreferencesInfo> diffPreferencesInput, Optional<EditPreferencesInfo> editPreferencesInput) throws org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
parseGeneralPreferences
public static GeneralPreferencesInfo parseGeneralPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, GeneralPreferencesInfo input) throws org.eclipse.jgit.errors.ConfigInvalidException
Returns aGeneralPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
parseDiffPreferences
public static DiffPreferencesInfo parseDiffPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, DiffPreferencesInfo input) throws org.eclipse.jgit.errors.ConfigInvalidException
Returns aDiffPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
parseEditPreferences
public static EditPreferencesInfo parseEditPreferences(org.eclipse.jgit.lib.Config cfg, org.eclipse.jgit.lib.Config defaultCfg, EditPreferencesInfo input) throws org.eclipse.jgit.errors.ConfigInvalidException
Returns aEditPreferencesInfo
that is the result of parsingdefaultCfg
for the server's default configs andcfg
for the user's config. These configs are then overlaid to inherit values (default -> user -> input (if provided).- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
readDefaultGeneralPreferences
public static GeneralPreferencesInfo readDefaultGeneralPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
readDefaultDiffPreferences
public static DiffPreferencesInfo readDefaultDiffPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
readDefaultEditPreferences
public static EditPreferencesInfo readDefaultEditPreferences(AllUsersName allUsersName, org.eclipse.jgit.lib.Repository allUsersRepo) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updateDefaultGeneralPreferences
public static GeneralPreferencesInfo updateDefaultGeneralPreferences(MetaDataUpdate md, GeneralPreferencesInfo input) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updateDefaultDiffPreferences
public static DiffPreferencesInfo updateDefaultDiffPreferences(MetaDataUpdate md, DiffPreferencesInfo input) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updateDefaultEditPreferences
public static EditPreferencesInfo updateDefaultEditPreferences(MetaDataUpdate md, EditPreferencesInfo input) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
validateMy
public static void validateMy(List<MenuItem> my) throws BadRequestException
- Throws:
BadRequestException
-
-