Class ProjectWatches
- java.lang.Object
-
- com.google.gerrit.server.account.ProjectWatches
-
public class ProjectWatches extends Object
Parses/writes project watches from/to aConfig
file.This is a low-level API. Read/write of project watches in a user branch should be done through
AccountsUpdate
orAccountConfig
.The config file 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.
The project watches are lazily parsed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProjectWatches.NotifyValue
static class
ProjectWatches.ProjectWatchKey
-
Field Summary
Fields Modifier and Type Field Description static String
FILTER_ALL
static String
KEY_NOTIFY
static String
PROJECT
static String
WATCH_CONFIG
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.common.collect.ImmutableMap<ProjectWatches.ProjectWatchKey,com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>>
getProjectWatches()
void
parse()
static com.google.common.collect.ImmutableMap<ProjectWatches.ProjectWatchKey,com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>>
parse(Account.Id accountId, org.eclipse.jgit.lib.Config cfg, ValidationError.Sink validationErrorSink)
Parses project watches from the given config file and returns them as a map.org.eclipse.jgit.lib.Config
save(Map<ProjectWatches.ProjectWatchKey,Set<NotifyConfig.NotifyType>> projectWatches)
-
-
-
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
-
-
Method Detail
-
getProjectWatches
public com.google.common.collect.ImmutableMap<ProjectWatches.ProjectWatchKey,com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> getProjectWatches()
-
parse
public void parse()
-
parse
public static com.google.common.collect.ImmutableMap<ProjectWatches.ProjectWatchKey,com.google.common.collect.ImmutableSet<NotifyConfig.NotifyType>> parse(Account.Id accountId, org.eclipse.jgit.lib.Config cfg, ValidationError.Sink validationErrorSink)
Parses project watches from the given config file and returns them as a map.A project watch is defined on a project and has a filter to match changes for which the project watch should be applied. The project and the filter form the map key. The map value is a set of notify types that decide for which events email notifications should be sent.
A project watch on the
All-Projects
project applies for all projects unless the project has a matching project watch.A project watch can have an empty set of notify types. An empty set of notify types means that no notification for matching changes should be set. This is different from no project watch as it overwrites matching project watches from the
All-Projects
project.Since we must be able to differentiate a project watch with an empty set of notify types from no project watch we can't use a
Multimap
as return type.- Parameters:
accountId
- the ID of the account for which the project watches should be parsedcfg
- the config file from which the project watches should be parsedvalidationErrorSink
- validation error sink- Returns:
- the parsed project watches
-
save
public org.eclipse.jgit.lib.Config save(Map<ProjectWatches.ProjectWatchKey,Set<NotifyConfig.NotifyType>> projectWatches)
-
-