Search in sources :

Example 1 with AccountsSection

use of com.google.gerrit.entities.AccountsSection in project gerrit by GerritCodeReview.

the class ProjectConfig method getCacheable.

/**
 * Returns an immutable, thread-safe representation of this object that can be cached.
 */
public CachedProjectConfig getCacheable() {
    CachedProjectConfig.Builder builder = CachedProjectConfig.builder().setProject(project).setAccountsSection(accountsSection).setBranchOrderSection(Optional.ofNullable(branchOrderSection)).setMimeTypes(mimeTypes).setRulesId(Optional.ofNullable(rulesId)).setRevision(Optional.ofNullable(getRevision())).setMaxObjectSizeLimit(maxObjectSizeLimit).setCheckReceivedObjects(checkReceivedObjects).setExtensionPanelSections(extensionPanelSections);
    groupList.byUUID().values().forEach(g -> builder.addGroup(g));
    contributorAgreements.values().forEach(c -> builder.addContributorAgreement(c));
    notifySections.values().forEach(n -> builder.addNotifySection(n));
    subscribeSections.values().forEach(s -> builder.addSubscribeSection(s));
    commentLinkSections.values().forEach(c -> builder.addCommentLinkSection(c));
    labelSections.values().forEach(l -> builder.addLabelSection(l));
    submitRequirementSections.values().forEach(sr -> builder.addSubmitRequirementSection(sr));
    pluginConfigs.entrySet().forEach(c -> builder.addPluginConfig(c.getKey(), c.getValue().toText()));
    projectLevelConfigs.entrySet().forEach(c -> builder.addProjectLevelConfig(c.getKey(), c.getValue().toText()));
    if (projectName.equals(allProjectsName)) {
        // Filter out permissions that aren't allowed to be set on All-Projects
        accessSections.values().forEach(a -> {
            List<Permission.Builder> copy = new ArrayList<>();
            for (Permission p : a.getPermissions()) {
                if (Permission.canBeOnAllProjects(a.getName(), p.getName())) {
                    copy.add(p.toBuilder());
                }
            }
            AccessSection section = AccessSection.builder(a.getName()).modifyPermissions(permissions -> permissions.addAll(copy)).build();
            builder.addAccessSection(section);
        });
    } else {
        accessSections.values().forEach(a -> builder.addAccessSection(a));
    }
    return builder.build();
}
Also used : GroupBackend(com.google.gerrit.server.account.GroupBackend) Arrays(java.util.Arrays) GlobalCapability(com.google.gerrit.common.data.GlobalCapability) Inject(com.google.inject.Inject) RevWalk(org.eclipse.jgit.revwalk.RevWalk) InheritableBoolean(com.google.gerrit.extensions.client.InheritableBoolean) Config(org.eclipse.jgit.lib.Config) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) VersionedMetaData(com.google.gerrit.server.git.meta.VersionedMetaData) LabelValue(com.google.gerrit.entities.LabelValue) LabelType(com.google.gerrit.entities.LabelType) ConfigUtil(com.google.gerrit.server.config.ConfigUtil) Locale(java.util.Locale) Map(java.util.Map) ContributorAgreement(com.google.gerrit.entities.ContributorAgreement) RefNames(com.google.gerrit.entities.RefNames) Splitter(com.google.common.base.Splitter) PluginConfig(com.google.gerrit.server.config.PluginConfig) EnumSet(java.util.EnumSet) Permission.isPermission(com.google.gerrit.entities.Permission.isPermission) ImmutableSet(com.google.common.collect.ImmutableSet) PatternSyntaxException(java.util.regex.PatternSyntaxException) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) AccessSection(com.google.gerrit.entities.AccessSection) Collection(java.util.Collection) Set(java.util.Set) Sets(com.google.common.collect.Sets) Preconditions.checkState(com.google.common.base.Preconditions.checkState) GroupReference(com.google.gerrit.entities.GroupReference) Objects(java.util.Objects) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) AllProjectsName(com.google.gerrit.server.config.AllProjectsName) DEFAULT_SUBMIT_TYPE(com.google.gerrit.entities.Project.DEFAULT_SUBMIT_TYPE) ConfiguredMimeTypes(com.google.gerrit.entities.ConfiguredMimeTypes) NotifyConfig(com.google.gerrit.entities.NotifyConfig) BooleanProjectConfig(com.google.gerrit.entities.BooleanProjectConfig) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) AllProjectsConfigProvider(com.google.gerrit.server.config.AllProjectsConfigProvider) FluentLogger(com.google.common.flogger.FluentLogger) Joiner(com.google.common.base.Joiner) MetaDataUpdate(com.google.gerrit.server.git.meta.MetaDataUpdate) Singleton(com.google.inject.Singleton) ValidationError(com.google.gerrit.server.git.ValidationError) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) Shorts(com.google.common.primitives.Shorts) SubmitRequirementExpression(com.google.gerrit.entities.SubmitRequirementExpression) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Strings(com.google.common.base.Strings) PluginPermissionsUtil.isValidPluginPermission(com.google.gerrit.server.permissions.PluginPermissionsUtil.isValidPluginPermission) ImmutableList(com.google.common.collect.ImmutableList) GroupDescription(com.google.gerrit.entities.GroupDescription) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) Objects.requireNonNull(java.util.Objects.requireNonNull) LabelFunction(com.google.gerrit.entities.LabelFunction) PermissionRule(com.google.gerrit.entities.PermissionRule) CachedProjectConfig(com.google.gerrit.entities.CachedProjectConfig) UsedAt(com.google.gerrit.common.UsedAt) Address(com.google.gerrit.entities.Address) SubmitRequirement(com.google.gerrit.entities.SubmitRequirement) AccountGroup(com.google.gerrit.entities.AccountGroup) AccountsSection(com.google.gerrit.entities.AccountsSection) CharMatcher(com.google.common.base.CharMatcher) Permission(com.google.gerrit.entities.Permission) IOException(java.io.IOException) ProjectState(com.google.gerrit.extensions.client.ProjectState) Maps(com.google.common.collect.Maps) ObjectId(org.eclipse.jgit.lib.ObjectId) Consumer(java.util.function.Consumer) Collectors.toList(java.util.stream.Collectors.toList) NotifyType(com.google.gerrit.entities.NotifyConfig.NotifyType) SubscribeSection(com.google.gerrit.entities.SubscribeSection) Project(com.google.gerrit.entities.Project) StoredConfig(org.eclipse.jgit.lib.StoredConfig) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StoredCommentLinkInfo(com.google.gerrit.entities.StoredCommentLinkInfo) BranchOrderSection(com.google.gerrit.entities.BranchOrderSection) Collections(java.util.Collections) Action(com.google.gerrit.entities.PermissionRule.Action) Repository(org.eclipse.jgit.lib.Repository) InvalidNameException(com.google.gerrit.exceptions.InvalidNameException) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) ArrayList(java.util.ArrayList) Permission.isPermission(com.google.gerrit.entities.Permission.isPermission) PluginPermissionsUtil.isValidPluginPermission(com.google.gerrit.server.permissions.PluginPermissionsUtil.isValidPluginPermission) Permission(com.google.gerrit.entities.Permission) CachedProjectConfig(com.google.gerrit.entities.CachedProjectConfig) AccessSection(com.google.gerrit.entities.AccessSection)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 CharMatcher (com.google.common.base.CharMatcher)1 Joiner (com.google.common.base.Joiner)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 Splitter (com.google.common.base.Splitter)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 FluentLogger (com.google.common.flogger.FluentLogger)1 Shorts (com.google.common.primitives.Shorts)1 Nullable (com.google.gerrit.common.Nullable)1 UsedAt (com.google.gerrit.common.UsedAt)1 GlobalCapability (com.google.gerrit.common.data.GlobalCapability)1 AccessSection (com.google.gerrit.entities.AccessSection)1 AccountGroup (com.google.gerrit.entities.AccountGroup)1 AccountsSection (com.google.gerrit.entities.AccountsSection)1