Package com.google.gerrit.server.account
Class WatchConfig
- java.lang.Object
-
- com.google.gerrit.server.git.VersionedMetaData
-
- com.google.gerrit.server.account.WatchConfig
-
- All Implemented Interfaces:
ValidationError.Sink
public class WatchConfig extends VersionedMetaData implements ValidationError.Sink
‘watch.config’ file in the user branch in the All-Users repository that contains the watch configuration of the user.The 'watch.config' file is a git config file that has one 'project' section for all project watches of a project.
The project name is used as subsection name and the filters with the notify types that decide for which events email notifications should be sent are represented as 'notify' values in the subsection. A 'notify' value is formatted as
<filter> [<comma-separated-list-of-notify-types>]
:[project "foo"] notify = * [ALL_COMMENTS] notify = branch:master [ALL_COMMENTS, NEW_PATCHSETS] notify = branch:master owner:self [SUBMITTED_CHANGES]
If two notify values in the same subsection have the same filter they are merged on the next save, taking the union of the notify types.
For watch configurations that notify on no event the list of notify types is empty:
[project "foo"] notify = branch:master []
Unknown notify types are ignored and removed on save.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WatchConfig.Accessor
static class
WatchConfig.NotifyType
static class
WatchConfig.NotifyValue
static class
WatchConfig.ProjectWatchKey
-
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
FILTER_ALL
static String
KEY_NOTIFY
static String
PROJECT
static String
WATCH_CONFIG
-
Constructor Summary
Constructors Constructor Description WatchConfig(Account.Id accountId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
error(ValidationError error)
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.static Map<WatchConfig.ProjectWatchKey,Set<WatchConfig.NotifyType>>
parse(Account.Id accountId, org.eclipse.jgit.lib.Config cfg, ValidationError.Sink validationErrorSink)
void
setProjectWatches(Map<WatchConfig.ProjectWatchKey,Set<WatchConfig.NotifyType>> projectWatches)
-
Methods inherited from class com.google.gerrit.server.git.VersionedMetaData
commit, commitToNewRef, getObjectId, getPathInfos, getRevision, load, load, load, load, load, openUpdate, readConfig, readFile, readTree, readUTF8, saveConfig, saveFile, saveUTF8, set, set, set
-
-
-
-
Field Detail
-
FILTER_ALL
public static final String FILTER_ALL
- See Also:
- Constant Field Values
-
WATCH_CONFIG
public static final String WATCH_CONFIG
- See Also:
- Constant Field Values
-
PROJECT
public static final String PROJECT
- See Also:
- Constant Field Values
-
KEY_NOTIFY
public static final String KEY_NOTIFY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WatchConfig
public WatchConfig(Account.Id accountId)
-
-
Method Detail
-
getRefName
protected String getRefName()
- Specified by:
getRefName
in classVersionedMetaData
- Returns:
- name of the reference storing this configuration.
-
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
-
parse
public static Map<WatchConfig.ProjectWatchKey,Set<WatchConfig.NotifyType>> parse(Account.Id accountId, org.eclipse.jgit.lib.Config cfg, ValidationError.Sink validationErrorSink)
-
setProjectWatches
public void setProjectWatches(Map<WatchConfig.ProjectWatchKey,Set<WatchConfig.NotifyType>> projectWatches)
-
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
-
error
public void error(ValidationError error)
- Specified by:
error
in interfaceValidationError.Sink
-
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.
-
-