Remove unused DirectoryException
Callers of AccountDirectory#fillAccountInfo converted DirectoryException into OrmException. By removing the throws DirectoryException clause from that method a lot of callers no longer need to deal with OrmException. Change-Id: I23a74bd35f98f8c728f28c9b4ef5e49680f1d270 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -47,17 +47,6 @@ public abstract class AccountDirectory {
|
|||||||
STATUS
|
STATUS
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options)
|
public abstract void fillAccountInfo(
|
||||||
throws DirectoryException;
|
Iterable<? extends AccountInfo> in, Set<FillOptions> options);
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static class DirectoryException extends Exception {
|
|
||||||
public DirectoryException(String message, Throwable why) {
|
|
||||||
super(message, why);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirectoryException(Throwable why) {
|
|
||||||
super(why);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,10 @@ package com.google.gerrit.server.account;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.server.account.AccountDirectory.DirectoryException;
|
|
||||||
import com.google.gerrit.server.account.AccountDirectory.FillOptions;
|
import com.google.gerrit.server.account.AccountDirectory.FillOptions;
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -86,23 +83,18 @@ public class AccountLoader {
|
|||||||
provided.add(info);
|
provided.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fill() throws OrmException {
|
public void fill() {
|
||||||
try {
|
directory.fillAccountInfo(Iterables.concat(created.values(), provided), options);
|
||||||
directory.fillAccountInfo(Iterables.concat(created.values(), provided), options);
|
|
||||||
} catch (DirectoryException e) {
|
|
||||||
Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
|
|
||||||
throw new OrmException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fill(Collection<? extends AccountInfo> infos) throws OrmException {
|
public void fill(Collection<? extends AccountInfo> infos) {
|
||||||
for (AccountInfo info : infos) {
|
for (AccountInfo info : infos) {
|
||||||
put(info);
|
put(info);
|
||||||
}
|
}
|
||||||
fill();
|
fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AccountInfo fillOne(Account.Id id) throws OrmException {
|
public AccountInfo fillOne(Account.Id id) {
|
||||||
AccountInfo info = get(id);
|
AccountInfo info = get(id);
|
||||||
fill();
|
fill();
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -63,8 +63,7 @@ public class InternalAccountDirectory extends AccountDirectory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options)
|
public void fillAccountInfo(Iterable<? extends AccountInfo> in, Set<FillOptions> options) {
|
||||||
throws DirectoryException {
|
|
||||||
if (options.equals(ID_ONLY)) {
|
if (options.equals(ID_ONLY)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,8 +415,7 @@ public class ChangeJson {
|
|||||||
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true);
|
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<List<ChangeInfo>> formatQueryResults(List<QueryResult<ChangeData>> in)
|
public List<List<ChangeInfo>> formatQueryResults(List<QueryResult<ChangeData>> in) {
|
||||||
throws OrmException {
|
|
||||||
try (Timer0.Context ignored = metrics.formatQueryResultsLatency.start()) {
|
try (Timer0.Context ignored = metrics.formatQueryResultsLatency.start()) {
|
||||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||||
List<List<ChangeInfo>> res = new ArrayList<>(in.size());
|
List<List<ChangeInfo>> res = new ArrayList<>(in.size());
|
||||||
|
|||||||
@@ -14,11 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.restapi.account;
|
package com.google.gerrit.server.restapi.account;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.server.account.AccountDirectory.DirectoryException;
|
|
||||||
import com.google.gerrit.server.account.AccountDirectory.FillOptions;
|
import com.google.gerrit.server.account.AccountDirectory.FillOptions;
|
||||||
import com.google.gerrit.server.account.AccountResource;
|
import com.google.gerrit.server.account.AccountResource;
|
||||||
import com.google.gerrit.server.account.InternalAccountDirectory;
|
import com.google.gerrit.server.account.InternalAccountDirectory;
|
||||||
@@ -45,12 +43,7 @@ public class GetDetail implements RestReadView<AccountResource> {
|
|||||||
AccountDetailInfo info = new AccountDetailInfo(a.getId().get());
|
AccountDetailInfo info = new AccountDetailInfo(a.getId().get());
|
||||||
info.registeredOn = a.getRegisteredOn();
|
info.registeredOn = a.getRegisteredOn();
|
||||||
info.inactive = !a.isActive() ? true : null;
|
info.inactive = !a.isActive() ? true : null;
|
||||||
try {
|
directory.fillAccountInfo(Collections.singleton(info), EnumSet.allOf(FillOptions.class));
|
||||||
directory.fillAccountInfo(Collections.singleton(info), EnumSet.allOf(FillOptions.class));
|
|
||||||
} catch (DirectoryException e) {
|
|
||||||
Throwables.throwIfInstanceOf(e.getCause(), OrmException.class);
|
|
||||||
throw new OrmException(e);
|
|
||||||
}
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import com.google.gerrit.reviewdb.client.FixReplacement;
|
|||||||
import com.google.gerrit.reviewdb.client.FixSuggestion;
|
import com.google.gerrit.reviewdb.client.FixSuggestion;
|
||||||
import com.google.gerrit.reviewdb.client.RobotComment;
|
import com.google.gerrit.reviewdb.client.RobotComment;
|
||||||
import com.google.gerrit.server.account.AccountLoader;
|
import com.google.gerrit.server.account.AccountLoader;
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -71,7 +70,7 @@ class CommentJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private abstract class BaseCommentFormatter<F extends Comment, T extends CommentInfo> {
|
private abstract class BaseCommentFormatter<F extends Comment, T extends CommentInfo> {
|
||||||
public T format(F comment) throws OrmException {
|
public T format(F comment) {
|
||||||
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
||||||
T info = toInfo(comment, loader);
|
T info = toInfo(comment, loader);
|
||||||
if (loader != null) {
|
if (loader != null) {
|
||||||
@@ -80,7 +79,7 @@ class CommentJson {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<T>> format(Iterable<F> comments) throws OrmException {
|
public Map<String, List<T>> format(Iterable<F> comments) {
|
||||||
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
||||||
|
|
||||||
Map<String, List<T>> out = new TreeMap<>();
|
Map<String, List<T>> out = new TreeMap<>();
|
||||||
@@ -106,7 +105,7 @@ class CommentJson {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<T> formatAsList(Iterable<F> comments) throws OrmException {
|
public List<T> formatAsList(Iterable<F> comments) {
|
||||||
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
AccountLoader loader = fillAccounts ? accountLoaderFactory.create(true) : null;
|
||||||
|
|
||||||
List<T> out =
|
List<T> out =
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public class ReviewersUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SuggestedReviewerInfo> loadAccounts(List<Account.Id> accountIds)
|
private List<SuggestedReviewerInfo> loadAccounts(List<Account.Id> accountIds)
|
||||||
throws OrmException, PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
Set<FillOptions> fillOptions =
|
Set<FillOptions> fillOptions =
|
||||||
permissionBackend.currentUser().test(GlobalPermission.MODIFY_ACCOUNT)
|
permissionBackend.currentUser().test(GlobalPermission.MODIFY_ACCOUNT)
|
||||||
? EnumSet.of(FillOptions.SECONDARY_EMAILS)
|
? EnumSet.of(FillOptions.SECONDARY_EMAILS)
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AccountInfo> toAccountInfoList(Set<Account.Id> accountIds) throws OrmException {
|
private List<AccountInfo> toAccountInfoList(Set<Account.Id> accountIds) {
|
||||||
List<AccountInfo> result = new ArrayList<>();
|
List<AccountInfo> result = new ArrayList<>();
|
||||||
AccountLoader loader = infoFactory.create(true);
|
AccountLoader loader = infoFactory.create(true);
|
||||||
for (Account.Id accId : accountIds) {
|
for (Account.Id accId : accountIds) {
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class ListMembers implements RestReadView<GroupResource> {
|
|||||||
return getDirectMembers(group, resource.getControl());
|
return getDirectMembers(group, resource.getControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AccountInfo> getTransitiveMembers(AccountGroup.UUID groupUuid) throws OrmException {
|
public List<AccountInfo> getTransitiveMembers(AccountGroup.UUID groupUuid) {
|
||||||
Optional<InternalGroup> group = groupCache.get(groupUuid);
|
Optional<InternalGroup> group = groupCache.get(groupUuid);
|
||||||
if (group.isPresent()) {
|
if (group.isPresent()) {
|
||||||
InternalGroupDescription internalGroup = new InternalGroupDescription(group.get());
|
InternalGroupDescription internalGroup = new InternalGroupDescription(group.get());
|
||||||
@@ -86,7 +86,7 @@ public class ListMembers implements RestReadView<GroupResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<AccountInfo> getTransitiveMembers(
|
private List<AccountInfo> getTransitiveMembers(
|
||||||
GroupDescription.Internal group, GroupControl groupControl) throws OrmException {
|
GroupDescription.Internal group, GroupControl groupControl) {
|
||||||
checkSameGroup(group, groupControl);
|
checkSameGroup(group, groupControl);
|
||||||
Set<Account.Id> members =
|
Set<Account.Id> members =
|
||||||
getTransitiveMemberIds(
|
getTransitiveMemberIds(
|
||||||
@@ -94,19 +94,19 @@ public class ListMembers implements RestReadView<GroupResource> {
|
|||||||
return toAccountInfos(members);
|
return toAccountInfos(members);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AccountInfo> getDirectMembers(InternalGroup group) throws OrmException {
|
public List<AccountInfo> getDirectMembers(InternalGroup group) {
|
||||||
InternalGroupDescription internalGroup = new InternalGroupDescription(group);
|
InternalGroupDescription internalGroup = new InternalGroupDescription(group);
|
||||||
return getDirectMembers(internalGroup, groupControlFactory.controlFor(internalGroup));
|
return getDirectMembers(internalGroup, groupControlFactory.controlFor(internalGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AccountInfo> getDirectMembers(
|
public List<AccountInfo> getDirectMembers(
|
||||||
GroupDescription.Internal group, GroupControl groupControl) throws OrmException {
|
GroupDescription.Internal group, GroupControl groupControl) {
|
||||||
checkSameGroup(group, groupControl);
|
checkSameGroup(group, groupControl);
|
||||||
Set<Account.Id> directMembers = getDirectMemberIds(group, groupControl);
|
Set<Account.Id> directMembers = getDirectMemberIds(group, groupControl);
|
||||||
return toAccountInfos(directMembers);
|
return toAccountInfos(directMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<AccountInfo> toAccountInfos(Set<Account.Id> members) throws OrmException {
|
private List<AccountInfo> toAccountInfos(Set<Account.Id> members) {
|
||||||
List<AccountInfo> memberInfos = new ArrayList<>(members.size());
|
List<AccountInfo> memberInfos = new ArrayList<>(members.size());
|
||||||
for (Account.Id member : members) {
|
for (Account.Id member : members) {
|
||||||
memberInfos.add(accountLoader.get(member));
|
memberInfos.add(accountLoader.get(member));
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import com.google.gerrit.server.ioutil.ColumnFormatter;
|
|||||||
import com.google.gerrit.server.restapi.group.ListMembers;
|
import com.google.gerrit.server.restapi.group.ListMembers;
|
||||||
import com.google.gerrit.sshd.CommandMetaData;
|
import com.google.gerrit.sshd.CommandMetaData;
|
||||||
import com.google.gerrit.sshd.SshCommand;
|
import com.google.gerrit.sshd.SshCommand;
|
||||||
import com.google.gwtorm.server.OrmException;
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -68,7 +67,7 @@ public class ListMembersCommand extends SshCommand {
|
|||||||
this.groupCache = groupCache;
|
this.groupCache = groupCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void display(PrintWriter writer) throws OrmException {
|
void display(PrintWriter writer) {
|
||||||
Optional<InternalGroup> group = groupCache.get(new AccountGroup.NameKey(name));
|
Optional<InternalGroup> group = groupCache.get(new AccountGroup.NameKey(name));
|
||||||
String errorText = "Group not found or not visible\n";
|
String errorText = "Group not found or not visible\n";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user