Search in sources :

Example 1 with InheritedBooleanInfo

use of com.google.gerrit.extensions.api.projects.ConfigInfo.InheritedBooleanInfo in project gerrit by GerritCodeReview.

the class ConfigInfoCreator method constructInfo.

@SuppressWarnings("deprecation")
public static ConfigInfo constructInfo(boolean serverEnableSignedPush, ProjectState projectState, CurrentUser user, DynamicMap<ProjectConfigEntry> pluginConfigEntries, PluginConfigFactory cfgFactory, AllProjectsName allProjects, UiActions uiActions, DynamicMap<RestView<ProjectResource>> views) {
    ConfigInfo configInfo = new ConfigInfo();
    Project p = projectState.getProject();
    configInfo.description = Strings.emptyToNull(p.getDescription());
    ProjectState parentState = Iterables.getFirst(projectState.parents(), null);
    for (BooleanProjectConfig cfg : BooleanProjectConfig.values()) {
        InheritedBooleanInfo info = new InheritedBooleanInfo();
        info.configuredValue = p.getBooleanConfig(cfg);
        if (parentState != null) {
            info.inheritedValue = parentState.is(cfg);
        }
        BooleanProjectConfigTransformations.set(cfg, configInfo, info);
    }
    if (!serverEnableSignedPush) {
        configInfo.enableSignedPush = null;
        configInfo.requireSignedPush = null;
    }
    configInfo.maxObjectSizeLimit = getMaxObjectSizeLimit(projectState, p);
    configInfo.defaultSubmitType = new SubmitTypeInfo();
    configInfo.defaultSubmitType.value = projectState.getSubmitType();
    configInfo.defaultSubmitType.configuredValue = MoreObjects.firstNonNull(projectState.getConfig().getProject().getSubmitType(), Project.DEFAULT_SUBMIT_TYPE);
    ProjectState parent = projectState.isAllProjects() ? projectState : projectState.parents().get(0);
    configInfo.defaultSubmitType.inheritedValue = parent.getSubmitType();
    configInfo.submitType = configInfo.defaultSubmitType.value;
    configInfo.state = p.getState() != com.google.gerrit.extensions.client.ProjectState.ACTIVE ? p.getState() : null;
    configInfo.commentlinks = new LinkedHashMap<>();
    for (CommentLinkInfo cl : projectState.getCommentLinks()) {
        configInfo.commentlinks.put(cl.name, cl);
    }
    configInfo.pluginConfig = getPluginConfig(projectState, pluginConfigEntries, cfgFactory, allProjects);
    configInfo.actions = new TreeMap<>();
    for (UiAction.Description d : uiActions.from(views, new ProjectResource(projectState, user))) {
        configInfo.actions.put(d.getId(), new ActionInfo(d));
    }
    configInfo.extensionPanelNames = projectState.getConfig().getExtensionPanelSections();
    return configInfo;
}
Also used : ActionInfo(com.google.gerrit.extensions.common.ActionInfo) ConfigInfo(com.google.gerrit.extensions.api.projects.ConfigInfo) UiAction(com.google.gerrit.extensions.webui.UiAction) InheritedBooleanInfo(com.google.gerrit.extensions.api.projects.ConfigInfo.InheritedBooleanInfo) Project(com.google.gerrit.entities.Project) SubmitTypeInfo(com.google.gerrit.extensions.api.projects.ConfigInfo.SubmitTypeInfo) CommentLinkInfo(com.google.gerrit.extensions.api.projects.CommentLinkInfo) ProjectState(com.google.gerrit.server.project.ProjectState) ProjectResource(com.google.gerrit.server.project.ProjectResource) BooleanProjectConfig(com.google.gerrit.entities.BooleanProjectConfig)

Aggregations

BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)1 Project (com.google.gerrit.entities.Project)1 CommentLinkInfo (com.google.gerrit.extensions.api.projects.CommentLinkInfo)1 ConfigInfo (com.google.gerrit.extensions.api.projects.ConfigInfo)1 InheritedBooleanInfo (com.google.gerrit.extensions.api.projects.ConfigInfo.InheritedBooleanInfo)1 SubmitTypeInfo (com.google.gerrit.extensions.api.projects.ConfigInfo.SubmitTypeInfo)1 ActionInfo (com.google.gerrit.extensions.common.ActionInfo)1 UiAction (com.google.gerrit.extensions.webui.UiAction)1 ProjectResource (com.google.gerrit.server.project.ProjectResource)1 ProjectState (com.google.gerrit.server.project.ProjectState)1