use of com.google.gerrit.server.IdentifiedUser in project gerrit by GerritCodeReview.
the class MembersCollection method parse.
@Override
public MemberResource parse(GroupResource parent, IdString id) throws MethodNotAllowedException, AuthException, ResourceNotFoundException, OrmException {
if (parent.toAccountGroup() == null) {
throw new MethodNotAllowedException();
}
IdentifiedUser user = accounts.parse(TopLevelResource.INSTANCE, id).getUser();
AccountGroupMember.Key key = new AccountGroupMember.Key(user.getAccountId(), parent.toAccountGroup().getId());
if (db.get().accountGroupMembers().get(key) != null && parent.getControl().canSeeMember(user.getAccountId())) {
return new MemberResource(parent, user);
}
throw new ResourceNotFoundException(id);
}
use of com.google.gerrit.server.IdentifiedUser in project gerrit by GerritCodeReview.
the class OwnerinPredicate method match.
@Override
public boolean match(final ChangeData object) throws OrmException {
final Change change = object.change();
if (change == null) {
return false;
}
final IdentifiedUser owner = userFactory.create(change.getOwner());
return owner.getEffectiveGroups().contains(uuid);
}
use of com.google.gerrit.server.IdentifiedUser in project gerrit by GerritCodeReview.
the class GetAgreements method apply.
@Override
public List<AgreementInfo> apply(AccountResource resource) throws RestApiException {
if (!agreementsEnabled) {
throw new MethodNotAllowedException("contributor agreements disabled");
}
if (!self.get().isIdentifiedUser()) {
throw new AuthException("not allowed to get contributor agreements");
}
IdentifiedUser user = self.get().asIdentifiedUser();
if (user != resource.getUser()) {
throw new AuthException("not allowed to get contributor agreements");
}
List<AgreementInfo> results = new ArrayList<>();
Collection<ContributorAgreement> cas = projectCache.getAllProjects().getConfig().getContributorAgreements();
for (ContributorAgreement ca : cas) {
List<AccountGroup.UUID> groupIds = new ArrayList<>();
for (PermissionRule rule : ca.getAccepted()) {
if ((rule.getAction() == Action.ALLOW) && (rule.getGroup() != null)) {
if (rule.getGroup().getUUID() != null) {
groupIds.add(rule.getGroup().getUUID());
} else {
log.warn("group \"" + rule.getGroup().getName() + "\" does not " + "exist, referenced in CLA \"" + ca.getName() + "\"");
}
}
}
if (user.getEffectiveGroups().containsAnyOf(groupIds)) {
results.add(agreementJson.format(ca));
}
}
return results;
}
use of com.google.gerrit.server.IdentifiedUser in project gerrit by GerritCodeReview.
the class StarredChanges method parse.
@Override
public AccountResource.StarredChange parse(AccountResource parent, IdString id) throws ResourceNotFoundException, OrmException {
IdentifiedUser user = parent.getUser();
ChangeResource change = changes.parse(TopLevelResource.INSTANCE, id);
if (starredChangesUtil.getLabels(user.getAccountId(), change.getId()).contains(StarredChangesUtil.DEFAULT_LABEL)) {
return new AccountResource.StarredChange(user, change);
}
throw new ResourceNotFoundException(id);
}
use of com.google.gerrit.server.IdentifiedUser in project gerrit by GerritCodeReview.
the class Stars method parse.
@Override
public Star parse(AccountResource parent, IdString id) throws ResourceNotFoundException, OrmException {
IdentifiedUser user = parent.getUser();
ChangeResource change = changes.parse(TopLevelResource.INSTANCE, id);
Set<String> labels = starredChangesUtil.getLabels(user.getAccountId(), change.getId());
return new AccountResource.Star(user, change, labels);
}
Aggregations