Class Groups


  • public class Groups
    extends Object
    A database accessor for read calls related to groups.

    All calls which read group related details from the database are gathered here. Other classes should always use this class instead of accessing the database directly. There are a few exceptions though: schema classes, wrapper classes, and classes executed during init. The latter ones should use GroupsOnInit instead.

    Most callers should not need to read groups directly from the database; they should use the GroupCache instead.

    If not explicitly stated, all methods of this class refer to internal groups.

    • Method Detail

      • getGroup

        public Optional<InternalGroup> getGroup​(AccountGroup.UUID groupUuid)
                                         throws IOException,
                                                org.eclipse.jgit.errors.ConfigInvalidException
        Returns the InternalGroup for the specified UUID if it exists.
        Parameters:
        groupUuid - the UUID of the group
        Returns:
        the found InternalGroup if it exists, or else an empty Optional
        Throws:
        IOException - if the group couldn't be retrieved from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the group couldn't be retrieved from NoteDb
      • getGroup

        public Optional<InternalGroup> getGroup​(AccountGroup.UUID groupUuid,
                                                org.eclipse.jgit.lib.ObjectId groupRefObjectId)
                                         throws IOException,
                                                org.eclipse.jgit.errors.ConfigInvalidException
        Returns the InternalGroup for the specified UUID and groupRefObjectId
        Parameters:
        groupUuid - the UUID of the group
        groupRefObjectId - the ref revision of this group
        Returns:
        the found InternalGroup if it exists, or else an empty Optional
        Throws:
        IOException - if the group couldn't be retrieved from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the group couldn't be retrieved from NoteDb
      • getAllGroupReferences

        public Stream<GroupReference> getAllGroupReferences()
                                                     throws IOException,
                                                            org.eclipse.jgit.errors.ConfigInvalidException
        Returns GroupReferences for all internal groups.
        Returns:
        a stream of the GroupReferences of all internal groups
        Throws:
        IOException - if an error occurs while reading from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the data in NoteDb is in an incorrect format
      • getExternalGroups

        public Stream<AccountGroup.UUID> getExternalGroups​(com.google.common.collect.ImmutableList<org.eclipse.jgit.lib.Ref> internalGroupsRefs)
                                                    throws IOException,
                                                           org.eclipse.jgit.errors.ConfigInvalidException
        Returns all known external groups. External groups are 'known' when they are specified as a subgroup of an internal group.
        Parameters:
        internalGroupsRefs - contains a list of all groups refs that we should inspect
        Returns:
        a stream of the UUIDs of the known external groups
        Throws:
        IOException - if an error occurs while reading from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the data in NoteDb is in an incorrect format
      • getMembersAudit

        public List<AccountGroupMemberAudit> getMembersAudit​(org.eclipse.jgit.lib.Repository allUsersRepo,
                                                             AccountGroup.UUID groupUuid)
                                                      throws IOException,
                                                             org.eclipse.jgit.errors.ConfigInvalidException
        Returns the membership audit records for a given group.
        Parameters:
        allUsersRepo - All-Users repository.
        groupUuid - the UUID of the group
        Returns:
        the audit records, in arbitrary order; empty if the group does not exist
        Throws:
        IOException - if an error occurs while reading from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the group couldn't be retrieved from NoteDb
      • getSubgroupsAudit

        public List<AccountGroupByIdAudit> getSubgroupsAudit​(org.eclipse.jgit.lib.Repository repo,
                                                             AccountGroup.UUID groupUuid)
                                                      throws IOException,
                                                             org.eclipse.jgit.errors.ConfigInvalidException
        Returns the subgroup audit records for a given group.
        Parameters:
        repo - All-Users repository.
        groupUuid - the UUID of the group
        Returns:
        the audit records, in arbitrary order; empty if the group does not exist
        Throws:
        IOException - if an error occurs while reading from NoteDb
        org.eclipse.jgit.errors.ConfigInvalidException - if the group couldn't be retrieved from NoteDb