Class ProjectWatches


  • public class ProjectWatches
    extends Object
    Parses/writes project watches from/to a Config file.

    This is a low-level API. Read/write of project watches in a user branch should be done through AccountsUpdate or AccountConfig.

    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.

    • Method Detail

      • 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 parsed
        cfg - the config file from which the project watches should be parsed
        validationErrorSink - validation error sink
        Returns:
        the parsed project watches