Package com.google.gerrit.server.account
Class Preferences
- java.lang.Object
-
- com.google.gerrit.server.account.Preferences
-
public class Preferences 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:
[general] showSiteHeader = false [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
-
-
-
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
-
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
-
-