public class AccountConfig extends VersionedMetaData implements ValidationError.Sink
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).
VersionedMetaData.BatchMetaDataUpdate, VersionedMetaData.PathInfo
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCOUNT |
static java.lang.String |
ACCOUNT_CONFIG |
static java.lang.String |
KEY_ACTIVE |
static java.lang.String |
KEY_FULL_NAME |
static java.lang.String |
KEY_PREFERRED_EMAIL |
static java.lang.String |
KEY_STATUS |
Constructor and Description |
---|
AccountConfig(OutgoingEmailValidator emailValidator,
Account.Id accountId) |
Modifier and Type | Method and 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 java.lang.String |
getRefName() |
java.util.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) |
commitToNewRef, getObjectId, getPathInfos, getRevision, load, load, load, load, load, openUpdate, readConfig, readFile, readTree, readUTF8, saveConfig, saveFile, saveUTF8, set, set, set
public static final java.lang.String ACCOUNT_CONFIG
public static final java.lang.String ACCOUNT
public static final java.lang.String KEY_ACTIVE
public static final java.lang.String KEY_FULL_NAME
public static final java.lang.String KEY_PREFERRED_EMAIL
public static final java.lang.String KEY_STATUS
public AccountConfig(OutgoingEmailValidator emailValidator, Account.Id accountId)
protected java.lang.String getRefName()
getRefName
in class VersionedMetaData
public Account getAccount()
java.lang.IllegalStateException
- if the account was not loaded yetpublic void setAccount(Account account)
Changing the registration date of an account is not supported.
account
- account that should be setjava.lang.IllegalStateException
- if the account was not loaded yetpublic Account getNewAccount() throws com.google.gwtorm.server.OrmDuplicateKeyException
com.google.gwtorm.server.OrmDuplicateKeyException
- if the user branch already existsprotected void onLoad() throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
VersionedMetaData
onLoad
in class VersionedMetaData
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws java.io.IOException
VersionedMetaData
commit
in class VersionedMetaData
update
- helper information to define the update that will occur.java.io.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 referenceprotected boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws java.io.IOException, org.eclipse.jgit.errors.ConfigInvalidException
VersionedMetaData
onSave
in class VersionedMetaData
java.io.IOException
org.eclipse.jgit.errors.ConfigInvalidException
public static void writeToConfig(Account account, org.eclipse.jgit.lib.Config cfg)
public java.util.List<ValidationError> getValidationErrors()
public void error(ValidationError error)
error
in interface ValidationError.Sink