本文整理汇总了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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}