当前位置: 首页>>代码示例>>Java>>正文


Java PermissionRule.setAction方法代码示例

本文整理汇总了Java中com.google.gerrit.common.data.PermissionRule.setAction方法的典型用法代码示例。如果您正苦于以下问题:Java PermissionRule.setAction方法的具体用法?Java PermissionRule.setAction怎么用?Java PermissionRule.setAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gerrit.common.data.PermissionRule的用法示例。


在下文中一共展示了PermissionRule.setAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureContributorAgreement

import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
protected ContributorAgreement configureContributorAgreement(boolean autoVerify)
    throws Exception {
  ContributorAgreement ca;
  if (autoVerify) {
    String g = createGroup("cla-test-group");
    GroupApi groupApi = gApi.groups().id(g);
    groupApi.description("CLA test group");
    InternalGroup caGroup =
        groupCache.get(new AccountGroup.UUID(groupApi.detail().id)).orElse(null);
    GroupReference groupRef = new GroupReference(caGroup.getGroupUUID(), caGroup.getName());
    PermissionRule rule = new PermissionRule(groupRef);
    rule.setAction(PermissionRule.Action.ALLOW);
    ca = new ContributorAgreement("cla-test");
    ca.setAutoVerify(groupRef);
    ca.setAccepted(ImmutableList.of(rule));
  } else {
    ca = new ContributorAgreement("cla-test-no-auto-verify");
  }
  ca.setDescription("description");
  ca.setAgreementUrl("agreement-url");

  ProjectConfig cfg = projectCache.checkedGet(allProjects).getConfig();
  cfg.replace(ca);
  saveProjectConfig(allProjects, cfg);
  return ca;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:AbstractDaemonTest.java

示例2: getAccessSections

import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
List<AccessSection> getAccessSections(Map<String, AccessSectionInfo> sectionInfos)
    throws UnprocessableEntityException {
  if (sectionInfos == null) {
    return Collections.emptyList();
  }

  List<AccessSection> sections = new ArrayList<>(sectionInfos.size());
  for (Map.Entry<String, AccessSectionInfo> entry : sectionInfos.entrySet()) {
    if (entry.getValue().permissions == null) {
      continue;
    }

    AccessSection accessSection = new AccessSection(entry.getKey());
    for (Map.Entry<String, PermissionInfo> permissionEntry :
        entry.getValue().permissions.entrySet()) {
      if (permissionEntry.getValue().rules == null) {
        continue;
      }

      Permission p = new Permission(permissionEntry.getKey());
      if (permissionEntry.getValue().exclusive != null) {
        p.setExclusiveGroup(permissionEntry.getValue().exclusive);
      }

      for (Map.Entry<String, PermissionRuleInfo> permissionRuleInfoEntry :
          permissionEntry.getValue().rules.entrySet()) {
        GroupDescription.Basic group = groupsCollection.parseId(permissionRuleInfoEntry.getKey());
        if (group == null) {
          throw new UnprocessableEntityException(
              permissionRuleInfoEntry.getKey() + " is not a valid group ID");
        }

        PermissionRuleInfo pri = permissionRuleInfoEntry.getValue();
        PermissionRule r = new PermissionRule(GroupReference.forGroup(group));
        if (pri != null) {
          if (pri.max != null) {
            r.setMax(pri.max);
          }
          if (pri.min != null) {
            r.setMin(pri.min);
          }
          r.setAction(GetAccess.ACTION_TYPE.inverse().get(pri.action));
          if (pri.force != null) {
            r.setForce(pri.force);
          }
        }
        p.add(r);
      }
      accessSection.getPermissions().add(p);
    }
    sections.add(accessSection);
  }
  return sections;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:55,代码来源:SetAccessUtil.java

示例3: initAllProjects

import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
private void initAllProjects(Repository git) throws IOException, ConfigInvalidException {
  BatchRefUpdate bru = git.getRefDatabase().newBatchUpdate();
  try (MetaDataUpdate md =
      new MetaDataUpdate(GitReferenceUpdated.DISABLED, allProjectsName, git, bru)) {
    md.getCommitBuilder().setAuthor(serverUser);
    md.getCommitBuilder().setCommitter(serverUser);
    md.setMessage(
        MoreObjects.firstNonNull(
            Strings.emptyToNull(message),
            "Initialized Gerrit Code Review " + Version.getVersion()));

    ProjectConfig config = ProjectConfig.read(md);
    Project p = config.getProject();
    p.setDescription("Access inherited by all other projects.");
    p.setRequireChangeID(InheritableBoolean.TRUE);
    p.setUseContentMerge(InheritableBoolean.TRUE);
    p.setUseContributorAgreements(InheritableBoolean.FALSE);
    p.setUseSignedOffBy(InheritableBoolean.FALSE);
    p.setEnableSignedPush(InheritableBoolean.FALSE);

    AccessSection cap = config.getAccessSection(AccessSection.GLOBAL_CAPABILITIES, true);
    AccessSection all = config.getAccessSection(AccessSection.ALL, true);
    AccessSection heads = config.getAccessSection(AccessSection.HEADS, true);
    AccessSection tags = config.getAccessSection("refs/tags/*", true);
    AccessSection meta = config.getAccessSection(RefNames.REFS_CONFIG, true);
    AccessSection refsFor = config.getAccessSection("refs/for/*", true);
    AccessSection magic = config.getAccessSection("refs/for/" + AccessSection.ALL, true);

    grant(config, cap, GlobalCapability.ADMINISTRATE_SERVER, admin);
    grant(config, all, Permission.READ, admin, anonymous);
    grant(config, refsFor, Permission.ADD_PATCH_SET, registered);

    if (batch != null) {
      Permission priority = cap.getPermission(GlobalCapability.PRIORITY, true);
      PermissionRule r = rule(config, batch);
      r.setAction(Action.BATCH);
      priority.add(r);

      Permission stream = cap.getPermission(GlobalCapability.STREAM_EVENTS, true);
      stream.add(rule(config, batch));
    }

    LabelType cr = initCodeReviewLabel(config);
    grant(config, heads, cr, -1, 1, registered);

    grant(config, heads, cr, -2, 2, admin, owners);
    grant(config, heads, Permission.CREATE, admin, owners);
    grant(config, heads, Permission.PUSH, admin, owners);
    grant(config, heads, Permission.SUBMIT, admin, owners);
    grant(config, heads, Permission.FORGE_AUTHOR, registered);
    grant(config, heads, Permission.FORGE_COMMITTER, admin, owners);
    grant(config, heads, Permission.EDIT_TOPIC_NAME, true, admin, owners);

    grant(config, tags, Permission.CREATE, admin, owners);
    grant(config, tags, Permission.CREATE_TAG, admin, owners);
    grant(config, tags, Permission.CREATE_SIGNED_TAG, admin, owners);

    grant(config, magic, Permission.PUSH, registered);
    grant(config, magic, Permission.PUSH_MERGE, registered);

    meta.getPermission(Permission.READ, true).setExclusiveGroup(true);
    grant(config, meta, Permission.READ, admin, owners);
    grant(config, meta, cr, -2, 2, admin, owners);
    grant(config, meta, Permission.CREATE, admin, owners);
    grant(config, meta, Permission.PUSH, admin, owners);
    grant(config, meta, Permission.SUBMIT, admin, owners);

    config.commitToNewRef(md, RefNames.REFS_CONFIG);
    initSequences(git, bru);
    execute(git, bru);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:73,代码来源:AllProjectsCreator.java

示例4: addGroup

import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
private void addGroup(GroupReference ref) {
  if (ref.getUUID() != null) {
    if (value.getRule(ref) == null) {
      PermissionRule newRule = value.getRule(ref, true);
      if (validRange != null) {
        int min = validRange.getDefaultMin();
        int max = validRange.getDefaultMax();
        newRule.setRange(min, max);

      } else if (GlobalCapability.PRIORITY.equals(value.getName())) {
        newRule.setAction(PermissionRule.Action.BATCH);
      }

      rules.getList().add(newRule);
    }
    groupToAdd.setValue(null);
    groupToAdd.setFocus(true);

  } else {
    // If the oracle didn't get to complete a UUID, resolve it now.
    //
    addRule.setEnabled(false);
    GroupMap.suggestAccountGroupForProject(
        projectName.get(),
        ref.getName(),
        1,
        new GerritCallback<GroupMap>() {
          @Override
          public void onSuccess(GroupMap result) {
            addRule.setEnabled(true);
            if (result.values().length() == 1) {
              addGroup(
                  new GroupReference(
                      result.values().get(0).getGroupUUID(), result.values().get(0).name()));
            } else {
              groupToAdd.setFocus(true);
              new ErrorDialog(Gerrit.M.noSuchGroupMessage(ref.getName())).center();
            }
          }

          @Override
          public void onFailure(Throwable caught) {
            addRule.setEnabled(true);
            super.onFailure(caught);
          }
        });
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:49,代码来源:PermissionEditor.java


注:本文中的com.google.gerrit.common.data.PermissionRule.setAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。