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


Java GroupDescription.Internal方法代码示例

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


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

示例1: getIndirectMemberIds

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private Set<Account.Id> getIndirectMemberIds(
    GroupDescription.Internal group, HashSet<AccountGroup.UUID> seenGroups) {
  Set<Account.Id> indirectMembers = new HashSet<>();
  for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) {
    if (!seenGroups.contains(subgroupUuid)) {
      seenGroups.add(subgroupUuid);

      Set<Account.Id> subgroupMembers =
          groupCache
              .get(subgroupUuid)
              .map(InternalGroupDescription::new)
              .map(
                  subgroup -> {
                    GroupControl subgroupControl = groupControlFactory.controlFor(subgroup);
                    return getTransitiveMemberIds(subgroup, subgroupControl, seenGroups);
                  })
              .orElseGet(ImmutableSet::of);
      indirectMembers.addAll(subgroupMembers);
    }
  }
  return indirectMembers;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:23,代码来源:ListMembers.java

示例2: apply

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
@Override
public GroupInfo apply(GroupResource resource)
    throws MethodNotAllowedException, ResourceNotFoundException, OrmException {
  GroupDescription.Internal group =
      resource.asInternalGroup().orElseThrow(MethodNotAllowedException::new);
  try {
    GroupControl c = controlFactory.validateFor(group.getOwnerGroupUUID());
    return json.format(c.getGroup());
  } catch (NoSuchGroupException e) {
    throw new ResourceNotFoundException();
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:13,代码来源:GetOwner.java

示例3: createOptions

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
public static GroupOptionsInfo createOptions(GroupDescription.Basic group) {
  GroupOptionsInfo options = new GroupOptionsInfo();
  if (group instanceof GroupDescription.Internal
      && ((GroupDescription.Internal) group).isVisibleToAll()) {
    options.visibleToAll = true;
  }
  return options;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:GroupJson.java

示例4: get

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
@Override
public GroupDescription.Internal get(AccountGroup.UUID uuid) {
  if (!handles(uuid)) {
    return null;
  }

  return groupCache.get(uuid).map(InternalGroupDescription::new).orElse(null);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:InternalGroupBackend.java

示例5: apply

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
@Override
public List<GroupInfo> apply(GroupResource resource, Input input)
    throws MethodNotAllowedException, AuthException, UnprocessableEntityException, OrmException,
        ResourceNotFoundException, IOException, ConfigInvalidException {
  GroupDescription.Internal group =
      resource.asInternalGroup().orElseThrow(MethodNotAllowedException::new);
  input = Input.init(input);

  GroupControl control = resource.getControl();
  if (!control.canAddGroup()) {
    throw new AuthException(String.format("Cannot add groups to group %s", group.getName()));
  }

  List<GroupInfo> result = new ArrayList<>();
  Set<AccountGroup.UUID> subgroupUuids = new HashSet<>();
  for (String subgroupIdentifier : input.groups) {
    GroupDescription.Basic subgroup = groupsCollection.parse(subgroupIdentifier);
    subgroupUuids.add(subgroup.getGroupUUID());
    result.add(json.format(subgroup));
  }

  AccountGroup.UUID groupUuid = group.getGroupUUID();
  try {
    addSubgroups(groupUuid, subgroupUuids);
  } catch (NoSuchGroupException e) {
    throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
  }
  return result;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:30,代码来源:AddSubgroups.java

示例6: isOwner

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private boolean isOwner(CurrentUser user, GroupDescription.Internal group) {
  try {
    return genericGroupControlFactory.controlFor(user, group.getGroupUUID()).isOwner();
  } catch (NoSuchGroupException e) {
    return false;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:ListGroups.java

示例7: owner

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private AccountGroup.Id owner(GroupInput input) throws UnprocessableEntityException {
  if (input.ownerId != null) {
    GroupDescription.Internal d = groups.parseInternal(Url.decode(input.ownerId));
    return d.getId();
  }
  return null;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:CreateGroup.java

示例8: apply

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
@Override
public Response<?> apply(GroupResource resource, Input input)
    throws AuthException, MethodNotAllowedException, UnprocessableEntityException, OrmException,
        ResourceNotFoundException, IOException, ConfigInvalidException {
  GroupDescription.Internal internalGroup =
      resource.asInternalGroup().orElseThrow(MethodNotAllowedException::new);
  input = Input.init(input);

  final GroupControl control = resource.getControl();
  if (!control.canRemoveGroup()) {
    throw new AuthException(
        String.format("Cannot delete groups from group %s", internalGroup.getName()));
  }

  Set<AccountGroup.UUID> subgroupsToRemove = new HashSet<>();
  for (String subgroupIdentifier : input.groups) {
    GroupDescription.Basic subgroup = groupsCollection.parse(subgroupIdentifier);
    subgroupsToRemove.add(subgroup.getGroupUUID());
  }

  AccountGroup.UUID groupUuid = internalGroup.getGroupUUID();
  try {
    removeSubgroups(groupUuid, subgroupsToRemove);
  } catch (NoSuchGroupException e) {
    throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
  }

  return Response.none();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:30,代码来源:DeleteSubgroups.java

示例9: asInternalGroup

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
public Optional<GroupDescription.Internal> asInternalGroup() {
  GroupDescription.Basic group = getGroup();
  if (group instanceof GroupDescription.Internal) {
    return Optional.of((GroupDescription.Internal) group);
  }
  return Optional.empty();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:GroupResource.java

示例10: isOwner

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
public boolean isOwner() {
  if (isOwner != null) {
    return isOwner;
  }

  if (group instanceof GroupDescription.Internal) {
    AccountGroup.UUID ownerUUID = ((GroupDescription.Internal) group).getOwnerGroupUUID();
    isOwner = getUser().getEffectiveGroups().contains(ownerUUID) || canAdministrateServer();
  } else {
    isOwner = false;
  }
  return isOwner;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:GroupControl.java

示例11: parseGroups

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private Set<AccountGroup.UUID> parseGroups(List<String> groups)
    throws UnprocessableEntityException {
  Set<AccountGroup.UUID> groupUuids = new HashSet<>();
  if (groups != null) {
    for (String g : groups) {
      GroupDescription.Internal internalGroup = groupsCollection.parseInternal(g);
      groupUuids.add(internalGroup.getGroupUUID());
    }
  }
  return groupUuids;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:12,代码来源:CreateAccount.java

示例12: apply

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
@Override
public GroupOptionsInfo apply(GroupResource resource, GroupOptionsInfo input)
    throws MethodNotAllowedException, AuthException, BadRequestException,
        ResourceNotFoundException, OrmException, IOException, ConfigInvalidException {
  GroupDescription.Internal internalGroup =
      resource.asInternalGroup().orElseThrow(MethodNotAllowedException::new);
  if (!resource.getControl().isOwner()) {
    throw new AuthException("Not group owner");
  }

  if (input == null) {
    throw new BadRequestException("options are required");
  }
  if (input.visibleToAll == null) {
    input.visibleToAll = false;
  }

  if (internalGroup.isVisibleToAll() != input.visibleToAll) {
    AccountGroup.UUID groupUuid = internalGroup.getGroupUUID();
    InternalGroupUpdate groupUpdate =
        InternalGroupUpdate.builder().setVisibleToAll(input.visibleToAll).build();
    try {
      groupsUpdateProvider.get().updateGroup(db.get(), groupUuid, groupUpdate);
    } catch (NoSuchGroupException e) {
      throw new ResourceNotFoundException(String.format("Group %s not found", groupUuid));
    }
  }

  GroupOptionsInfo options = new GroupOptionsInfo();
  if (input.visibleToAll) {
    options.visibleToAll = true;
  }
  return options;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:PutOptions.java

示例13: getDirectSubgroups

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
public List<GroupInfo> getDirectSubgroups(
    GroupDescription.Internal group, GroupControl groupControl) throws OrmException {
  boolean ownerOfParent = groupControl.isOwner();
  List<GroupInfo> included = new ArrayList<>();
  for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) {
    try {
      GroupControl i = controlFactory.controlFor(subgroupUuid);
      if (ownerOfParent || i.isVisible()) {
        included.add(json.format(i.getGroup()));
      }
    } catch (NoSuchGroupException notFound) {
      log.warn(
          String.format(
              "Group %s no longer available, subgroup of %s", subgroupUuid, group.getName()));
      continue;
    }
  }
  Collections.sort(
      included,
      new Comparator<GroupInfo>() {
        @Override
        public int compare(GroupInfo a, GroupInfo b) {
          int cmp = nullToEmpty(a.name).compareTo(nullToEmpty(b.name));
          if (cmp != 0) {
            return cmp;
          }
          return nullToEmpty(a.id).compareTo(nullToEmpty(b.id));
        }
      });
  return included;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:32,代码来源:ListSubgroups.java

示例14: checkSameGroup

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private static void checkSameGroup(GroupDescription.Internal group, GroupControl groupControl) {
  checkState(
      group.equals(groupControl.getGroup()), "Specified group and groupControl do not match");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:5,代码来源:ListMembers.java

示例15: canSeeMembers

import com.google.gerrit.common.data.GroupDescription; //导入方法依赖的package包/类
private boolean canSeeMembers() {
  if (group instanceof GroupDescription.Internal) {
    return ((GroupDescription.Internal) group).isVisibleToAll() || isOwner();
  }
  return false;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:GroupControl.java


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