本文整理汇总了Java中com.google.gerrit.common.data.GroupDescription类的典型用法代码示例。如果您正苦于以下问题:Java GroupDescription类的具体用法?Java GroupDescription怎么用?Java GroupDescription使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GroupDescription类属于com.google.gerrit.common.data包,在下文中一共展示了GroupDescription类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGroupInfo
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private Map<AccountGroup.UUID, GroupInfo> buildGroupInfo(List<AccessSection> local) {
Map<AccountGroup.UUID, GroupInfo> infos = new HashMap<>();
for (AccessSection section : local) {
for (Permission permission : section.getPermissions()) {
for (PermissionRule rule : permission.getRules()) {
if (rule.getGroup() != null) {
AccountGroup.UUID uuid = rule.getGroup().getUUID();
if (uuid != null && !infos.containsKey(uuid)) {
GroupDescription.Basic group = groupBackend.get(uuid);
infos.put(uuid, group != null ? new GroupInfo(group) : null);
}
}
}
}
}
return Maps.filterEntries(infos, in -> in.getValue() != null);
}
示例2: suggestGroups
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private List<GroupInfo> suggestGroups() throws OrmException, BadRequestException {
if (conflictingSuggestParameters()) {
throw new BadRequestException(
"You should only have no more than one --project and -n with --suggest");
}
List<GroupReference> groupRefs =
Lists.newArrayList(
Iterables.limit(
groupBackend.suggest(suggest, projects.stream().findFirst().orElse(null)),
limit <= 0 ? 10 : Math.min(limit, 10)));
List<GroupInfo> groupInfos = Lists.newArrayListWithCapacity(groupRefs.size());
for (GroupReference ref : groupRefs) {
GroupDescription.Basic desc = groupBackend.get(ref.getUUID());
if (desc != null) {
groupInfos.add(json.addOptions(options).format(desc));
}
}
return groupInfos;
}
示例3: isNotRelevant
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private boolean isNotRelevant(Pattern pattern, GroupDescription.Internal group) {
if (!Strings.isNullOrEmpty(matchSubstring)) {
if (!group.getName().toLowerCase(Locale.US).contains(matchSubstring.toLowerCase(Locale.US))) {
return true;
}
} else if (pattern != null) {
if (!pattern.matcher(group.getName()).matches()) {
return true;
}
}
if (visibleToAll && !group.isVisibleToAll()) {
return true;
}
if (!groupsToInspect.isEmpty() && !groupsToInspect.contains(group.getGroupUUID())) {
return true;
}
GroupControl c = groupControlFactory.controlFor(group);
return !c.isVisible();
}
示例4: apply
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
@Override
public String apply(GroupResource rsrc, NameInput input)
throws MethodNotAllowedException, AuthException, BadRequestException,
ResourceConflictException, ResourceNotFoundException, OrmException, IOException,
ConfigInvalidException {
GroupDescription.Internal internalGroup =
rsrc.asInternalGroup().orElseThrow(MethodNotAllowedException::new);
if (!rsrc.getControl().isOwner()) {
throw new AuthException("Not group owner");
} else if (input == null || Strings.isNullOrEmpty(input.name)) {
throw new BadRequestException("name is required");
}
String newName = input.name.trim();
if (newName.isEmpty()) {
throw new BadRequestException("name is required");
}
if (internalGroup.getName().equals(newName)) {
return newName;
}
renameGroup(internalGroup, newName);
return newName;
}
示例5: 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;
}
示例6: parse
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
@Override
public GroupResource parse(TopLevelResource parent, IdString id)
throws AuthException, ResourceNotFoundException {
final CurrentUser user = self.get();
if (user instanceof AnonymousUser) {
throw new AuthException("Authentication required");
} else if (!(user.isIdentifiedUser())) {
throw new ResourceNotFoundException(id);
}
GroupDescription.Basic group = parseId(id.get());
if (group == null) {
throw new ResourceNotFoundException(id.get());
}
GroupControl ctl = groupControlFactory.controlFor(group);
if (!ctl.isVisible()) {
throw new ResourceNotFoundException(id);
}
return new GroupResource(ctl);
}
示例7: createProjectConfig
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private void createProjectConfig(CreateProjectArgs args)
throws IOException, ConfigInvalidException {
try (MetaDataUpdate md = metaDataUpdateFactory.create(args.getProject())) {
ProjectConfig config = ProjectConfig.read(md);
Project newProject = config.getProject();
newProject.setDescription(args.projectDescription);
newProject.setSubmitType(
MoreObjects.firstNonNull(
args.submitType, repositoryCfg.getDefaultSubmitType(args.getProject())));
newProject.setUseContributorAgreements(args.contributorAgreements);
newProject.setUseSignedOffBy(args.signedOffBy);
newProject.setUseContentMerge(args.contentMerge);
newProject.setCreateNewChangeForAllNotInTarget(args.newChangeForAllNotInTarget);
newProject.setRequireChangeID(args.changeIdRequired);
newProject.setMaxObjectSizeLimit(args.maxObjectSizeLimit);
if (args.newParent != null) {
newProject.setParentName(args.newParent);
}
if (!args.ownerIds.isEmpty()) {
AccessSection all = config.getAccessSection(AccessSection.ALL, true);
for (AccountGroup.UUID ownerId : args.ownerIds) {
GroupDescription.Basic g = groupBackend.get(ownerId);
if (g != null) {
GroupReference group = config.resolve(GroupReference.forGroup(g));
all.getPermission(Permission.OWNER, true).add(new PermissionRule(group));
}
}
}
md.setMessage("Created project\n");
config.commit(md);
md.getRepository().setGitwebDescription(args.projectDescription);
}
projectCache.onCreateProject(args.getProject());
}
示例8: updateGroupNames
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
/**
* Check all GroupReferences use current group name, repairing stale ones.
*
* @param groupBackend cache to use when looking up group information by UUID.
* @return true if one or more group names was stale.
*/
public boolean updateGroupNames(GroupBackend groupBackend) {
boolean dirty = false;
for (GroupReference ref : groupList.references()) {
GroupDescription.Basic g = groupBackend.get(ref.getUUID());
if (g != null && !g.getName().equals(ref.getName())) {
dirty = true;
ref.setName(g.getName());
}
}
return dirty;
}
示例9: 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();
}
}
示例10: 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;
}
示例11: createGroupInfo
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private GroupInfo createGroupInfo(
GroupDescription.Basic group, Supplier<GroupControl> groupControlSupplier)
throws OrmException {
GroupInfo info = createBasicGroupInfo(group);
if (group instanceof GroupDescription.Internal) {
addInternalDetails(info, (GroupDescription.Internal) group, groupControlSupplier);
}
return info;
}
示例12: createBasicGroupInfo
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private static GroupInfo createBasicGroupInfo(GroupDescription.Basic group) {
GroupInfo info = new GroupInfo();
info.id = Url.encode(group.getGroupUUID().get());
info.name = Strings.emptyToNull(group.getName());
info.url = Strings.emptyToNull(group.getUrl());
info.options = createOptions(group);
return info;
}
示例13: addInternalDetails
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void addInternalDetails(
GroupInfo info,
GroupDescription.Internal internalGroup,
Supplier<GroupControl> groupControlSupplier)
throws OrmException {
info.description = Strings.emptyToNull(internalGroup.getDescription());
info.groupId = internalGroup.getId().get();
AccountGroup.UUID ownerGroupUUID = internalGroup.getOwnerGroupUUID();
if (ownerGroupUUID != null) {
info.ownerId = Url.encode(ownerGroupUUID.get());
GroupDescription.Basic o = groupBackend.get(ownerGroupUUID);
if (o != null) {
info.owner = o.getName();
}
}
info.createdOn = internalGroup.getCreatedOn();
if (options.contains(MEMBERS)) {
info.members = listMembers.get().getDirectMembers(internalGroup, groupControlSupplier.get());
}
if (options.contains(INCLUDES)) {
info.includes =
listSubgroups.get().getDirectSubgroups(internalGroup, groupControlSupplier.get());
}
}
示例14: 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;
}
示例15: getAllExistingGroups
import com.google.gerrit.common.data.GroupDescription; //导入依赖的package包/类
private Stream<GroupDescription.Internal> getAllExistingGroups() throws OrmException {
if (!projects.isEmpty()) {
return projects
.stream()
.map(ProjectState::getAllGroups)
.flatMap(Collection::stream)
.map(GroupReference::getUUID)
.distinct()
.map(groupCache::get)
.flatMap(Streams::stream)
.map(InternalGroupDescription::new);
}
return groups.getAll(db.get()).map(InternalGroupDescription::new);
}