Class 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).

    • Method Detail

      • 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 class VersionedMetaData
        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 class VersionedMetaData
        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 class VersionedMetaData
        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.