Package com.google.gerrit.server.account
Class AccountConfig
- java.lang.Object
-
- com.google.gerrit.server.git.VersionedMetaData
-
- com.google.gerrit.server.account.AccountConfig
-
- All Implemented Interfaces:
ValidationError.Sink
public class AccountConfig extends VersionedMetaData implements ValidationError.Sink
‘account.config’ file in the user branch in the All-Users repository that contains the properties of the account.The 'account.config' file is a git config file that has one 'account' section with the properties of the account:
[account] active = false fullName = John Doe preferredEmail = [email protected] status = Overloaded with reviews
All keys are optional. This means 'account.config' may not exist on the user branch if no properties are set.
Not setting a key and setting a key to an empty string are treated the same way and result in a
null
value.If no value for 'active' is specified, by default the account is considered as active.
The commit date of the first commit on the user branch is used as registration date of the account. The first commit may be an empty commit (if no properties were set and 'account.config' doesn't exist).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.gerrit.server.git.VersionedMetaData
VersionedMetaData.BatchMetaDataUpdate, VersionedMetaData.PathInfo
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCOUNT
static String
ACCOUNT_CONFIG
static String
KEY_ACTIVE
static String
KEY_FULL_NAME
static String
KEY_PREFERRED_EMAIL
static String
KEY_STATUS
-
Constructor Summary
Constructors Constructor Description AccountConfig(OutgoingEmailValidator emailValidator, Account.Id accountId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.eclipse.jgit.revwalk.RevCommit
commit(MetaDataUpdate update)
Update this metadata branch, recording a new commit on its reference.void
error(ValidationError error)
Account
getAccount()
Get the loaded account.Account
getNewAccount()
Creates a new account.protected String
getRefName()
List<ValidationError>
getValidationErrors()
Get the validation errors, if any were discovered during load.protected void
onLoad()
Set up the metadata, parsing any state from the loaded revision.protected boolean
onSave(org.eclipse.jgit.lib.CommitBuilder commit)
Save any changes to the metadata in a commit.void
setAccount(Account account)
Sets the account.static void
writeToConfig(Account account, org.eclipse.jgit.lib.Config cfg)
-
Methods inherited from class com.google.gerrit.server.git.VersionedMetaData
commitToNewRef, getObjectId, getPathInfos, getRevision, load, load, load, load, load, openUpdate, readConfig, readFile, readTree, readUTF8, saveConfig, saveFile, saveUTF8, set, set, set
-
-
-
-
Field Detail
-
ACCOUNT_CONFIG
public static final String ACCOUNT_CONFIG
- See Also:
- Constant Field Values
-
ACCOUNT
public static final String ACCOUNT
- See Also:
- Constant Field Values
-
KEY_ACTIVE
public static final String KEY_ACTIVE
- See Also:
- Constant Field Values
-
KEY_FULL_NAME
public static final String KEY_FULL_NAME
- See Also:
- Constant Field Values
-
KEY_PREFERRED_EMAIL
public static final String KEY_PREFERRED_EMAIL
- See Also:
- Constant Field Values
-
KEY_STATUS
public static final String KEY_STATUS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AccountConfig
public AccountConfig(OutgoingEmailValidator emailValidator, Account.Id accountId)
-
-
Method Detail
-
getRefName
protected String getRefName()
- Specified by:
getRefName
in classVersionedMetaData
- Returns:
- name of the reference storing this configuration.
-
getAccount
public Account getAccount()
Get the loaded account.- Returns:
- loaded account.
- Throws:
IllegalStateException
- if the account was not loaded yet
-
setAccount
public void setAccount(Account account)
Sets the account. This means the loaded account will be overwritten with the given account.Changing the registration date of an account is not supported.
- Parameters:
account
- account that should be set- Throws:
IllegalStateException
- if the account was not loaded yet
-
getNewAccount
public Account getNewAccount() throws com.google.gwtorm.server.OrmDuplicateKeyException
Creates a new account.- Returns:
- the new account
- Throws:
com.google.gwtorm.server.OrmDuplicateKeyException
- if the user branch already exists
-
onLoad
protected void onLoad() throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
Description copied from class:VersionedMetaData
Set up the metadata, parsing any state from the loaded revision.- Specified by:
onLoad
in classVersionedMetaData
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
commit
public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws IOException
Description copied from class:VersionedMetaData
Update this metadata branch, recording a new commit on its reference.- Overrides:
commit
in classVersionedMetaData
- Parameters:
update
- helper information to define the update that will occur.- Returns:
- the commit that was created
- Throws:
IOException
- if there is a storage problem and the update cannot be executed as requested or if it failed because of a concurrent update to the same reference
-
onSave
protected boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
Description copied from class:VersionedMetaData
Save any changes to the metadata in a commit.- Specified by:
onSave
in classVersionedMetaData
- Returns:
- true if the commit should proceed, false to abort.
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
writeToConfig
public static void writeToConfig(Account account, org.eclipse.jgit.lib.Config cfg)
-
getValidationErrors
public List<ValidationError> getValidationErrors()
Get the validation errors, if any were discovered during load.- Returns:
- list of errors; empty list if there are no errors.
-
error
public void error(ValidationError error)
- Specified by:
error
in interfaceValidationError.Sink
-
-