本文整理汇总了Java中com.google.gerrit.common.data.PermissionRule.setForce方法的典型用法代码示例。如果您正苦于以下问题:Java PermissionRule.setForce方法的具体用法?Java PermissionRule.setForce怎么用?Java PermissionRule.setForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gerrit.common.data.PermissionRule
的用法示例。
在下文中一共展示了PermissionRule.setForce方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: grant
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
protected void grant(
Project.NameKey project,
String ref,
String permission,
boolean force,
AccountGroup.UUID groupUUID)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
md.setMessage(String.format("Grant %s on %s", permission, ref));
ProjectConfig config = ProjectConfig.read(md);
AccessSection s = config.getAccessSection(ref, true);
Permission p = s.getPermission(permission, true);
PermissionRule rule = Util.newRule(config, groupUUID);
rule.setForce(force);
p.add(rule);
config.commit(md);
projectCache.evict(config.getProject());
}
}
示例2: grantLabel
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
protected void grantLabel(
String label,
int min,
int max,
Project.NameKey project,
String ref,
boolean force,
AccountGroup.UUID groupUUID,
boolean exclusive)
throws RepositoryNotFoundException, IOException, ConfigInvalidException {
String permission = Permission.LABEL + label;
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
md.setMessage(String.format("Grant %s on %s", permission, ref));
ProjectConfig config = ProjectConfig.read(md);
AccessSection s = config.getAccessSection(ref, true);
Permission p = s.getPermission(permission, true);
p.setExclusiveGroup(exclusive);
PermissionRule rule = Util.newRule(config, groupUUID);
rule.setForce(force);
rule.setMin(min);
rule.setMax(max);
p.add(rule);
config.commit(md);
projectCache.evict(config.getProject());
}
}
示例3: grant
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
public static void grant(
ProjectConfig config,
AccessSection section,
String permission,
boolean force,
Boolean exclusive,
GroupReference... groupList) {
Permission p = section.getPermission(permission, true);
if (exclusive != null) {
p.setExclusiveGroup(exclusive);
}
for (GroupReference group : groupList) {
if (group != null) {
PermissionRule r = rule(config, group);
r.setForce(force);
p.add(r);
}
}
}
示例4: unblockForce
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
@Test
public void unblockForce() {
PermissionRule r = block(local, PUSH, ANONYMOUS_USERS, "refs/heads/*");
r.setForce(true);
allow(local, PUSH, DEVS, "refs/heads/*").setForce(true);
ProjectControl u = user(local, DEVS);
assertCanForceUpdate("refs/heads/master", u);
}
示例5: unblockForceWithAllowNoForce_NotPossible
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
@Test
public void unblockForceWithAllowNoForce_NotPossible() {
PermissionRule r = block(local, PUSH, ANONYMOUS_USERS, "refs/heads/*");
r.setForce(true);
allow(local, PUSH, DEVS, "refs/heads/*");
ProjectControl u = user(local, DEVS);
assertCannotForceUpdate("refs/heads/master", u);
}
示例6: setProjectPermissions
import com.google.gerrit.common.data.PermissionRule; //导入方法依赖的package包/类
private void setProjectPermissions() {
addPermissions(AccessSection.ALL, Permission.OWNER);
addPermissions(
CODE_REVIEW_REFS,
Permission.READ,
Permission.PUSH,
Permission.REMOVE_REVIEWER,
Permission.SUBMIT,
Permission.REBASE);
PermissionRule reviewRange = new PermissionRule(getMyGroup());
reviewRange.setMin(new Integer(-2));
reviewRange.setMax(new Integer(+2));
addPermission(CODE_REVIEW_REFS, Permission.LABEL + CODE_REVIEW_LABEL, reviewRange);
PermissionRule verifiedRange = new PermissionRule(getMyGroup());
verifiedRange.setMin(new Integer(-1));
verifiedRange.setMax(new Integer(+1));
addPermission(CODE_REVIEW_REFS, Permission.LABEL + VERIFIED_LABEL, verifiedRange);
addPermissions(AccessSection.HEADS, Permission.READ, Permission.CREATE, Permission.PUSH_MERGE);
PermissionRule forcePush = new PermissionRule(getMyGroup());
forcePush.setForce(Boolean.TRUE);
addPermission(AccessSection.HEADS, Permission.PUSH, forcePush);
addPermissions(TAGS_REFS, Permission.PUSH);
PermissionRule removeTag = new PermissionRule(getMyGroup());
removeTag.setForce(Boolean.TRUE);
addPermission(TAGS_REFS, Permission.PUSH, removeTag);
}
示例7: 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;
}